| 6177 |
dpurdie |
1 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 4733 |
dpurdie |
2 |
#
|
|
|
3 |
# Module name : cppcheck
|
|
|
4 |
# Module type : Makefile system
|
|
|
5 |
# Compiler(s) : ANSI C
|
|
|
6 |
# Environment(s): Linux cppcheck
|
|
|
7 |
#
|
|
|
8 |
# Description:
|
|
|
9 |
# cppcheck static code analysis support
|
|
|
10 |
#
|
|
|
11 |
# Contents:
|
|
|
12 |
# Generate rules to use cppcheck
|
|
|
13 |
#............................................................................#
|
|
|
14 |
|
|
|
15 |
use strict;
|
|
|
16 |
use warnings;
|
|
|
17 |
use Data::Dumper;
|
|
|
18 |
|
|
|
19 |
###############################################################################
|
|
|
20 |
# CppcheckInit()
|
|
|
21 |
# Runtime initialisation
|
|
|
22 |
#
|
|
|
23 |
# Arguments:
|
|
|
24 |
# none No arguments currently defined
|
|
|
25 |
#
|
|
|
26 |
###############################################################################
|
|
|
27 |
|
|
|
28 |
CppcheckInit();
|
|
|
29 |
|
|
|
30 |
sub CppcheckInit
|
|
|
31 |
{
|
|
|
32 |
ToolsetRules( "cppcheck.rul" );
|
|
|
33 |
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
###############################################################################
|
|
|
38 |
# CppcheckAR( $name, \@args, \@objs )
|
|
|
39 |
# This subroutine takes the user options and builds the rules
|
|
|
40 |
# required to lint the static library 'name'.
|
|
|
41 |
#
|
|
|
42 |
# Arguments:
|
|
|
43 |
# none No arguments currently defined
|
|
|
44 |
#
|
|
|
45 |
# Output:
|
|
|
46 |
# [ $(LIBDIR)/name$_lint: .... ]
|
|
|
47 |
# $(ARLINT)
|
|
|
48 |
#
|
|
|
49 |
###############################################################################
|
|
|
50 |
sub CppcheckAR
|
|
|
51 |
{
|
|
|
52 |
my ($name, $pArgs, $pObjs, $target, $CSRC, $CXXSRC) = @_;
|
|
|
53 |
CppcheckBuildRule('AR', $name, $CSRC, $CXXSRC);
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
###############################################################################
|
|
|
58 |
# CppcheckSHLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
|
|
|
59 |
#
|
|
|
60 |
# This subroutine takes the user options and builds the rules
|
|
|
61 |
# required to lint the shared library 'name'.
|
|
|
62 |
#
|
|
|
63 |
# Arguments:
|
|
|
64 |
# (none)
|
|
|
65 |
#
|
|
|
66 |
# Output:
|
|
|
67 |
# [ $(LIBDIR)/$name_lint: .... ]
|
|
|
68 |
# $(SHLIBLINT)
|
|
|
69 |
#
|
|
|
70 |
# $name_shlnt +=
|
|
|
71 |
# $name_shlnt += ...
|
|
|
72 |
# :
|
|
|
73 |
#
|
|
|
74 |
###############################################################################
|
|
|
75 |
|
|
|
76 |
sub CppcheckSHLD
|
|
|
77 |
{
|
|
|
78 |
my ($name, $pArgs, $pObjs, $pLibs, $target, $CSRC, $CXXSRC) = @_;
|
|
|
79 |
CppcheckBuildRule('SHLD', $name, $CSRC, $CXXSRC);
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
###############################################################################
|
|
|
83 |
# CppcheckLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
|
|
|
84 |
#
|
|
|
85 |
# This subroutine takes the user options and builds the rules
|
|
|
86 |
# required to lint the program 'name'.
|
|
|
87 |
#
|
|
|
88 |
# Arguments:
|
|
|
89 |
# (none)
|
|
|
90 |
#
|
|
|
91 |
# Output:
|
|
|
92 |
# [ $(BINDIR)/$name_lint: .... ]
|
|
|
93 |
# $(LDLINT)
|
|
|
94 |
#
|
|
|
95 |
# $name_ldlnt +=
|
|
|
96 |
# $name_ldlnt += ...
|
|
|
97 |
# :
|
|
|
98 |
#
|
|
|
99 |
###############################################################################
|
|
|
100 |
|
|
|
101 |
sub CppcheckLD
|
|
|
102 |
{
|
|
|
103 |
my ($name, $pArgs, $pObjs, $pLibs, $target, $CSRC, $CXXSRC) = @_;
|
|
|
104 |
CppcheckBuildRule('LD', $name, $CSRC, $CXXSRC);
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
###############################################################################
|
|
|
108 |
# CppcheckBuildRule( $rule, $name, \@csrc, \@cxxsrc )
|
|
|
109 |
#
|
|
|
110 |
# Build a cppcheck rule for a particular target.
|
|
|
111 |
#
|
|
|
112 |
###############################################################################
|
|
|
113 |
sub CppcheckBuildRule
|
|
|
114 |
{
|
|
|
115 |
my ($rule, $name, $CSRC, $CXXSRC) = @_;
|
|
|
116 |
my ($io) = ToolsetPrinter::New();
|
|
|
117 |
|
|
|
118 |
$io->Prt( "\n\t" . '$(echo) Running cppcheck on ' . $name . "... \n");
|
|
|
119 |
$io->Prt( "\t" . '$(eval INC := $(foreach dir,$(CPPCHECK_INC),$(if $(wildcard $(dir)),-I$(dir),)))' . "\n");
|
|
|
120 |
foreach (@$CSRC)
|
|
|
121 |
{
|
|
|
122 |
$io->Prt( "\t" . '$(CPPCHECK_' . $rule . ') $(INC) '. $_ . "\n");
|
|
|
123 |
}
|
|
|
124 |
foreach (@$CXXSRC)
|
|
|
125 |
{
|
|
|
126 |
$io->Prt( "\t" . '$(CPPCHECK_' . $rule . ') $(INC) '. $_ . "\n");
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
|