diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-12-22 13:12:02 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-04-17 00:54:45 +0000 |
commit | 6668f5becfb8fcb6d10e42495c6ea5cdba2d15c5 (patch) | |
tree | ec4eed8728f21dbbf94c45ea3a7907345962946b /mkspecs/features | |
parent | 964ccc58534aac436529007000d1c38d76c88834 (diff) |
Implement a more direct headersclean check
Test each include file directly, instead of doing a large #include. This
verifies that each header is compilable on its own. One big advantage of
doing it via a special compiler in qmake is that we skip pre-compiled
headers, which has hidden build errors in the past.
This solution is implemented by making syncqt produce a second list of
headers. This list is the same as the list of headers in the source
code to be installed, minus the headers that declare themselves to be
unclean, via the pragma:
#pragma qt_sync_skip_header_check
This mechanism is applied only for public libraries (skipping
QtPlatformSupport, an internal_module).
This test is enabled only for -developer-builds of Qt because it
increases the compilation time.
On QtTest: the library only links to QtCore, but it has two headers that
provide inline-only functionality by including QtGui and QtWidgets
headers (namely, qtest_gui.h and qtest_widget.h). If those two modules
aren't getting compiled due to -no-gui or -no-widgets to configure, we
need to remove the respective headers from the list of headers to be
checked. If they are being built, then we need to make QtTest's build
wait for the headers to be generated and that happens when qmake is
first run inside the src/gui and src/widgets directories.
Change-Id: I57d64bd697a92367c8464c073a42e4d142a9a15f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'mkspecs/features')
-rw-r--r-- | mkspecs/features/data/dummy.cpp | 2 | ||||
-rw-r--r-- | mkspecs/features/qt_module.prf | 10 | ||||
-rw-r--r-- | mkspecs/features/qt_module_headers.prf | 86 |
3 files changed, 93 insertions, 5 deletions
diff --git a/mkspecs/features/data/dummy.cpp b/mkspecs/features/data/dummy.cpp new file mode 100644 index 0000000000..6bda7320e9 --- /dev/null +++ b/mkspecs/features/data/dummy.cpp @@ -0,0 +1,2 @@ +// Used when we need to compile with no source code +// (controls are in the command-line) diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index b85dbfb9c3..7ed5ea0561 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -60,10 +60,6 @@ MODULE_DEFINES = $$MODULE_DEFINE $$MODULE_DEFINES load(qt_module_pris) -INCLUDEPATH *= $$eval(QT.$${MODULE}.includes) $$eval(QT.$${MODULE}_private.includes) - -!no_module_headers: load(qt_module_headers) - #other TEMPLATE = lib DESTDIR = $$eval(QT.$${MODULE_ID}.libs) @@ -73,6 +69,11 @@ CONFIG += qmake_cache target_qt QMAKE_DOCS_TARGETDIR = qt$${MODULE} +load(qt_common) + +!no_module_headers: load(qt_module_headers) +INCLUDEPATH *= $$eval(QT.$${MODULE}.includes) $$eval(QT.$${MODULE}_private.includes) + # If Qt was configured with -debug-and-release then build the module the same way # - unless this is a host library !host_build:if(win32|mac):!macx-xcode { @@ -175,7 +176,6 @@ android: CONFIG += qt_android_deps load(qt_installs) load(qt_targets) -load(qt_common) # this builds on top of qt_common unix|mingw { diff --git a/mkspecs/features/qt_module_headers.prf b/mkspecs/features/qt_module_headers.prf index fc3ec75e82..ed76e67baa 100644 --- a/mkspecs/features/qt_module_headers.prf +++ b/mkspecs/features/qt_module_headers.prf @@ -76,3 +76,89 @@ SYNCQT.HEADER_FILES += $$MODULE_MASTER_DEPS_HEADER } CONFIG += qt_install_headers + +headersclean:!internal_module { + # Make sure that the header compiles with our strict options + hcleanDEFS = -DQT_NO_CAST_TO_ASCII=1 \ + -DQT_NO_CAST_FROM_ASCII=1 \ + -DQT_STRICT_ITERATORS \ + -DQT_NO_URL_CAST_FROM_STRING=1 \ + -DQT_NO_CAST_FROM_BYTEARRAY=1 \ + -DQT_NO_KEYWORDS=1 \ + -DQT_USE_FAST_CONCATENATION \ + -DQT_USE_FAST_OPERATOR_PLUS \ + -Dsignals=int \ + -Dslots=int \ + -Demit=public: \ + -Dforeach=public: \ + -Dforever=public: + + gcc { + # Turn on some extra warnings not found in -Wall -Wextra. + # Common to GCC, Clang and ICC (and other compilers that masquerade as GCC): + hcleanFLAGS = -Wall -Wextra -Werror \ + -Woverloaded-virtual -Wshadow -Wundef \ + -Wnon-virtual-dtor -Wpointer-arith -Wformat-security \ + -Wno-long-long -Wno-variadic-macros -pedantic-errors + + intel_icc { + # these warnings are disabled because explicit constructors with zero or + # multiple arguments are permitted in C++11: + # 2304: non-explicit constructor with single argument may cause implicit type conversion + # 2305: declaration of 'explicit' constructor without a single argument is redundant + hcleanFLAGS += -wd2304,2305 + greaterThan(QT_ICC_MAJOR_VERSION, 13) { + # ICC 14+ has a bug with -Wshadow, emitting it for cases where there's no shadowing + # (issue ID 0000698329, task DPD200245740) + hcleanFLAGS -= -Wshadow + } + } else { + hcleanFLAGS += -Wchar-subscripts + + !contains(QT_ARCH, arm):!contains(QT_ARCH, mips): \ + hcleanFLAGS += -Wcast-align + } + + # Use strict mode C++11 or C++98, with no GNU extensions (see -pedantic-errors above). + # The module might set CONFIG += c++11, but it might also change QMAKE_CXXFLAGS_CXX11 + # or the module (or the mkspec) can set the C++11 flag on QMAKE_CXXFLAGS + # (or QMAKE_CXXFLAGS_{RELEASE,DEBUG} but that's unlikely). + c++11:contains(QMAKE_CXXFLAGS_CXX11, -std=gnu++11) { + hcleanFLAGS += -std=c++11 + } else: contains(QMAKE_CXXFLAGS, -std=gnu++11) { + hcleanFLAGS += -std=c++11 + } else: c++11:contains(QMAKE_CXXFLAGS_CXX11, -std=gnu++0x) { + hcleanFLAGS += -std=c++0x + } else: contains(QMAKE_CXXFLAGS, -std=gnu++0x) { + hcleanFLAGS += -std=c++0x + } else: !c++11:!contains(QMAKE_CXXFLAGS, -std=c++0x):!contains(QMAKE_CXXFLAGS, -std=c++11) { + hcleanFLAGS += -std=c++98 + } + + hcleanCOMMAND = $$QMAKE_CXX -c $(CXXFLAGS) $$hcleanFLAGS $(INCPATH) $$hcleanDEFS -xc++ ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} + } else: win32-msvc2013 { + # 4180: qualifier applied to function type has no meaning; ignored + # 4458: declaration of 'identifier' hides class member + # -Za enables strict standards behavior, but we can't add it because + # <windows.h> and <GL.h> violate the standards. + hcleanFLAGS = -WX -W3 -wd4180 -wd4458 + hcleanCOMMAND = $$QMAKE_CXX -c $(CXXFLAGS) $$hcleanFLAGS $(INCPATH) $$hcleanDEFS -FI${QMAKE_FILE_IN} -Fo${QMAKE_FILE_OUT} \ + $$[QT_INSTALL_DATA/src]/mkspecs/features/data/dummy.cpp + } + + !isEmpty(hcleanCOMMAND):if(!contains(QT_CONFIG, debug_and_release)|CONFIG(release, debug|release)) { + header_check.dependency_type = TYPE_C + header_check.CONFIG += no_link + header_check.output = ${QMAKE_VAR_OBJECTS_DIR}header_${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)} + header_check.input = SYNCQT.CLEAN_HEADER_FILES + header_check.variable_out = PRE_TARGETDEPS + header_check.name = headercheck ${QMAKE_FILE_IN} + header_check.commands = $$hcleanCOMMAND + silent:header_check.commands = @echo compiling[header] ${QMAKE_FILE_IN} && $$hcleanCOMMAND + QMAKE_EXTRA_COMPILERS += header_check + SYNCQT.CLEAN_HEADER_FILES -= $$HEADERSCLEAN_EXCLUDE + } + unset(hcleanCOMMAND) + unset(hcleanFLAGS) + unset(hcleanDEFS) +} |