Add support for user defined rules
This commit is contained in:
parent
1ece516816
commit
2d3865a671
107
Makefile
107
Makefile
|
@ -86,22 +86,23 @@ TESTOBJ = test/options.o \
|
|||
test/testuninitvar.o \
|
||||
test/testunusedfunctions.o \
|
||||
test/testunusedprivfunc.o \
|
||||
test/testunusedvar.o \
|
||||
test/tinyxml/tinystr.o \
|
||||
test/tinyxml/tinyxml.o \
|
||||
test/tinyxml/tinyxmlerror.o \
|
||||
test/tinyxml/tinyxmlparser.o
|
||||
test/testunusedvar.o
|
||||
|
||||
EXTOBJ = externals/tinyxml/tinystr.o \
|
||||
externals/tinyxml/tinyxml.o \
|
||||
externals/tinyxml/tinyxmlerror.o \
|
||||
externals/tinyxml/tinyxmlparser.o
|
||||
|
||||
|
||||
###### Targets
|
||||
|
||||
cppcheck: $(LIBOBJ) $(CLIOBJ)
|
||||
$(CXX) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(LDFLAGS)
|
||||
cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ)
|
||||
$(CXX) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre $(LDFLAGS)
|
||||
|
||||
all: cppcheck testrunner
|
||||
|
||||
testrunner: $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o
|
||||
$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o $(LDFLAGS)
|
||||
testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o
|
||||
$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o $(LDFLAGS)
|
||||
|
||||
test: all
|
||||
./testrunner
|
||||
|
@ -210,125 +211,113 @@ lib/tokenize.o: lib/tokenize.cpp lib/tokenize.h lib/token.h lib/filelister.h lib
|
|||
$(CXX) $(CXXFLAGS) -Ilib -c -o lib/tokenize.o lib/tokenize.cpp
|
||||
|
||||
cli/cmdlineparser.o: cli/cmdlineparser.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h lib/timer.h cli/cmdlineparser.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -c -o cli/cmdlineparser.o cli/cmdlineparser.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Iexternals -c -o cli/cmdlineparser.o cli/cmdlineparser.cpp
|
||||
|
||||
cli/cppcheckexecutor.o: cli/cppcheckexecutor.cpp cli/cppcheckexecutor.h lib/errorlogger.h lib/settings.h lib/cppcheck.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h cli/threadexecutor.h cli/cmdlineparser.h lib/filelister.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -c -o cli/cppcheckexecutor.o cli/cppcheckexecutor.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Iexternals -c -o cli/cppcheckexecutor.o cli/cppcheckexecutor.cpp
|
||||
|
||||
cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/errorlogger.h lib/settings.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -c -o cli/main.o cli/main.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Iexternals -c -o cli/main.o cli/main.cpp
|
||||
|
||||
cli/threadexecutor.o: cli/threadexecutor.cpp cli/threadexecutor.h lib/settings.h lib/errorlogger.h lib/cppcheck.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -c -o cli/threadexecutor.o cli/threadexecutor.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Iexternals -c -o cli/threadexecutor.o cli/threadexecutor.cpp
|
||||
|
||||
test/options.o: test/options.cpp test/options.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/options.o test/options.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/options.o test/options.cpp
|
||||
|
||||
test/testautovariables.o: test/testautovariables.cpp lib/tokenize.h lib/checkautovariables.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testautovariables.o test/testautovariables.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testautovariables.o test/testautovariables.cpp
|
||||
|
||||
test/testbufferoverrun.o: test/testbufferoverrun.cpp lib/tokenize.h lib/checkbufferoverrun.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h lib/mathlib.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testbufferoverrun.o test/testbufferoverrun.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testbufferoverrun.o test/testbufferoverrun.cpp
|
||||
|
||||
test/testcharvar.o: test/testcharvar.cpp lib/tokenize.h lib/checkother.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testcharvar.o test/testcharvar.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testcharvar.o test/testcharvar.cpp
|
||||
|
||||
test/testclass.o: test/testclass.cpp lib/tokenize.h lib/checkclass.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h lib/symboldatabase.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testclass.o test/testclass.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testclass.o test/testclass.cpp
|
||||
|
||||
test/testcmdlineparser.o: test/testcmdlineparser.cpp test/testsuite.h lib/errorlogger.h test/redirect.h lib/settings.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testcmdlineparser.o test/testcmdlineparser.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testcmdlineparser.o test/testcmdlineparser.cpp
|
||||
|
||||
test/testconstructors.o: test/testconstructors.cpp lib/tokenize.h lib/checkclass.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h lib/symboldatabase.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testconstructors.o test/testconstructors.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testconstructors.o test/testconstructors.cpp
|
||||
|
||||
test/testcppcheck.o: test/testcppcheck.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h test/testsuite.h test/redirect.h lib/path.h test/tinyxml/tinyxml.h test/tinyxml/tinystr.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testcppcheck.o test/testcppcheck.cpp
|
||||
test/testcppcheck.o: test/testcppcheck.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h test/testsuite.h test/redirect.h lib/path.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testcppcheck.o test/testcppcheck.cpp
|
||||
|
||||
test/testdivision.o: test/testdivision.cpp lib/tokenize.h lib/checkother.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testdivision.o test/testdivision.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testdivision.o test/testdivision.cpp
|
||||
|
||||
test/testerrorlogger.o: test/testerrorlogger.cpp test/testsuite.h lib/errorlogger.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testerrorlogger.o test/testerrorlogger.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testerrorlogger.o test/testerrorlogger.cpp
|
||||
|
||||
test/testexceptionsafety.o: test/testexceptionsafety.cpp lib/tokenize.h lib/checkexceptionsafety.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testexceptionsafety.o test/testexceptionsafety.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testexceptionsafety.o test/testexceptionsafety.cpp
|
||||
|
||||
test/testincompletestatement.o: test/testincompletestatement.cpp test/testsuite.h lib/errorlogger.h test/redirect.h lib/tokenize.h lib/checkother.h lib/check.h lib/token.h lib/settings.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testincompletestatement.o test/testincompletestatement.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testincompletestatement.o test/testincompletestatement.cpp
|
||||
|
||||
test/testmathlib.o: test/testmathlib.cpp lib/mathlib.h test/testsuite.h lib/errorlogger.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testmathlib.o test/testmathlib.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testmathlib.o test/testmathlib.cpp
|
||||
|
||||
test/testmemleak.o: test/testmemleak.cpp lib/tokenize.h lib/checkmemoryleak.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h lib/symboldatabase.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testmemleak.o test/testmemleak.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testmemleak.o test/testmemleak.cpp
|
||||
|
||||
test/testnullpointer.o: test/testnullpointer.cpp lib/tokenize.h lib/checknullpointer.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testnullpointer.o test/testnullpointer.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testnullpointer.o test/testnullpointer.cpp
|
||||
|
||||
test/testobsoletefunctions.o: test/testobsoletefunctions.cpp lib/tokenize.h lib/checkobsoletefunctions.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testobsoletefunctions.o test/testobsoletefunctions.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testobsoletefunctions.o test/testobsoletefunctions.cpp
|
||||
|
||||
test/testoptions.o: test/testoptions.cpp test/options.h test/testsuite.h lib/errorlogger.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testoptions.o test/testoptions.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testoptions.o test/testoptions.cpp
|
||||
|
||||
test/testother.o: test/testother.cpp lib/tokenize.h lib/checkother.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testother.o test/testother.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testother.o test/testother.cpp
|
||||
|
||||
test/testpath.o: test/testpath.cpp test/testsuite.h lib/errorlogger.h test/redirect.h lib/path.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testpath.o test/testpath.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testpath.o test/testpath.cpp
|
||||
|
||||
test/testpostfixoperator.o: test/testpostfixoperator.cpp lib/tokenize.h lib/checkpostfixoperator.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testpostfixoperator.o test/testpostfixoperator.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testpostfixoperator.o test/testpostfixoperator.cpp
|
||||
|
||||
test/testpreprocessor.o: test/testpreprocessor.cpp test/testsuite.h lib/errorlogger.h test/redirect.h lib/preprocessor.h lib/tokenize.h lib/token.h lib/settings.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testpreprocessor.o test/testpreprocessor.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testpreprocessor.o test/testpreprocessor.cpp
|
||||
|
||||
test/testrunner.o: test/testrunner.cpp test/testsuite.h lib/errorlogger.h test/redirect.h test/options.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testrunner.o test/testrunner.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testrunner.o test/testrunner.cpp
|
||||
|
||||
test/testsettings.o: test/testsettings.cpp lib/settings.h test/testsuite.h lib/errorlogger.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testsettings.o test/testsettings.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testsettings.o test/testsettings.cpp
|
||||
|
||||
test/testsimplifytokens.o: test/testsimplifytokens.cpp test/testsuite.h lib/errorlogger.h test/redirect.h lib/tokenize.h lib/token.h lib/settings.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testsimplifytokens.o test/testsimplifytokens.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testsimplifytokens.o test/testsimplifytokens.cpp
|
||||
|
||||
test/teststl.o: test/teststl.cpp lib/tokenize.h lib/checkstl.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/teststl.o test/teststl.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/teststl.o test/teststl.cpp
|
||||
|
||||
test/testsuite.o: test/testsuite.cpp test/testsuite.h lib/errorlogger.h test/redirect.h test/options.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testsuite.o test/testsuite.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testsuite.o test/testsuite.cpp
|
||||
|
||||
test/testthreadexecutor.o: test/testthreadexecutor.cpp lib/cppcheck.h lib/settings.h lib/errorlogger.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testthreadexecutor.o test/testthreadexecutor.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testthreadexecutor.o test/testthreadexecutor.cpp
|
||||
|
||||
test/testtoken.o: test/testtoken.cpp test/testsuite.h lib/errorlogger.h test/redirect.h lib/tokenize.h lib/token.h lib/settings.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testtoken.o test/testtoken.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testtoken.o test/testtoken.cpp
|
||||
|
||||
test/testtokenize.o: test/testtokenize.cpp test/testsuite.h lib/errorlogger.h test/redirect.h lib/tokenize.h lib/token.h lib/settings.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testtokenize.o test/testtokenize.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testtokenize.o test/testtokenize.cpp
|
||||
|
||||
test/testuninitvar.o: test/testuninitvar.cpp lib/tokenize.h lib/checkuninitvar.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testuninitvar.o test/testuninitvar.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testuninitvar.o test/testuninitvar.cpp
|
||||
|
||||
test/testunusedfunctions.o: test/testunusedfunctions.cpp lib/tokenize.h test/testsuite.h lib/errorlogger.h test/redirect.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/settings.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testunusedfunctions.o test/testunusedfunctions.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testunusedfunctions.o test/testunusedfunctions.cpp
|
||||
|
||||
test/testunusedprivfunc.o: test/testunusedprivfunc.cpp lib/tokenize.h lib/checkclass.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h lib/symboldatabase.h test/testsuite.h test/redirect.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testunusedprivfunc.o test/testunusedprivfunc.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testunusedprivfunc.o test/testunusedprivfunc.cpp
|
||||
|
||||
test/testunusedvar.o: test/testunusedvar.cpp test/testsuite.h lib/errorlogger.h test/redirect.h lib/tokenize.h lib/checkother.h lib/check.h lib/token.h lib/settings.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testunusedvar.o test/testunusedvar.cpp
|
||||
|
||||
test/tinyxml/tinystr.o: test/tinyxml/tinystr.cpp test/tinyxml/tinystr.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/tinyxml/tinystr.o test/tinyxml/tinystr.cpp
|
||||
|
||||
test/tinyxml/tinyxml.o: test/tinyxml/tinyxml.cpp test/tinyxml/tinyxml.h test/tinyxml/tinystr.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/tinyxml/tinyxml.o test/tinyxml/tinyxml.cpp
|
||||
|
||||
test/tinyxml/tinyxmlerror.o: test/tinyxml/tinyxmlerror.cpp test/tinyxml/tinyxml.h test/tinyxml/tinystr.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/tinyxml/tinyxmlerror.o test/tinyxml/tinyxmlerror.cpp
|
||||
|
||||
test/tinyxml/tinyxmlparser.o: test/tinyxml/tinyxmlparser.cpp test/tinyxml/tinyxml.h test/tinyxml/tinystr.h
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/tinyxml/tinyxmlparser.o test/tinyxml/tinyxmlparser.cpp
|
||||
$(CXX) $(CXXFLAGS) -Ilib -Icli -Iexternals -c -o test/testunusedvar.o test/testunusedvar.cpp
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
Some temporary build instructions. This is work in progress.
|
||||
|
||||
|
||||
The tinyxml and pcre libraries are needed. The tinyxml is not really needed, these
|
||||
files could be integrated into the CLI instead.
|
||||
|
||||
|
||||
Windows
|
||||
|
||||
Visual Studio
|
||||
|
||||
To build pcre I downloaded the sourcecode from www.pcre.org. I downloaded cmake 2.8.
|
||||
Then I built the lib with:
|
||||
cmake .
|
||||
nmake
|
||||
|
||||
To build tinyxml I just built all the files in externals/tinyxml
|
||||
|
||||
|
||||
MINGW (Qt 4.7 SDK)
|
||||
|
||||
I downloaded pcre-8.0-lib.zip from here: http://software-download.name/pcre-library-windows/
|
||||
|
||||
I build libtinyxml.a with:
|
||||
cd externals/tinyxml
|
||||
qmake
|
||||
jom
|
||||
|
||||
|
||||
Linux
|
||||
|
||||
The normal Makefile should work
|
||||
|
||||
Install pcre on ubuntu might be needed:
|
||||
sudo apt-get install libpcre3 libpcre3-dev
|
|
@ -1,18 +1,21 @@
|
|||
TEMPLATE = app
|
||||
TARGET = cppcheck
|
||||
DEPENDPATH += .
|
||||
INCLUDEPATH += . ../lib
|
||||
INCLUDEPATH += . ../lib ../externals
|
||||
OBJECTS_DIR = temp
|
||||
CONFIG += warn_on
|
||||
CONFIG -= qt app_bundle
|
||||
|
||||
include($$PWD/../externals/tinyxml/tinyxml.pri)
|
||||
include($$PWD/../lib/lib.pri)
|
||||
|
||||
SOURCES += main.cpp \
|
||||
cppcheckexecutor.cpp \
|
||||
cmdlineparser.cpp \
|
||||
threadexecutor.cpp
|
||||
HEADERS += cppcheckexecutor.cpp \
|
||||
threadexecutor.cpp
|
||||
HEADERS += cppcheckexecutor.h \
|
||||
cmdlineparser.h \
|
||||
threadexecutor.h
|
||||
|
||||
CONFIG(release, debug|release) {
|
||||
DEFINES += NDEBUG
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "settings.h"
|
||||
#include "cmdlineparser.h"
|
||||
|
||||
// xml is used in rules
|
||||
#include "tinyxml/tinyxml.h"
|
||||
|
||||
static void AddFilesToList(const std::string& FileList, std::vector<std::string>& PathNames)
|
||||
{
|
||||
|
@ -387,6 +389,56 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
_settings->_showtime = SHOWTIME_NONE;
|
||||
}
|
||||
|
||||
// Rules are a debug feature
|
||||
#ifndef NDEBUG
|
||||
// Rule given at command line
|
||||
else if (strncmp(argv[i], "--rule=", 7) == 0)
|
||||
{
|
||||
Settings::Rule rule;
|
||||
rule.pattern = 7 + argv[i];
|
||||
_settings->rules.push_back(rule);
|
||||
}
|
||||
|
||||
// Rule file
|
||||
else if (strncmp(argv[i], "--rule-file=", 12) == 0)
|
||||
{
|
||||
TiXmlDocument doc;
|
||||
if (doc.LoadFile(12+argv[i]))
|
||||
{
|
||||
TiXmlElement *root = doc.FirstChildElement();
|
||||
if (root && root->ValueStr() == "rule")
|
||||
{
|
||||
Settings::Rule rule;
|
||||
|
||||
TiXmlElement *pattern = root->FirstChildElement("pattern");
|
||||
if (pattern)
|
||||
{
|
||||
rule.pattern = pattern->GetText();
|
||||
}
|
||||
|
||||
TiXmlElement *message = root->FirstChildElement("message");
|
||||
if (message)
|
||||
{
|
||||
TiXmlElement *severity = message->FirstChildElement("severity");
|
||||
if (severity)
|
||||
rule.severity = severity->GetText();
|
||||
|
||||
TiXmlElement *id = message->FirstChildElement("id");
|
||||
if (id)
|
||||
rule.id = id->GetText();
|
||||
|
||||
TiXmlElement *summary = message->FirstChildElement("summary");
|
||||
if (summary)
|
||||
rule.summary = summary->GetText();
|
||||
}
|
||||
|
||||
if (!rule.pattern.empty())
|
||||
_settings->rules.push_back(rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Print help
|
||||
else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
HEADERS += $$PWD/tinystr.h $$PWD/tinyxml.h
|
||||
SOURCES += $$PWD/tinystr.cpp $$PWD/tinyxml.cpp $$PWD/tinyxmlerror.cpp $$PWD/tinyxmlparser.cpp
|
|
@ -6,6 +6,7 @@ DEPENDPATH += . \
|
|||
../lib
|
||||
INCLUDEPATH += . \
|
||||
../lib
|
||||
LIBS+=-L../externals
|
||||
|
||||
DESTDIR = .
|
||||
RCC_DIR = temp
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#include <ctime>
|
||||
#include "timer.h"
|
||||
|
||||
#define PCRE_STATIC
|
||||
#include <pcre.h>
|
||||
|
||||
static TimerResults S_timerResults;
|
||||
|
||||
CppCheck::CppCheck(ErrorLogger &errorLogger)
|
||||
|
@ -297,6 +300,76 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
Timer timerSimpleChecks((*it)->name() + "::runSimplifiedChecks", _settings._showtime, &S_timerResults);
|
||||
(*it)->runSimplifiedChecks(&_tokenizer, &_settings, this);
|
||||
}
|
||||
|
||||
// Are there extra rules?
|
||||
if (!_settings.rules.empty())
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
for (const Token *tok = _tokenizer.tokens(); tok; tok = tok->next())
|
||||
ostr << " " << tok->str();
|
||||
const std::string str(ostr.str());
|
||||
for (std::list<Settings::Rule>::const_iterator it = _settings.rules.begin(); it != _settings.rules.end(); ++it)
|
||||
{
|
||||
const Settings::Rule &rule = *it;
|
||||
if (rule.pattern.empty() || rule.id.empty() || rule.severity.empty())
|
||||
continue;
|
||||
|
||||
const char *error = 0;
|
||||
int erroffset = 0;
|
||||
pcre *re = pcre_compile(rule.pattern.c_str(),0,&error,&erroffset,NULL);
|
||||
if (!re && error)
|
||||
{
|
||||
ErrorLogger::ErrorMessage errmsg(std::list<ErrorLogger::ErrorMessage::FileLocation>(),
|
||||
Severity::error,
|
||||
error,
|
||||
"pcre_compile");
|
||||
|
||||
reportErr(errmsg);
|
||||
}
|
||||
if (re)
|
||||
{
|
||||
int pos = 0;
|
||||
int ovector[30];
|
||||
if (0 <= pcre_exec(re, NULL, str.c_str(), str.size(), pos, 0, ovector, 30))
|
||||
{
|
||||
unsigned int pos1 = (unsigned int)ovector[0];
|
||||
unsigned int pos2 = (unsigned int)ovector[1];
|
||||
|
||||
// determine location..
|
||||
ErrorLogger::ErrorMessage::FileLocation loc;
|
||||
loc.setfile(_tokenizer.getFiles()->front());
|
||||
loc.line = 0;
|
||||
|
||||
unsigned int len = 0;
|
||||
for (const Token *tok = _tokenizer.tokens(); tok; tok = tok->next())
|
||||
{
|
||||
len = len + 1 + tok->str().size();
|
||||
if (len > pos1)
|
||||
{
|
||||
loc.setfile(_tokenizer.getFiles()->at(tok->fileIndex()));
|
||||
loc.line = tok->linenr();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const std::list<ErrorLogger::ErrorMessage::FileLocation> callStack(1, loc);
|
||||
|
||||
// Create error message
|
||||
std::string summary;
|
||||
if (rule.summary.empty())
|
||||
summary = "found '" + str.substr(pos1, pos2 - pos1) + "'";
|
||||
else
|
||||
summary = rule.summary;
|
||||
ErrorLogger::ErrorMessage errmsg(callStack, Severity::fromString(rule.severity), summary, rule.id);
|
||||
|
||||
// Report error
|
||||
reportErr(errmsg);
|
||||
}
|
||||
|
||||
pcre_free(re);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Settings CppCheck::settings() const
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# no manual edits - this file is autogenerated by dmake
|
||||
|
||||
LIBS += -L../externals -lpcre
|
||||
HEADERS += $$PWD/check.h \
|
||||
$$PWD/checkautovariables.h \
|
||||
$$PWD/checkbufferoverrun.h \
|
||||
|
|
|
@ -185,6 +185,30 @@ public:
|
|||
* As usual, include guards are not counted.
|
||||
*/
|
||||
bool ifcfg;
|
||||
|
||||
/** Rule */
|
||||
class Rule
|
||||
{
|
||||
public:
|
||||
Rule()
|
||||
{
|
||||
// default id
|
||||
id = "rule";
|
||||
|
||||
// default severity
|
||||
severity = "style";
|
||||
}
|
||||
|
||||
std::string pattern;
|
||||
std::string id;
|
||||
std::string severity;
|
||||
std::string summary;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Extra rules
|
||||
*/
|
||||
std::list<Rule> rules;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -128,6 +128,9 @@ int main(int argc, char **argv)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::vector<std::string> externalfiles;
|
||||
getCppFiles(externalfiles, "externals/");
|
||||
|
||||
|
||||
// QMAKE - lib/lib.pri
|
||||
{
|
||||
|
@ -135,6 +138,7 @@ int main(int argc, char **argv)
|
|||
if (fout1.is_open())
|
||||
{
|
||||
fout1 << "# no manual edits - this file is autogenerated by dmake\n\n";
|
||||
fout1 << "LIBS += -lpcre\n";
|
||||
fout1 << "HEADERS += $$PWD/check.h \\\n";
|
||||
for (unsigned int i = 0; i < libfiles.size(); ++i)
|
||||
{
|
||||
|
@ -215,14 +219,18 @@ int main(int argc, char **argv)
|
|||
for (unsigned int i = 1; i < testfiles.size(); ++i)
|
||||
fout << " \\" << std::endl << std::string(14, ' ') << objfile(testfiles[i]);
|
||||
fout << "\n\n";
|
||||
fout << "EXTOBJ = " << objfile(externalfiles[0]);
|
||||
for (unsigned int i = 1; i < externalfiles.size(); ++i)
|
||||
fout << " \\" << std::endl << std::string(14, ' ') << objfile(externalfiles[i]);
|
||||
fout << "\n\n";
|
||||
|
||||
|
||||
fout << "\n###### Targets\n\n";
|
||||
fout << "cppcheck:\t$(LIBOBJ)\t$(CLIOBJ)\n";
|
||||
fout << "\t$(CXX) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(LDFLAGS)\n\n";
|
||||
fout << "cppcheck:\t$(LIBOBJ)\t$(CLIOBJ)\t$(EXTOBJ)\n";
|
||||
fout << "\t$(CXX) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre $(LDFLAGS)\n\n";
|
||||
fout << "all:\tcppcheck\ttestrunner\n\n";
|
||||
fout << "testrunner:\t$(TESTOBJ)\t$(LIBOBJ)\tcli/threadexecutor.o\tcli/cmdlineparser.o\tcli/cppcheckexecutor.o\n";
|
||||
fout << "\t$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o $(LDFLAGS)\n\n";
|
||||
fout << "testrunner:\t$(TESTOBJ)\t$(LIBOBJ)\t$(EXTOBJ)\tcli/threadexecutor.o\tcli/cmdlineparser.o\tcli/cppcheckexecutor.o\n";
|
||||
fout << "\t$(CXX) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o $(LDFLAGS)\n\n";
|
||||
fout << "test:\tall\n";
|
||||
fout << "\t./testrunner\n\n";
|
||||
fout << "check:\tall\n";
|
||||
|
@ -247,8 +255,8 @@ int main(int argc, char **argv)
|
|||
fout << "\n###### Build\n\n";
|
||||
|
||||
compilefiles(fout, libfiles, "-Ilib");
|
||||
compilefiles(fout, clifiles, "-Ilib");
|
||||
compilefiles(fout, testfiles, "-Ilib -Icli");
|
||||
compilefiles(fout, clifiles, "-Ilib -Iexternals");
|
||||
compilefiles(fout, testfiles, "-Ilib -Icli -Iexternals");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue