Author Topic: Execute command and capture in Build  (Read 10410 times)

Ivan N. Zlatev

  • Community Member
  • Posts: 87
  • Hero Points: 5
Execute command and capture in Build
« on: September 11, 2007, 08:16:22 PM »
How can I execute something like "cd /svn/mono/mcs/class/System; make install PROFILE=net_2_0" and have the output be displayed in the Build window via a macro (so I will be able to navigate errors produced by the compilation)?

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Execute command and capture in Build
« Reply #1 on: September 11, 2007, 10:01:00 PM »
1. add a 'New' build tool to Project>Properties>Tools tab, add the commandline commands (incl. wildcards as project dir etc.) to and check the appr. 'capture' items. In a macro you can use 'project_build ( "<Tool name>" );'
2. create a macro like this simple example:
Code: [Select]
_command void ddir () name_info (','VSARG2_EDITORCTL)
{
   activate_build ();
   _str cmdline=get_env ("COMSPEC") " /c dir" " 2>&1";
   concur_command (cmdline, false, true, false, false);
   // optional: set focus back to edit win.
   cursor_data();
}

I'd prefer 1. b/c it uses the standard method and will get improved support in the future (e.g. error markers w/o any add. hacks/workarounds).
If you can't wait and really want error markers for user added build tools I can post the workaround I'm using.
Note it's using a deprecated method although there is no other possibilty curr. available.

HS2

Ivan N. Zlatev

  • Community Member
  • Posts: 87
  • Hero Points: 5
Re: Execute command and capture in Build
« Reply #2 on: September 13, 2007, 11:32:29 AM »
Thanks!

If you can't wait and really want error markers for user added build tools I can post the workaround I'm using.
Note it's using a deprecated method although there is no other possibilty curr. available.

I don't really need the markers I just want to be able to click on the errors and be dropped at the correct code line. Probably I will need to change the current working directory before build to match the one of the command to execute.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Execute command and capture in Build
« Reply #3 on: September 13, 2007, 11:57:06 AM »
Quote
change the current working directory before build
If you're going to use method 1. you get it for free ('Run from dir' also supports cool wildcards).
Conc. method 2. have this tiny example could be useful: http://community.slickedit.com/index.php?topic=1961.msg8227#msg8227
HS2
« Last Edit: September 13, 2007, 11:58:43 AM by hs2 »

Ivan N. Zlatev

  • Community Member
  • Posts: 87
  • Hero Points: 5
Re: Execute command and capture in Build
« Reply #4 on: September 13, 2007, 12:24:34 PM »
The reason why I don't want 1) is that I am hacking on a framework that I use in 90% of my projects (Mono/.Net) and I have to add the build tool to each of them. The other way will be to add a project containing the source code of the framework to each of my projects, but why, when I can recompile and install with a single command :). Thus I have decided to try and create a menu/toolbar with helper functions.

Currently I have:

Code: [Select]
#define MCS_PATH "/svn/mono/mcs/class"

_command void mono_recompile_assembly (_str assemblyName = "System", _str profile = "net_2_0")
{
   clear_pbuffer ();
   activate_build ();
   if (cd ("+p "MCS_PATH"/"assemblyName) != 0) {
      concur_command ("make install PROFILE="profile, false, true, false, false);
   }
   cursor_data();
}

The issue is that even though I end up with the correct working dir in Build:
Code: [Select]
System.Windows.Forms/WebBrowserBase.cs(199,33): error CS0117: `Mono.WebBrowser.IWebBrowser' does not contain a definition for `Shutdown'
/svn/mono/mcs/class/lib/net_2_0/Mono.Mozilla.dll (Location of the symbol related to previous error)
class/Managed.Windows.Forms# pwd
/svn/mono/mcs/class/Managed.Windows.Forms

When I double-click on the error the pwd is reverted back to what it was before I've set it and slickedit is unable to find the file with the error. Any ideas?

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Execute command and capture in Build
« Reply #5 on: September 13, 2007, 12:35:36 PM »
Hmm - try omit the last param (addErrorInfo) or set it to 'true'. This causes concur_command to set the 'VSLICKERRORPATH' needed for error parsing.
e.g. concur_command (cmdline, false, true, false, true);
HS2

Ivan N. Zlatev

  • Community Member
  • Posts: 87
  • Hero Points: 5
Re: Execute command and capture in Build
« Reply #6 on: September 13, 2007, 12:52:36 PM »
No go.  :( I still get promted for the file location and the current directory set to the one from before the execution of the macro. Any other ideas?

Code: [Select]
#define MCS_PATH "/svn/mono/mcs/class"

_command void mono_recompile_assembly (_str assemblyName = "System", _str profile = "net_2_0")
{
   clear_pbuffer ();
   activate_build ();
   if (cdd (MCS_PATH"/"assemblyName) != 0) {
      concur_command ("make install PROFILE="profile, false, true, false, true);
   }
   cursor_data();
}

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Execute command and capture in Build
« Reply #7 on: September 13, 2007, 01:02:25 PM »
Did you add the additional directories (not covered by VSLICKERRORPATH prefix) to 'Project Props>Directories' also needed for error searching ?
Do you see the 'set VSLICKERRORPATH ...' line in the build win ?

HS2

Ivan N. Zlatev

  • Community Member
  • Posts: 87
  • Hero Points: 5
Re: Execute command and capture in Build
« Reply #8 on: September 13, 2007, 01:49:27 PM »
Stupid me. I wass passing a wrong parameter from my menu entry. Thanks for all the help HS2.

Final:
Code: [Select]
#define MCS_PATH "/svn/mono/mcs/class"

_command void mono_recompile_assembly (_str assemblyName = "System", _str profile = "net_2_0")
{
   activate_build ();
   clear_pbuffer ();

   _str dir = getcwd ();
   if (cdd (MCS_PATH"/"assemblyName) == 0)
      concur_command ("make install PROFILE="profile, false, true, false, true);
   cdd (dir);

   cursor_data();
}