Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Adding LINT or other static analysis tools to the build process...: (13 Items)
   
Adding LINT or other static analysis tools to the build process...  
Does anyone have any experience integrating LINT (or any other static analysis tool) into the build process within 
Momentics? We've traditionally used LINT on our code, and I'd like to be able to make analysis part of the build process
, but I'm striking out as far as ideas go...

Thanks,

Mike
Re: Adding LINT or other static analysis tools to the build proce ss...  
If make does not build tools that used in the build process itself; 
usually it works to override CC macro (CCPREF for qnx makefiles) with 
static analysis tool compiler like
make CCPREF=lint
and run this build before regular build.
but it depends on how lint can work with command line options passed to it



Attachment: Text elaskavaia.vcf 94 bytes
Re: Adding LINT or other static analysis tools to the build process...  
I too would like to integrate pc-lint into my build process. Does anybody have any suggestions on how to do this?

TIA

Stephen
Re: Adding LINT or other static analysis tools to the build process...  
Our internal static analysis setup uses a set of pattern targets something along the lines of:

    .PHONY: lint-xml
    lint-xml: $(lint-xml)
    $(lint-xml): %.lob.xml: %.c ; $(run-lint) $@ $<

The real thing is considerably more complicated than that, owing to our own various internal requirements and processes,
 but that is the essence of it.

If you want to do the checking in parallel with the compiles, then you'll probably need something which sets CCPOST to 
get the effect you want.  (The next release of Momentics will probably include predefined "hook" variables to make this 
simpler.)
Re: Adding LINT or other static analysis tools to the build process...  
I don't actually understand what to do with CCPOST. From the description it sounds the sort of thing I need.

I tried to update the all: target to do my lint check but the CCFLAGS macro was empty and didn't contain my include file
 paths that I needed for lint.

Stephen
Re: Adding LINT or other static analysis tools to the build process...  
I usually suggest avoiding doing the lint pass as an adjunct to the compile unless there is some very compelling reason 
to do so.  Usually the effect that is desired by the developer is ensuring that the lint check occurs whenever the 
source changes, "just like for the object file".  The downside in this case is that full dependency checking isn't done 
by default by the QNX build system anyway, so you're probably not linting as thoroughly as you might ideally like.  If 
your static analysis tool(s) generate some sort of output file - even just redirected stdout - you can easily set up 
your own rules independent of (most of) the internal guts of the build system.

CCPOST is intended for "C Compilation Post-Processing" and is simply expanded at the end of the compiler command line.  
This could be leveraged something along the lines of:

    CCPOST = && $(do-lint) $<

to run a lint check for each successful compile.
Re: Adding LINT or other static analysis tools to the build process...  
Thanks, I'll get to work on this.
Stephen
Re: Adding LINT or other static analysis tools to the build process...  
Post again if you have any questions and I'll do my best to help.  Let me know if any of the utilities (gcc2lnt etc.) 
would be of any use - at some point I'll try to get them up on the Foundry.
Re: Adding LINT or other static analysis tools to the build process...  
Hi,

could you share the utils. I seem to understand what these do, but it would be better to reuse those than device a 
script to do the same things.
Thanks
Ashwin
Re: Adding LINT or other static analysis tools to the build process...  
I've been hoping to get permission to get this published to Foundry27,
but that isn't going to happen before next Tuesday, at the very
earliest.  Various impediments, both legal and technical, prevent me
from just publishing the lot, unfortunately.

Was there some bit (or bits) in particular that you're interested in?  I
can post certain parts here; not as good as SVN access but better than
nothing (I hope ;-)

On Wed, 2009-08-05 at 05:19 -0400, Ashwin Patwekar wrote:
> Hi,
> 
> could you share the utils. I seem to understand what these do, but it would be better to reuse those than device a 
script to do the same things.
> Thanks
> Ashwin
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post35229
> 
Re: Adding LINT or other static analysis tools to the build process...  
using make -n and the qlint.mk we understand gcc2lnt creates 2 files 
1.  file which is a list of include directories for that module/file. These files might be having appropriate -i 
prefixed to the list of directory name
2. A file with #defines for the env and module based on the command line passed -D options..
these files are then checked for any changes and appropriate lint or lint delta command seems to be used.

In addition to the defines collected from GCC I had to define QNX_SOURCE to get past the error "POSIX Threads needs 
P1003.1b-1993 or later".This might be defined in kernel lint files though did not check it.

I was able to manually do this and get a lint result. The lint output is big enough to keep us occupied for a couple of 
days. We will wait till these are made public.

Thanks,
Ashwin 



Re: Adding LINT or other static analysis tools to the build process...  
On Thu, 2009-08-06 at 03:05 -0400, Ashwin Patwekar wrote:
> using make -n and the qlint.mk we understand gcc2lnt creates 2 files 
> 1.  file which is a list of include directories for that module/file. These files might be having appropriate -i 
prefixed to the list of directory name
> 2. A file with #defines for the env and module based on the command line passed -D options..
> these files are then checked for any changes and appropriate lint or lint delta command seems to be used.
> 

You're absolutely correct about these.  I've attached our gcc2lnt (and
the publicly available mkinstalldirs and move-if-change) for your
convenience.  (Note too that a fair bit of the setup for the toolchain
is contained in *.lnt and *.h files which I don't have permission to
post yet.)  The usual disclaimers apply: these tools are not
"officially" supported and there is no warranty.  That being said, I'll
help out where I can.  I'm still working on getting clearance for other
portions.

Regards,
Neil

Attachment: Text gcc2lnt 1.58 KB Text mkinstalldirs 3.41 KB Text move-if-change 880 bytes
Re: Adding LINT or other static analysis tools to the build process...  
I've attached the makefile which we use internally for linting.  There's probably way more stuff in there than you'll 
need, but hopefully it'll give you some ideas.

[The usual disclaimers apply: this is unsupported software; no warranty; trademarks belong to their registered holders; 
no endorsement by QNX of any third party should be inferred; yada yada.]
Attachment: Text qlint.mk 17.14 KB