summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/preprocessor.h
Commit message (Collapse)AuthorAgeFilesLines
* moc: Cache header lookups to reduce number of file stat'sThomas Sondergaard2016-11-031-0/+1
| | | | | | | | | | | | | | This improves moc performance on Windows where file-stat'ing is slow and where the number of project include paths to search is often high because project third-party headers are installed in separate directories rather than a shared include path such as /usr/include. In a real project of non-trivial size it reduces the total from-scratch build time of an optimized build using CMake+ninja with 32 cores by 11% from ~11m35s to ~10m15s. Change-Id: Ieed59646927ed75c55ed9efa97600c328b2fed2c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* moc: get the system #defines from the compiler itselfThiago Macieira2016-07-201-0/+1
| | | | | | | | | | | | | | | | | | | | In order for moc to properly parse #ifdefs and family, we've had QMAKE_COMPILER_DEFINES as a list of pre-defined macros from the compiler. That list is woefully incomplete. Instead, let's simply ask the compiler for the list. With GCC and family, we use the -dM flag while preprocessing. With ICC on Windows, the flag gains an extra "Q" but is otherwise the same. For MSVC, it requires using some undocumented switches and parsing environment variables (I've tested MSVC 2012, 2013 and 2015). The new moc option is called --include to be similar to GCC's -include option. It does more than just parse a list of pre-defined macros and can be used to insert any sort of code that moc needs to parse prior to the main file. Change-Id: I7de033f80b0e4431b7f1ffff13fca02dbb60a0a6 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Updated license headersJani Heikkinen2016-01-211-17/+12
| | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* moc: Make toExpand const, we do not modify it.Milian Wolff2015-07-231-1/+1
| | | | | Change-Id: I7036ea7ee9e533670ebed425e6c4a8bb0063f751 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Optimize moc: Remove temporary allocations during macro expansion.Milian Wolff2015-07-131-1/+1
| | | | | | | | | | Previously, a temporary list was allocated and then fed into the bigger list of results. Now, we push data into the final list directly, removing the overhead of the temporary allocation. Change-Id: I9bea0fd3c23b1434b4be2728c60ac22a66908efc Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Use file mapping in moc.Jędrzej Nowacki2014-10-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | The change reduces heap allocations by using file mapping instead of reading a whole file into memory just to create a slightly modified copy of it. For this small test case: moc <<EOF class X : public QObject { Q_OBJECT Q_PROPERTY(int x) }; EOF massif shows improvement from: peak cost: "26,8 KB" heap "2,1 KB" heap extra "0 B" stacks to: peak cost: "11,3 KB" heap "2,2 KB" heap extra "0 B" stacks In general, depending on source file high peak memory usage is reduced from few to few hundreds KB, especially that the allocation used to happen for each include file too. Change-Id: I9c1c848be848444156af25a991b67161fb9d8b29 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* moc: Fix parsing of complex defines defined via command lineOlivier Goffart2014-01-171-0/+2
| | | | | | | | | | | | | | | | | Since now in Qt5 the moc does full macro substitution, it needs to handle the defines passed is command argument, even if they span over multiple tokens, or if they do not have any token. Example: moc '-DCOMPLEX=QVector<int>' '-DEMPTY=' foo.h [ChangeLog][moc] Fixed passing -D of a macro defined to something more complex than a single identifier. Task-number: QTBUG-33668 Change-Id: Ie8131de215f1659a24af4778d52ee40cda19759f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Port moc to QCommandLineParserDavid Faure2013-09-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This required special care because of @option-file where additional args can be read from. Found again one undocumented option, --ignore-option-clashes. Usage: moc [options] [header-file] [@option-file] Qt Meta Object Compiler version 67 (Qt 5.2.0) Options: -h, --help Displays this help. -v, --version Displays version information. -o <file> Write output to file rather than stdout. -I <dir> Add dir to the include path for header files. -F <framework> Add Mac framework to the include path for header fil es. -E Preprocess only; do not generate meta object code. -D <macro[=def]> Define macro, with optional definition. -U <macro> Undefine macro. -i Do not generate an #include statement. -p <path> Path prefix for included file. -f <file> Force #include [optional <file>] (overwrite default) . -b <file> Prepend #include <file> (preserve default include). -n <which> Do not display notes (-nn) or warnings (-nw). Compat ibility option. --no-notes Do not display notes. --no-warnings Do not display warnings (implies --no-notes). --ignore-option-clashes Ignore all options that conflict with compilers, lik e -pthread conflicting with moc's -p option. Arguments: [header-file] Header file to read from, otherwise stdin. [@option-file] Read additional options from option-file. Change-Id: I0dfa8e029f95ad8084832530d701e30f315df98e Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* moc: Fix infinite recursion in macro substitutionOlivier Goffart2013-02-211-1/+2
| | | | | | | | | | | | | | When performing macro argument substitution, one should keep the set of macro to exclude, else we can enter an infinite recursion. Testcase: #define M1(A) A #define M2 M1(M2) Task-number: QTBUG-29759 Change-Id: I564bbfed65e1c8599592eaf12c6d67285d2fd9ce Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Proper macro replacment and branch evaluationLars Knoll2012-11-231-5/+3
| | | | | | | | | | | | Correclty replace macros according to the C++ standard. Use the correct replacement method also to evaluate With this moc correctly processes boost headers. Task-number: QTBUG-27546 Change-Id: I001b3054c5fcdc34d46cfa53d1387bd19436f361 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Moc: Correctly expand macros with argumentsLars Knoll2012-09-251-1/+3
| | | | | | | | | Moc now supports full expansion of macros with arguments with the exception of some keywords such as Q_OBJECT and others that are used internally Change-Id: I283d47152f75de81ec68a3df1f0f2273f11c5149 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Correctly parse function macrosLars Knoll2012-09-251-0/+4
| | | | | | | | Parse function macros and add it's list of arguments to the Macro definition. Change-Id: Id22f5cf4a1c098f7b4f5b72f002900cd40d03e0f Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Correctly expand macros without arguments in mocLars Knoll2012-09-251-0/+1
| | | | | | | | | | | | This helps e.g. cases where a namespace is defined through a macro and moc doesn't see it at all. Expanding macros with arguments is significantly more work, and should happen in a separate commit. Change-Id: Ic8d0443d06fab2ed343115d8c43022f2c67ec3cd Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* make src/tools/ compile without CamelCase headersOswald Buddenhagen2012-09-191-2/+2
| | | | | | | | so the build works with syncqt -minimal Change-Id: Ief5e8eb9a504dd6c84cff76cc3e5257450386a0f Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Search the include paths for json files containing plugin infoLars Knoll2012-07-311-8/+0
| | | | | | | | This fixes shadow builds with autogenerated .json files as e.g. used by Qt Creator. Change-Id: Ibb783b05d97d996100da4b0dca859fa3f310dc83 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Add an overload to Moc to allow reading from a QIODevice.Stephen Kelly2012-03-141-0/+2
| | | | | | | | This allows external code to provide the input data, such as a bootstrapped version of qdbuscpp2xml. Change-Id: I163062efc6495b3ab92573f94523967a67601191 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+102
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12