Author Topic: Macros in post-build tools?  (Read 12464 times)

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Macros in post-build tools?
« on: June 30, 2006, 06:42:19 pm »
Hello,

I have a very old compiler that writes error messages to an output file rather than stdout or stderr.
If there is an error in knife.mb, the error output is in knife.err.

Is there a way to create a post-build tool something like:
    'type %p%n.err'

And while we're at it, I could use some help with the regex for
    (knife.mb:50)  is not valid outside a Sub procedure or Function.

TIA for any ideas...

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: Macros in post-build tools?
« Reply #1 on: July 01, 2006, 02:51:37 am »
.mb and .err files... ¡Viva MapBasic!

If you're wanting a regular expression to parse the error lines, this should do the trick.

^\({#0:p}\:{#1:d#}\):b{#3?#}$

This is a SlickEdit syntax regex, and I used the same {#} grouping numbers that is used by the next-error regex logic. Can MapBasic spit out compiler errors to stdout, or is it still limited to using the .err files? Go to Build | Configure Error Parsing, add this expression as "MapBasic". (If you're using v11.0 or v11.0.1, that is)

Anyway, if you want to open up the .err files after a build is complete, you can use this as a post-build step.

"%(VSLICKBIN)\vs.exe" "%rw*.err"

That just opens up any .err files right in the same instance of SlickEdit. Of course you'll need to tweak the "%rw*.err" part if your error output is going in some subdirectory.

But I wouldn't do it that way, since you have no support for using the next-error commands to jump to the offending error lines. And that's why you went through the trouble to put in a new error parsing expression.

Try this: Add the following as your post-build step
type "%rw*.err"

The type command works like the cat command, except that it will also place the file names right before the content if your *.err wildcard yields multiple files. This gets the contents of the .err files into the build output window, and it can be picked up by our build output error and warning scanning. (Of course you do need to add that MapBasic regex for those lines from .err files to be recognized as such)

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Macros in post-build tools?
« Reply #2 on: July 01, 2006, 11:26:07 am »
.mb and .err files... ¡Viva MapBasic!

If you're wanting a regular expression to parse the error lines, this should do the trick.

^\({#0:p}\:{#1:d#}\):b{#3?#}$

This is a SlickEdit syntax regex, and I used the same {#} grouping numbers that is used by the next-error regex logic.
Thanks, I'll try that.
Quote
Can MapBasic spit out compiler errors to stdout, or is it still limited to using the .err files?
Alas, its only output is still to the .err files.

Quote
Go to Build | Configure Error Parsing, add this expression as "MapBasic". (If you're using v11.0 or v11.0.1, that is)
Done (using 11.0.1).
Quote
But I wouldn't do it that way, since you have no support for using the next-error commands to jump to the offending error lines. And that's why you went through the trouble to put in a new error parsing expression.

Try this: Add the following as your post-build step
type "%rw*.err"

The type command works like the cat command, except that it will also place the file names right before the content if your *.err wildcard yields multiple files. This gets the contents of the .err files into the build output window, and it can be picked up by our build output error and warning scanning. (Of course you do need to add that MapBasic regex for those lines from .err files to be recognized as such)

As for the 'type' command: 1) I would like to get the .err file for the .mb file in the current buffer; I think '%pn.err' is what I want; 2) nothing happens -- not only is there a long delay before the compile command is executed, but it seems that the post-build command is never executed.

If I go to the Build window and type 'type *.err', I can use next_error and prev_error.  (The regex error expression is working, at least...)

Thanks for your help.  I'm spending an unfortunate amount of time with MapBasic recently, so I'd like to build up SlickEdit's support for it.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Macros in post-build tools?
« Reply #3 on: July 03, 2006, 01:59:38 pm »
1) Project->Properties->Tools->Compile:
C:\MI\mapbasic.exe -d -nosplash %f

2) Project->Properties->Tools->Build:
C:\MI\mapbasic.exe -nosplash -l %f

Post-build:  type *.err
Both tools: Capture Output=TRUE, Output to Build Window=TRUE

Build window:
C:\MI\mapbasic.exe -d -nosplash C:\WorkMIMB\TThing_Main.mb&"c:\program files\slickedit11\win\vsbuild" -signalport 9000 -signal "execute-post-build "

Post-build is NOT executed


c:\PROGRA~1\SLICKE~3\win\vsbuild "build" "C:\WorkMIMB\GE20088\GE20088.vpw" "C:\WorkMIMB\GE20088\GE20088.vpj"&"c:\program files\slickedit11\win\vsbuild" -signalport 9000 -signal "execute-post-build C:\WorkMIMB\GE20088\GE20088.vpj"
VSLICKERRORPATH="C:\WorkMIMB\GE20088"
C:\MI\mapbasic.exe -nosplash -l
type *.err
The system cannot find the file specified.

** Note missing filename on mapbasic command line.
Post-build IS executed.

What is going on here?

pchandra

  • Community Member
  • Posts: 5
  • Hero Points: 2
Re: Macros in post-build tools?
« Reply #4 on: July 11, 2006, 02:05:59 pm »
Hi,

If you indeed want to run a Slick-C macro as a post-build command, create a batch file containing the line:

@echo <hex value 01><name of macro to run> <arguments to pass>

Then set that batch file as the post-build command of your project. <hex value 01> is a special character that, when seen on the output of the SlickEdit .process buffer, is interpreted by the IDE as meaning "the rest of this line is a command to run". I've been using this trick successfully on 11.x and 10.x, so it should work for you as well.

-Parag

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Macros in post-build tools?
« Reply #5 on: July 11, 2006, 03:25:31 pm »
Thanks for the suggestion, but I don't think I need it, as it is not Slick-C macros that I want to run.

The two problems I'm having:
1) For the Compile command, the post-build command is not executed.

2) For the Build command, the target filename is not being passed to the tool.
My Build command:
  c:\MI\MapBasic.exe -l -nosplash %f
What appears in the build window:
c: & cd c:\Work\ge19995

C:\Work\GE19995>C:\PROGRA~1\SLICKE~3\win\vsbuild "build" "c:\Work\ge19995\GE_19995.vpw" "c:\Work\ge19995\GE_19995.vpj"&"C:\Program Files\SlickEdit11\win\vsbuild" -signalport 9000 -signal "execute-post-build c:\Work\ge19995\GE_19995.vpj"
VSLICKERRORPATH="c:\Work\ge19995"
C:\MIMB\mapbasic.exe -l -nosplash
c: & cd c:\Work\ge19995
type *.err
The system cannot find the file specified.

Note there is no filename on the mapbasic command line.  "Type *.err" is the post-build command.
I've sent this to SlickEdit support, but haven't heard back from them.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Macros in post-build tools?
« Reply #6 on: August 17, 2006, 03:36:54 pm »

The two problems I'm having:
1) For the Compile command, the post-build command is not executed.

