| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ env: | |||
| 13 | 13 | - CPPCHECK=${TRAVIS_BUILD_DIR}/cppcheck | |
| 14 | 14 | matrix: | |
| 15 | 15 | - CXXFLAGS="${CXXFLAGS} -DCHECK_INTERNAL" | |
| 16 | - - CXXFLAGS="${CXXFLAGS} -DCHECK_INTERNAL" MAKEFLAGS="HAVE_RULES=yes" SRCDIR=build VERIFY=1 | ||
| 16 | + - CXXFLAGS="${CXXFLAGS} -DCHECK_INTERNAL" MAKEFLAGS="HAVE_RULES=yes" MATCHCOMPILER=yes VERIFY=1 | ||
| 17 | 17 | ||
| 18 | 18 | before_install: | |
| 19 | 19 | # install needed deps | |
@@ -67,8 +67,8 @@ matrix: | |||
| 67 | 67 | - git clean -dfx | |
| 68 | 68 | # check what happens if we want to install it to some other dir, | |
| 69 | 69 | - echo $CXXFLAGS | |
| 70 | - - make -s SRCDIR=build CFGDIR=/usr/share/cppcheck/cfg -j 2 | ||
| 71 | - - sudo make SRCDIR=build CFGDIR=/usr/share/cppcheck/cfg install | ||
| 70 | + - make -s MATCHCOMPILER=yes CFGDIR=/usr/share/cppcheck/cfg -j 2 | ||
| 71 | + - sudo make MATCHCOMPILER=yes CFGDIR=/usr/share/cppcheck/cfg install | ||
| 72 | 72 | - sudo mkdir -p /usr/share/cppcheck/cfg | |
| 73 | 73 | - sudo install -D ./cfg/* -t /usr/share/cppcheck/cfg | |
| 74 | 74 | # check if it actually works: | |
@@ -133,7 +133,7 @@ matrix: | |||
| 133 | 133 | - name: "check clang sources with cppcheck" | |
| 134 | 134 | compiler: clang | |
| 135 | 135 | script: | |
| 136 | - - wget "https://github.com/llvm-mirror/clang/archive/a1f8bd3778cc5a53236a53500c6ab184e945eefa.zip" & SRCDIR=build VERIFY=1 make -j 2 & wait | ||
| 136 | + - wget "https://github.com/llvm-mirror/clang/archive/a1f8bd3778cc5a53236a53500c6ab184e945eefa.zip" & MATCHCOMPILER=yes VERIFY=1 make -j 2 & wait | ||
| 137 | 137 | - unzip a1f8bd3778cc5a53236a53500c6ab184e945eefa.zip > /dev/null | |
| 138 | 138 | - touch /tmp/clang.cppcheck | |
| 139 | 139 | - cd ./clang-a1f8bd3778cc5a53236a53500c6ab184e945eefa | |
@@ -146,7 +146,7 @@ matrix: | |||
| 146 | 146 | - name: "check llvm sources with cppcheck" | |
| 147 | 147 | compiler: clang | |
| 148 | 148 | script: | |
| 149 | - - wget "https://github.com/llvm-mirror/llvm/archive/6fa6453210fa34c1c28bd73a431d04734549f0d6.zip" & SRCDIR=build VERIFY=1 make -j 2 & wait | ||
| 149 | + - wget "https://github.com/llvm-mirror/llvm/archive/6fa6453210fa34c1c28bd73a431d04734549f0d6.zip" & MATCHCOMPILER=yes VERIFY=1 make -j 2 & wait | ||
| 150 | 150 | - unzip 6fa6453210fa34c1c28bd73a431d04734549f0d6.zip > /dev/null | |
| 151 | 151 | - touch /tmp/llvm.cppcheck | |
| 152 | 152 | - cd ./llvm-6fa6453210fa34c1c28bd73a431d04734549f0d6 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,18 +69,18 @@ make | |||
| 69 | 69 | The recommended release build is: | |
| 70 | 70 | ||
| 71 | 71 | ```shell | |
| 72 | - make SRCDIR=build CFGDIR=cfg HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function" | ||
| 72 | + make MATCHCOMPILER=yes CFGDIR=cfg HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function" | ||
| 73 | 73 | ``` | |
| 74 | 74 | ||
| 75 | 75 | Flags: | |
| 76 | 76 | ||
| 77 | - 1. `SRCDIR=build` | ||
| 78 | - Python is used to optimise cppcheck | ||
| 77 | + 1. `MATCHCOMPILER=yes` | ||
| 78 | + Python is used to optimise cppcheck. The Token::Match patterns are converted into C++ code at compile time. | ||
| 79 | 79 | ||
| 80 | - 2. `CFGDIR=cfg` | ||
| 80 | + 2. `CFGDIR=cfg` | ||
| 81 | 81 | Specify folder where .cfg files are found | |
| 82 | 82 | ||
| 83 | - 3. `HAVE_RULES=yes` | ||
| 83 | + 3. `HAVE_RULES=yes` | ||
| 84 | 84 | Enable rules (PCRE is required if this is used) | |
| 85 | 85 | ||
| 86 | 86 | 4. `CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function"` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,12 +58,12 @@ Compiling | |||
| 58 | 58 | make | |
| 59 | 59 | ||
| 60 | 60 | The recommended release build is: | |
| 61 | - make SRCDIR=build CFGDIR=cfg HAVE_RULES=yes | ||
| 61 | + make MATCHCOMPILER=yes CFGDIR=cfg HAVE_RULES=yes | ||
| 62 | 62 | ||
| 63 | 63 | Flags: | |
| 64 | - SRCDIR=build : Python is used to optimise cppcheck | ||
| 65 | - CFGDIR=cfg : Specify folder where .cfg files are found | ||
| 66 | - HAVE_RULES=yes : Enable rules (pcre is required if this is used) | ||
| 64 | + MATCHCOMPILER=yes : Python is used to optimise cppcheck at compile time | ||
| 65 | + CFGDIR=cfg : Specify folder where .cfg files are found | ||
| 66 | + HAVE_RULES=yes : Enable rules (pcre is required if this is used) | ||
| 67 | 67 | ||
| 68 | 68 | g++ (for experts) | |
| 69 | 69 | ================= | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ | |||
| 31 | 31 | static std::string builddir(std::string filename) | |
| 32 | 32 | { | |
| 33 | 33 | if (filename.compare(0,4,"lib/") == 0) | |
| 34 | - filename = "$(SRCDIR)" + filename.substr(3); | ||
| 34 | + filename = "$(libcppdir)" + filename.substr(3); | ||
| 35 | 35 | return filename; | |
| 36 | 36 | } | |
| 37 | 37 | ||
@@ -200,15 +200,21 @@ int main(int argc, char **argv) | |||
| 200 | 200 | fout << "# To compile with rules, use 'make HAVE_RULES=yes'\n"; | |
| 201 | 201 | makeConditionalVariable(fout, "HAVE_RULES", "no"); | |
| 202 | 202 | ||
| 203 | - // compiled patterns.. | ||
| 204 | - fout << "# folder where lib/*.cpp files are located\n"; | ||
| 205 | - makeConditionalVariable(fout, "SRCDIR", "lib"); | ||
| 203 | + // use match compiler.. | ||
| 204 | + fout << "# use match compiler\n"; | ||
| 206 | 205 | fout << "ifeq ($(SRCDIR),build)\n" | |
| 206 | + << " $(warning Usage of SRCDIR to acticate match compiler is deprecated. Use MATCHCOMPILER=yes instead.)\n" | ||
| 207 | + << " MATCHCOMPILER:=yes\n" | ||
| 208 | + << "endif\n"; | ||
| 209 | + fout << "ifeq ($(MATCHCOMPILER),yes)\n" | ||
| 207 | 210 | << " ifdef VERIFY\n" | |
| 208 | 211 | << " matchcompiler_S := $(shell python tools/matchcompiler.py --verify)\n" | |
| 209 | 212 | << " else\n" | |
| 210 | 213 | << " matchcompiler_S := $(shell python tools/matchcompiler.py)\n" | |
| 211 | 214 | << " endif\n" | |
| 215 | + << " libcppdir:=build\n" | ||
| 216 | + << "else\n" | ||
| 217 | + << " libcppdir:=lib\n" | ||
| 212 | 218 | << "endif\n\n"; | |
| 213 | 219 | ||
| 214 | 220 | // explicit cfg dir.. | |
@@ -376,7 +382,7 @@ int main(int argc, char **argv) | |||
| 376 | 382 | fout << "\t./testrunner -q\n\n"; | |
| 377 | 383 | fout << "checkcfg:\tcppcheck validateCFG\n"; | |
| 378 | 384 | fout << "\t./test/cfg/runtests.sh\n\n"; | |
| 379 | - fout << "dmake:\ttools/dmake.o cli/filelister.o $(SRCDIR)/pathmatch.o $(SRCDIR)/path.o externals/simplecpp/simplecpp.o\n"; | ||
| 385 | + fout << "dmake:\ttools/dmake.o cli/filelister.o $(libcppdir)/pathmatch.o $(libcppdir)/path.o externals/simplecpp/simplecpp.o\n"; | ||
| 380 | 386 | fout << "\t$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)\n\n"; | |
| 381 | 387 | fout << "run-dmake: dmake\n"; | |
| 382 | 388 | fout << "\t./dmake\n\n"; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,7 +78,7 @@ def compile_version(workPath, jobs, version): | |||
| 78 | 78 | os.chdir(workPath + '/cppcheck') | |
| 79 | 79 | subprocess.call(['git', 'checkout', version]) | |
| 80 | 80 | subprocess.call(['make', 'clean']) | |
| 81 | - subprocess.call(['make', jobs, 'SRCDIR=build', 'CXXFLAGS=-O2 -g']) | ||
| 81 | + subprocess.call(['make', jobs, 'MATCHCOMPILER=yes', 'CXXFLAGS=-O2 -g']) | ||
| 82 | 82 | if os.path.isfile(workPath + '/cppcheck/cppcheck'): | |
| 83 | 83 | os.mkdir(workpath + '/' + version) | |
| 84 | 84 | destPath = workpath + '/' + version + '/' | |
@@ -96,7 +96,7 @@ def compile(cppcheckPath, jobs): | |||
| 96 | 96 | print('Compiling Cppcheck..') | |
| 97 | 97 | try: | |
| 98 | 98 | os.chdir(cppcheckPath) | |
| 99 | - subprocess.call(['make', jobs, 'SRCDIR=build', 'CXXFLAGS=-O2 -g']) | ||
| 99 | + subprocess.call(['make', jobs, 'MATCHCOMPILER=yes', 'CXXFLAGS=-O2 -g']) | ||
| 100 | 100 | subprocess.call([cppcheckPath + '/cppcheck', '--version']) | |
| 101 | 101 | except OSError: | |
| 102 | 102 | return False | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ | |||
| 5 | 5 | The matchcompiler.py is a build script that performs a few code transformations to *.cpp* files under the *lib* directory. These transformations are related to the use of `Token::Match()` function and are intended to improve code performance. The transformed files are saved on the *build* directory. This tool is silently used when building the code with `SRCDIR=build`, that is: | |
| 6 | 6 | ```shell | |
| 7 | 7 | $ cd path/to/cppcheck | |
| 8 | - $ make SRCDIR=build | ||
| 8 | + $ make MATCHCOMPILER=yes | ||
| 9 | 9 | ``` | |
| 10 | 10 | Here is a simple example of the *matchcompiler.py* optimization. Suppose there is a file *example.cpp* under *lib/*: | |
| 11 | 11 | ```cpp | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ git reset --hard HEAD > times.log | |||
| 18 | 18 | for i in $(seq 1 50); do | |
| 19 | 19 | git_head=$(git log -1 --format=%h) | |
| 20 | 20 | # if build fails, make clean and try again | |
| 21 | - make SRCDIR=build CXXFLAGS=-O2 -j4 || make clean ; make SRCDIR=build CXXFLAGS=-O2 -j4 | ||
| 21 | + make SRCDIR=build CXXFLAGS=-O2 -j4 || make clean ; make MATCHCOMPILER=yes CXXFLAGS=-O2 -j4 | ||
| 22 | 22 | echo "Run number $i" | |
| 23 | 23 | for j in $(seq 1 ${iterations}); do | |
| 24 | 24 | ./cppcheck --quiet --showtime=summary --enable=all --inconclusive src 2> /dev/null | tee -a times.log | |
| Back | FazBrowse Home | New Git URL |
0 commit comments