# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED. # # Module name : cppcheck # Module type : Makefile system # Compiler(s) : ANSI C # Environment(s): Linux cppcheck # # Description: # cppcheck static code analysis support # # Contents: # Generate rules to use cppcheck #............................................................................# use strict; use warnings; use Data::Dumper; ############################################################################### # CppcheckInit() # Runtime initialisation # # Arguments: # none No arguments currently defined # ############################################################################### CppcheckInit(); sub CppcheckInit { ToolsetRules( "cppcheck.rul" ); } ############################################################################### # CppcheckAR( $name, \@args, \@objs ) # This subroutine takes the user options and builds the rules # required to lint the static library 'name'. # # Arguments: # none No arguments currently defined # # Output: # [ $(LIBDIR)/name$_lint: .... ] # $(ARLINT) # ############################################################################### sub CppcheckAR { my ($name, $pArgs, $pObjs, $target, $CSRC, $CXXSRC) = @_; CppcheckBuildRule('AR', $name, $CSRC, $CXXSRC); } ############################################################################### # CppcheckSHLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc ) # # This subroutine takes the user options and builds the rules # required to lint the shared library 'name'. # # Arguments: # (none) # # Output: # [ $(LIBDIR)/$name_lint: .... ] # $(SHLIBLINT) # # $name_shlnt += # $name_shlnt += ... # : # ############################################################################### sub CppcheckSHLD { my ($name, $pArgs, $pObjs, $pLibs, $target, $CSRC, $CXXSRC) = @_; CppcheckBuildRule('SHLD', $name, $CSRC, $CXXSRC); } ############################################################################### # CppcheckLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc ) # # This subroutine takes the user options and builds the rules # required to lint the program 'name'. # # Arguments: # (none) # # Output: # [ $(BINDIR)/$name_lint: .... ] # $(LDLINT) # # $name_ldlnt += # $name_ldlnt += ... # : # ############################################################################### sub CppcheckLD { my ($name, $pArgs, $pObjs, $pLibs, $target, $CSRC, $CXXSRC) = @_; CppcheckBuildRule('LD', $name, $CSRC, $CXXSRC); } ############################################################################### # CppcheckBuildRule( $rule, $name, \@csrc, \@cxxsrc ) # # Build a cppcheck rule for a particular target. # ############################################################################### sub CppcheckBuildRule { my ($rule, $name, $CSRC, $CXXSRC) = @_; my ($io) = ToolsetPrinter::New(); $io->Prt( "\n\t" . '$(echo) Running cppcheck on ' . $name . "... \n"); $io->Prt( "\t" . '$(eval INC := $(foreach dir,$(CPPCHECK_INC),$(if $(wildcard $(dir)),-I$(dir),)))' . "\n"); foreach (@$CSRC) { $io->Prt( "\t" . '$(CPPCHECK_' . $rule . ') $(INC) '. $_ . "\n"); } foreach (@$CXXSRC) { $io->Prt( "\t" . '$(CPPCHECK_' . $rule . ') $(INC) '. $_ . "\n"); } }