2) For the Build command, the target filename is not being passed to the tool.
My Build command:
  c:\MI\MapBasic.exe -l -nosplash %f
<snip>

SlickEdit support says both behaviors are correct -- Pre- and Post-Build commands only run for the Build command, and the %f isn't expanded for the Build command.

So, I still have my original problem -- after Build->Compile, how do I get the contents of the .err file into the output window?

Phil Barila

  • Senior Community Member
  • Posts: 742
  • Hero Points: 61
Re: Macros in post-build tools?
« Reply #7 on: August 17, 2006, 05:30:43 pm »
Compile != build.  There's no concept of "build current buffer", which is what it appears you are trying to do.  You need a "post-compile" step, though I don't think there is one.  The best you can do for post-build, which is supposed to compile anything that needs to be compiled, is to "type *.err", so at least all the errors show up and the error tracking works.  You might want to add a "del *.err" to your pre-build.  Make sure your build is happening in the proper directory, it's easy for that to get someplace it shouldn't.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Macros in post-build tools?
« Reply #8 on: August 17, 2006, 06:02:42 pm »
The mapbasic program works in two seperate steps.  First, use mapbasic to turn .mb source into .mbo intermediate files; 2nd, use mapbasic with a different command line switch and a project file to combine .mbo files into .mbx file. 

