From 33b5970c912ccb9bfa34f9757f0c279a8a5b2128 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 18 Aug 2011 12:13:21 -0500 Subject: [PATCH 1/5] use the qmake config setting HAVE_RULES to enable/disable pcre rules support, defaulting to on except on Windows. --- lib/lib.pri | 11 +++++++++-- tools/dmake.cpp | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/lib.pri b/lib/lib.pri index 95f0ebe2251..9745b30614a 100644 --- a/lib/lib.pri +++ b/lib/lib.pri @@ -1,7 +1,14 @@ # no manual edits - this file is autogenerated by dmake -LIBS += -L../externals -lpcre -INCLUDEPATH += ../externals ../externals/tinyxml +!win32 { + CONFIG += HAVE_RULES +} +HAVE_RULES { + DEFINES += HAVE_RULES + LIBS += -L../externals -lpcre + INCLUDEPATH += ../externals +} +INCLUDEPATH += ../externals/tinyxml HEADERS += $${BASEPATH}check.h \ $${BASEPATH}check64bit.h \ $${BASEPATH}checkassignif.h \ diff --git a/tools/dmake.cpp b/tools/dmake.cpp index 1a162586211..aa4faa4a2d3 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -182,8 +182,15 @@ int main(int argc, char **argv) if (fout1.is_open()) { fout1 << "# no manual edits - this file is autogenerated by dmake\n\n"; - fout1 << "LIBS += -L../externals -lpcre\n"; - fout1 << "INCLUDEPATH += ../externals ../externals/tinyxml\n"; + fout1 << "!win32 {\n"; + fout1 << " CONFIG += HAVE_RULES\n"; + fout1 << "}\n"; + fout1 << "HAVE_RULES {\n"; + fout1 << " DEFINES += HAVE_RULES\n"; + fout1 << " LIBS += -L../externals -lpcre\n"; + fout1 << " INCLUDEPATH += ../externals\n"; + fout1 << "}\n"; + fout1 << "INCLUDEPATH += ../externals/tinyxml\n"; fout1 << "HEADERS += $${BASEPATH}check.h \\\n"; for (unsigned int i = 0; i < libfiles.size(); ++i) { From 6cbcf65339c8e8e5071f43ae4e42010801ecbb36 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 18 Aug 2011 12:13:37 -0500 Subject: [PATCH 2/5] cli pro doesn't force HAVE_RULES anymore. --- cli/cli.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/cli/cli.pro b/cli/cli.pro index 3cd4dae43fe..7003c078e06 100644 --- a/cli/cli.pro +++ b/cli/cli.pro @@ -5,7 +5,6 @@ INCLUDEPATH += . ../lib OBJECTS_DIR = temp CONFIG += warn_on CONFIG -= qt app_bundle -DEFINES += HAVE_RULES BASEPATH = ../externals/tinyxml/ include($$PWD/../externals/tinyxml/tinyxml.pri) From 50b0e95314cfe7e55a59e37cb135bde64064597b Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 18 Aug 2011 15:42:19 -0500 Subject: [PATCH 3/5] put the rules logic in its own .pri file, and allow easier override --- lib/lib.pri | 9 +-------- lib/pcrerules.pri | 18 ++++++++++++++++++ tools/dmake.cpp | 9 +-------- 3 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 lib/pcrerules.pri diff --git a/lib/lib.pri b/lib/lib.pri index 9745b30614a..df37d31ffda 100644 --- a/lib/lib.pri +++ b/lib/lib.pri @@ -1,13 +1,6 @@ # no manual edits - this file is autogenerated by dmake -!win32 { - CONFIG += HAVE_RULES -} -HAVE_RULES { - DEFINES += HAVE_RULES - LIBS += -L../externals -lpcre - INCLUDEPATH += ../externals -} +include($$PWD/pcrerules.pri) INCLUDEPATH += ../externals/tinyxml HEADERS += $${BASEPATH}check.h \ $${BASEPATH}check64bit.h \ diff --git a/lib/pcrerules.pri b/lib/pcrerules.pri new file mode 100644 index 00000000000..9ff84c5befc --- /dev/null +++ b/lib/pcrerules.pri @@ -0,0 +1,18 @@ +# On non-Windows, if the variable HAVE_RULES is empty, default to using PCRE and enabling rules +!win32:isEmpty(HAVE_RULES) { + CONFIG += use_pcre_rules +} + +# If HAVE_RULES=yes is passed to qmake, use PCRE and enable rules +contains(HAVE_RULES, [yY][eE][sS]) { + CONFIG += use_pcre_rules +} + +use_pcre_rules { + DEFINES += HAVE_RULES + LIBS += -L../externals -lpcre + INCLUDEPATH += ../externals + message("Rules enabled - to disable them and remove the dependency on PCRE, pass HAVE_RULES=no to qmake.") +} else { + message("Rules disabled - to enable them, make PCRE available and pass HAVE_RULES=yes to qmake.") +} diff --git a/tools/dmake.cpp b/tools/dmake.cpp index aa4faa4a2d3..7c5428af3d9 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -182,14 +182,7 @@ int main(int argc, char **argv) if (fout1.is_open()) { fout1 << "# no manual edits - this file is autogenerated by dmake\n\n"; - fout1 << "!win32 {\n"; - fout1 << " CONFIG += HAVE_RULES\n"; - fout1 << "}\n"; - fout1 << "HAVE_RULES {\n"; - fout1 << " DEFINES += HAVE_RULES\n"; - fout1 << " LIBS += -L../externals -lpcre\n"; - fout1 << " INCLUDEPATH += ../externals\n"; - fout1 << "}\n"; + fout1 << "include($$PWD/pcrerules.pri)\n"; fout1 << "INCLUDEPATH += ../externals/tinyxml\n"; fout1 << "HEADERS += $${BASEPATH}check.h \\\n"; for (unsigned int i = 0; i < libfiles.size(); ++i) From 4373f0a812be6a7a2f970e7c1187e4112165a486 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 18 Aug 2011 15:58:22 -0500 Subject: [PATCH 4/5] document the updated qmake/rules interaction --- build-pcre.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/build-pcre.txt b/build-pcre.txt index b7ebf7b7724..0b5e0cd2d61 100644 --- a/build-pcre.txt +++ b/build-pcre.txt @@ -1,3 +1,22 @@ +PCRE is a library that is used by the optional "rules" feature. (It adds +some additional features to the command line client.) It's readily available +on Linux and Mac OS X, but must be obtained separately for Windows. + +If you're using qmake to generate makefiles, the following behavior applies: + +- If you're not on Windows, it assumes by default that you have PCRE and want + to enable rules support. + +- If you're not on Windows, you can disable rules support (removing the PCRE + dependency) by passing HAVE_RULES=no to qmake. + +- If you are on Windows, but have PCRE available, you can enable rules support + by passing HAVE_RULES=yes to qmake. + + - Note: This includes using build.bat since it calls qmake - to use PCRE and + build.bat, you need to edit build.bat to add HAVE_RULES=yes to the + qmake call. + Some temporary build instructions. This is work in progress. From ef0ca2b9796432c97abe839524bd26d479ce0b49 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 18 Aug 2011 16:01:39 -0500 Subject: [PATCH 5/5] HAVE_RULES support for build.bat Let the user's setting of the HAVE_RULES environment variable affect build.bat's calls to qmake. --- build-pcre.txt | 3 +-- build.bat | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build-pcre.txt b/build-pcre.txt index 0b5e0cd2d61..28893a92e42 100644 --- a/build-pcre.txt +++ b/build-pcre.txt @@ -14,8 +14,7 @@ If you're using qmake to generate makefiles, the following behavior applies: by passing HAVE_RULES=yes to qmake. - Note: This includes using build.bat since it calls qmake - to use PCRE and - build.bat, you need to edit build.bat to add HAVE_RULES=yes to the - qmake call. + build.bat, you need to run set HAVE_RULES=yes before each run of build.bat Some temporary build instructions. This is work in progress. diff --git a/build.bat b/build.bat index 14e7b5f7856..3833e6dbaa0 100644 --- a/build.bat +++ b/build.bat @@ -7,6 +7,9 @@ REM where is any of cppcheck/gui/tests/all REM release or debug is the configuration REM all-target builds both cppcheck and gui. REM +REM Run the command before build.bat to enable rules using pcre: +REM set HAVE_RULES=yes +REM REM TODO: REM - run tests too @@ -31,7 +34,7 @@ goto help :cppcheck cd cli -qmake -config %TARGET% +qmake -config %TARGET% HAVE_RULES=%HAVE_RULES% %MAKE% cd .. if "%1" == "all" goto gui @@ -39,7 +42,7 @@ goto end :gui cd gui -qmake -config %TARGET% +qmake -config %TARGET% HAVE_RULES=%HAVE_RULES% %MAKE% lrelease gui.pro cd .. @@ -47,7 +50,7 @@ goto end :tests cd test -qmake -config %TARGET% +qmake -config %TARGET% HAVE_RULES=%HAVE_RULES% %MAKE% cd .. goto end