Author Topic: Linting Each Compiled File  (Read 11721 times)

Dave_Sinkula

  • Community Member
  • Posts: 27
  • Hero Points: 4
Linting Each Compiled File
« on: October 05, 2006, 02:02:51 AM »
I would like to add "Pre-Compile Command" or "Post-Compile Command" rather than a "Pre-Build Command" or "Post-Build Command", such that for each C file that I would like to compile, I can Lint it before or after. What would be the best approach to do this.

I have previously used a makefile and done such a thing in a build, but I would like it to also be attached to the compile command such that when new C files are added to the project, they are automagically Linted as well without amending a makefile.

Thanks for any advice.

jbezem

  • Community Member
  • Posts: 87
  • Hero Points: 8
Re: Linting Each Compiled File
« Reply #1 on: October 05, 2006, 06:59:09 AM »
Two easy ways I can see:
- replace your compiler command string with a call to a command script/batch file, performing a Lint run before executing the compiler proper; or
- in the project properties dialog, enhance the compiler command string to include a Lint command call before the compiler is executed.

Personally, I am not a fan of IDE's as "the only tool a developer needs", I do not (intend to) use SE to compile my projects, using GNU make and a command shell for that, so I'm not familiar enough with the new (v11) make-like features SE has now built-in.

FWIW,

Johan

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Linting Each Compiled File
« Reply #2 on: October 05, 2006, 07:43:04 AM »
The 'Pre/Post-Build' commands are called for Build, Rebuild and Compile.
For a better control you could use add. commands (see 'Tools' tab -> New ->e.g. 'Lint').
or enhance your makefile.

HS2

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Linting Each Compiled File
« Reply #3 on: October 05, 2006, 02:12:16 PM »
The 'Pre/Post-Build' commands are called for Build, Rebuild and Compile.

According to an email I received from SlickEdit Support, the Pre- and Post-Build commands are only called for Build and Rebuild, not Compile, Clean, Execute, or any custom build ops.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Linting Each Compiled File
« Reply #4 on: October 05, 2006, 03:54:35 PM »
Pre/Post-Build commands are limited to just Build & Rebuild.  But you should be able to create a custom project tool that should hopefully what you want.  Under Project Properties... Tools, create a New project tool and configure it to call lint.  Additionally, goto the Advanced step, and use the Call Other Tool so that the Compile tool is called before.  All tools set using the Advanced > Call Other Tool setup are called first, in order.  Then the command specified in the tool is executed.  This should work for you, but let me know if you have any problems setting that up.
« Last Edit: October 05, 2006, 03:56:37 PM by Lee »

Dave_Sinkula

  • Community Member
  • Posts: 27
  • Hero Points: 4
Re: Linting Each Compiled File
« Reply #5 on: October 05, 2006, 04:45:53 PM »
I do not (intend to) use SE to compile my projects, using GNU make and a command shell for that
  • I'm trying to learn how to use SlickEdit's builder to go away from maintaining a separate makefile.
  • Since my project is a Gnu C/C++ project, I first tried to learn Gnu make, but I was stymied by using the colon for the path's drive on my Windows box.
Pre/Post-Build commands are limited to just Build & Rebuild.  But you should be able to create a custom project tool that should hopefully what you want.  Under Project Properties... Tools, create a New project tool and configure it to call lint.  Additionally, goto the Advanced step, and use the Call Other Tool so that the Compile tool is called before.  All tools set using the Advanced > Call Other Tool setup are called first, in order.  Then the command specified in the tool is executed.  This should work for you, but let me know if you have any problems setting that up.
All righty, I've been trying to go this route (in fact the last two replies were during the attempt). I have added 2 tools:

  • Lint to be used like a compiler for a single source file to generate its information and try to create a .lob (lint output binary) file.
    This is its command line:
    Quote
    lint-nt.exe -Ii:\lint std.lnt -u %f -oo
    I have added this to the Advanced Tool Options for Compiler.

  • Lint Project to be used like a linker on the .lob files.
    This is its command line:
    Quote
    lint-nt.exe -Ii:\lint std.lnt *.lob
    I have added this to the Advanced Tool Options for Build and Rebuild.
First, I also have issues with setting up the linter correctly, but it seems I have remaining issues with SlickEdit as well.

Running the Compile gives me this output:
Quote
C:\projects\Test>"C:\Program Files\SlickEdit\win\vsbuild" compile  C:\projects\Test\SlickEdit\Sample.vpw C:\projects\Test\SlickEdit\Sample.vpj&"C:\Program Files\SlickEdit\win\vsbuild" -signalport 9000 -signal "execute-post-build "
VSLICKERRORPATH="C:\projects\Test"
VSLICKERRORPATH="C:\projects\Test"
lint-nt.exe -Ii:\lint std.lnt -u  -oo
PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software 1985-2006
Outputting to file .lob

gcc -c  -ansi  -g -Wall -pedantic -o "C:/projects/Test/Debug/"  ""
gcc.EXE: : No such file or directory
gcc.EXE: no input files
So it appears to be missing the input file information for both the linter and the compiler proper.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Linting Each Compiled File
« Reply #6 on: October 05, 2006, 05:20:20 PM »
I'm sorry guys ... I only checked the related macros in the Slick sources and didn't try it for real ...
That's what I found:
Code: [Select]
/**
 * This command is executed at the end of a build, rebuild, or compile
 *
 */
_command void execute_post_build()
{
   call_list("_postbuild_", arg(1));
}

/**
 * This command is executed at the before launching a build, rebuild, or compile
 *
 */
_command void execute_pre_build()
{
   call_list("_prebuild_", arg(1));
}
and in _project_command () the actual build command is checked against 'build','rebuild' and 'compile' too

So I assume that I'm a victim of wrong comments ... and wrong comments are evil ;)

@S-Team: Could you please fix the comments too ?

HS2

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Linting Each Compiled File
« Reply #7 on: October 05, 2006, 07:42:44 PM »
Dave_Sinkula: My apologies, what I should have said was: it should work, *in theory*.   I just confirmed what you've reported, it is not doing the right thing when you add the Advanced option.  There seems a step is missing somewhere in the build system where the filename is getting ignored or lost, I'm not sure which at the moment.  I'll file a defect for this.  Removing the Advanced step from the from the project should allow the tool(s) to work as expected.  The Lint tool should work correctly itself, as a stand-alone tool with the way you've configured, just not paired with the Compile step.  As a workaround, you may be to get around it by rolling both the compile and lint step into a batch file, and calling the batch from a custom Project tool.  Should work *in theory*, anyway :)


hs2:  Those macro commands you are referring to (execute_post_build, execute_pre_build) are actually used as part of a notification process telling us that vsbuild (our own build system) has finished it's processing.  I'm currently re-working some of that anyway, so I can always re-name them and do a better job commenting them.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Linting Each Compiled File
« Reply #8 on: October 05, 2006, 09:12:57 PM »
@Lee: Thanks a lot for clarification !
You know - sometimes you think "I got it" but in fact you're miles away !
I didn't want to nag. Next time I should take a closer look at the context before telling wrong things...

HS2