My Compile command invokes mapbasic to create the .mbo from the current buffer's .mb.
My Build command runs mapbasic with the project file that names all the .mbo that go in to the .mbx.
All the .mbo must be present for the .mbx to be created; if one is missing the build fails. 

I have some scripts that do a crude dependency checking and build all the .mbo before trying to build the .mbx, but the scripts don't run in cmd.exe.  (Is there a way to get slickedit to use a different shell on Windows?!)

Beside the post-build command, is there a way to programmaticaly load a file into the output window?

Phil Barila

  • Senior Community Member
  • Posts: 742
  • Hero Points: 61
Re: Macros in post-build tools?
« Reply #9 on: August 17, 2006, 06:13:00 pm »
If they are shell scripts, use cygwin or msys to run them inside the cmd.exe started by vs.  If they are PERL, Python, REXX, or some other reasonably mature scripting language, you should be able to use the existing interpreter/compiler for that language.  If they have an extension associated, they can be invoked directly.  Alternatively, you can use a path to the interpreter/compiler in your pre/post-build defs.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1249
  • Hero Points: 125
Re: Macros in post-build tools?
« Reply #10 on: August 17, 2006, 06:27:00 pm »
As long as your compile tool in a cmd.exe shell, you can setup the command-line for the Compile in Project Properties to run multiple shell commands.  Try changing the command-line to this:

C:\MI\mapbasic.exe -d -nosplash %f & type *.err

the & is a seperator for multiple commands in cmd.exe.  It will first execute the original compile step,followed by the type command.  You're also allowed to group and nest multiple commands with parens [(command1 & command2)&(command3 & command4)], but hopefully you won't need to go that far.


Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Macros in post-build tools?
« Reply #11 on: August 17, 2006, 07:54:54 pm »
As long as your compile tool in a cmd.exe shell, you can setup the command-line for the Compile in Project Properties to run multiple shell commands.  Try changing the command-line to this:

C:\MI\mapbasic.exe -d -nosplash %f & type *.err


Tried that; seems to be a timing problem, in it looks like the 'type *.err' is executed before mapbasic.exe has finished.

Here's the content of the Output window:
del *.err & C:\MI\mapbasic.exe -d -nosplash GELink.mb & type *.err&"C:\Program Files\SlickEdit11\win\vsbuild" -signalport 9000 -signal "execute-post-build "
The system cannot find the file specified.

C:\WorkMIMB\GE19995\SAMPLES\MAPBASIC\GoogleConnect>


If I type "type *.err" into the output window, I can use 'next-error'.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1249
  • Hero Points: 125
Re: Macros in post-build tools?
« Reply #12 on: August 17, 2006, 08:52:26 pm »
Forgive me, I'm not familiar with mapbasic.  It appears that is not a nice simple console application like gcc as I had hoped, and is instead a Windows app that accepts command-line options and self-terminates when it's done processing the command-line.  If that's the case, then yes, the type *.err command will execute immediately after the previous command instead of waiting for it to terminate. The same thing would happen if you tried "notepad.exe & type *.err".

Lets just give this a try:
cmd /c "C:\MI\mapbasic.exe -d -nosplash %f" & type *.err


I'm not 100% certain this will work.  This time, we are building in another command shell and waiting for the command shell to terminate, which it should terminate as soon as mapbasic terminates when used with the /c option.  Let me know if this works.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Macros in post-build tools?
« Reply #13 on: August 17, 2006, 09:00:12 pm »
Lets just give this a try:
cmd /c "C:\MI\mapbasic.exe -d -nosplash %f" & type *.err


From the Build window, reflecting the new Compile command that finally works as desired:
del *.err & cmd /c "C:\MI\mapbasic.exe -d -nosplash gelink.mb" & type *.err&"C:\Program Files\SlickEdit11\win\vsbuild" -signalport 9000 -signal "execute-post-build "


The extra command shell seems to do the trick...  Thanks for your help.