Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74058 - in trunk/tools/build/v2: test/qt4 tools
From: juergen.hunold_at_[hidden]
Date: 2011-08-25 14:10:00


Author: jhunold
Date: 2011-08-25 14:09:59 EDT (Thu, 25 Aug 2011)
New Revision: 74058
URL: http://svn.boost.org/trac/boost/changeset/74058

Log:
Fix #5802: Add response file support for moc.
Added:
   trunk/tools/build/v2/test/qt4/mock.cpp (contents, props changed)
   trunk/tools/build/v2/test/qt4/mock.h (contents, props changed)
Text files modified:
   trunk/tools/build/v2/test/qt4/jamroot.jam | 29 ++++++++++--------
   trunk/tools/build/v2/test/qt4/qttest.cpp | 8 ++++-
   trunk/tools/build/v2/tools/qt4.jam | 60 +++++++++++++++++++++------------------
   3 files changed, 54 insertions(+), 43 deletions(-)

Modified: trunk/tools/build/v2/test/qt4/jamroot.jam
==============================================================================
--- trunk/tools/build/v2/test/qt4/jamroot.jam (original)
+++ trunk/tools/build/v2/test/qt4/jamroot.jam 2011-08-25 14:09:59 EDT (Thu, 25 Aug 2011)
@@ -1,35 +1,35 @@
 # (c) Copyright Juergen Hunold 2008
-# Use, modification, and distribution are subject to the
-# Boost Software License, Version 1.0. (See accompanying file
+# Use, modification, and distribution are subject to the
+# Boost Software License, Version 1.0. (See accompanying file
 # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 import qt4 ;
-import testing ;
+import testing ;
 import cast ;
 
-
+
 
 if [ qt4.initialized ]
 {
     use-project /boost : ../../../../.. ;
 
- project qttest
- : requirements
+ project qttest
+ : requirements
           <library>/boost/test//boost_unit_test_framework
       ;
-
+
     alias qt-tests :
       # Check for explicit libraries, <use>/qt should not link any lib
       [ link-fail qtcorefail.cpp : <use>/qt ]
-
+
       [ run qtcore.cpp /qt//QtCore ]
       [ run qtsql.cpp /qt//QtSql ]
- [ run qtxml.cpp /qt//QtXml ]
+ [ run qtxml.cpp /qt//QtXml ]
       [ run qtnetwork.cpp /qt//QtNetwork ]
       [ run qtscript.cpp /qt//QtScript ]
       [ run qtscripttools.cpp /qt//QtScriptTools ]
       [ run qtxmlpatterns.cpp /qt//QtXmlPatterns ]
-
+
       # ToDo: runable example code
       [ link qtsvg.cpp /qt//QtSvg ]
       [ link qtgui.cpp /qt//QtGui ]
@@ -39,7 +39,7 @@
       [ link phonon.cpp /qt//phonon ]
       [ link qtmultimedia.cpp /qt//QtMultimedia ]
 
- # QML
+ # QML
       [ link qtdeclarative.cpp /qt//QtDeclarative ]
 
       # Help systems.
@@ -52,12 +52,15 @@
 
       # Testing using QtTest. Simple sample
       # ToDo: better support for "automoc" aka '#include "qttest.moc"'
- [ run qttest.cpp [ cast _ moccable-cpp : qttest.cpp ] /qt//QtTest ]
+ [ run qttest.cpp [ cast _ moccable-cpp : qttest.cpp ] /qt//QtTest : : : <define>TEST_MOCK ]
+
+ # Test moc rule
+ [ run mock.cpp mock.h /qt//QtCore : : : <define>TEST_MOCK ]
 
    : # requirements
    : # default-build
    : # usage-requirements
- ;
+ ;
 }
 
 # QtAssistant is removed from Qt >= 4.6

Added: trunk/tools/build/v2/test/qt4/mock.cpp
==============================================================================
--- (empty file)
+++ trunk/tools/build/v2/test/qt4/mock.cpp 2011-08-25 14:09:59 EDT (Thu, 25 Aug 2011)
@@ -0,0 +1,26 @@
+// (c) Copyright Juergen Hunold 2011
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_TEST_MODULE QtMoc
+
+#include "mock.h"
+
+#include <boost/test/unit_test.hpp>
+
+Mock::Mock()
+{
+}
+
+/*!
+ Check that the compiler get the correct #defines.
+ The logic to test the moc is in the header file "mock.h"
+ */
+BOOST_AUTO_TEST_CASE(construct_mock)
+{
+ delete new Mock();
+
+ BOOST_CHECK_EQUAL(BOOST_IS_DEFINED(QT_CORE_LIB), true);
+ BOOST_CHECK_EQUAL(BOOST_IS_DEFINED(TEST_MOCK), true);
+}

Added: trunk/tools/build/v2/test/qt4/mock.h
==============================================================================
--- (empty file)
+++ trunk/tools/build/v2/test/qt4/mock.h 2011-08-25 14:09:59 EDT (Thu, 25 Aug 2011)
@@ -0,0 +1,21 @@
+// (c) Copyright Juergen Hunold 2011
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <QtCore/QObject>
+
+class Mock : public QObject
+{
+ /*!
+ Test that the moc gets the necessary #defines
+ Else the moc will not see the Q_OBJECT macro, issue a warning
+ and linking will fail due to missing vtable symbols.
+ */
+#if defined(TEST_MOCK)
+ Q_OBJECT
+#endif
+ public:
+
+ Mock();
+};

Modified: trunk/tools/build/v2/test/qt4/qttest.cpp
==============================================================================
--- trunk/tools/build/v2/test/qt4/qttest.cpp (original)
+++ trunk/tools/build/v2/test/qt4/qttest.cpp 2011-08-25 14:09:59 EDT (Thu, 25 Aug 2011)
@@ -1,4 +1,4 @@
-// (c) Copyright Juergen Hunold 2008
+// (c) Copyright Juergen Hunold 2008-2011
 // Use, modification and distribution is subject to the Boost Software
 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -7,11 +7,15 @@
 
 class QtTest: public QObject
 {
+ /*!
+ Test if the moc gets the #define
+ */
+#if defined(TEST_MOCK)
     Q_OBJECT
+#endif
 
 private Q_SLOTS:
     void toUpper();
-
 };
 
 void

Modified: trunk/tools/build/v2/tools/qt4.jam
==============================================================================
--- trunk/tools/build/v2/tools/qt4.jam (original)
+++ trunk/tools/build/v2/tools/qt4.jam 2011-08-25 14:09:59 EDT (Thu, 25 Aug 2011)
@@ -68,7 +68,7 @@
 
 # The Qt version used for requirements
 # Valid are <qt>4.4 or <qt>4.5.0
-# Auto-detection via qmake sets '<qt>major.minor.patch'
+# Auto-detection via qmake sets '<qt>major.minor.patch'
 feature.feature qt : : propagated ;
 
 project.initialize $(__name__) ;
@@ -110,7 +110,7 @@
 # Capture Qt version from qmake
 local rule check-version ( bin_prefix )
 {
- full-cmd = $(bin_prefix)"/qmake -v" ;
+ full-cmd = $(bin_prefix)"/qmake -v" ;
     debug-message Running '$(full-cmd)' ;
     local output = [ SHELL $(full-cmd) ] ;
     for line in [ read-output $(output) ]
@@ -120,7 +120,7 @@
         {
             # Skip first line of output
         }
- else
+ else
         {
             temp = [ MATCH "([0-9]*)\\.([0-9]*)\\.([0-9]*)" : $(line) ] ;
         }
@@ -144,14 +144,14 @@
     return $(major-minor[1]) $(major-minor[2]) ;
 }
 
-# Initialize the QT support module.
+# Initialize the QT support module.
 # Parameters:
 # - 'prefix' parameter tells where Qt is installed.
 # - 'full_bin' optional full path to Qt binaries (qmake,moc,uic,rcc)
 # - 'full_inc' optional full path to Qt top-level include directory
 # - 'full_lib' optional full path to Qt library directory
 # - 'version' optional version of Qt, else autodetected via 'qmake -v'
-# - 'condition' optional requirements
+# - 'condition' optional requirements
 rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : condition * )
 {
     project.push-current $(.project) ;
@@ -172,7 +172,7 @@
     local inc_prefix lib_prefix bin_prefix ;
     if $(full_inc)
     {
- inc_prefix = $(full_inc) ;
+ inc_prefix = $(full_inc) ;
     }
     else
     {
@@ -236,7 +236,7 @@
         version = $(major-minor:J=.) ;
     }
     else
- {
+ {
         version = [ check-version $(bin_prefix) ] ;
         if $(version)
         {
@@ -259,7 +259,7 @@
 
     local target-os = [ feature.get-values target-os : $(condition) ] ;
     if ! $(target-os)
- {
+ {
         target-os ?= [ feature.defaults target-os ] ;
         target-os = $(target-os:G=) ;
         target-requirements += <target-os>$(target-os) ;
@@ -317,12 +317,12 @@
        # ToDo: 2009-02-12: Maybe throw this away and
        # require separate setup with <variant>debug as condition.
        .have_separate_debug = FALSE ;
-
+
        # Setup other platforms
- if $(target-os) in windows cygwin
+ if $(target-os) in windows cygwin
        {
            .have_separate_debug = TRUE ;
-
+
            # On NT, the libs have "4" suffix, and "d" suffix in debug builds.
            .suffix_version = "4" ;
            .suffix_debug = "d" ;
@@ -335,7 +335,7 @@
                   <variant>debug
                   $(target-requirements)
                ;
-
+
            lib qtmain
                : # sources
                : # requirements
@@ -370,7 +370,7 @@
            ;
 
        if $(.have_separate_debug) = TRUE
- {
+ {
            debug-message Configure debug libraries with suffix '$(.suffix_debug)' ;
 
            lib QtCore : $(main)
@@ -389,13 +389,13 @@
 
     # Initialising the remaining libraries is canonical
     # parameters 'module' : 'depends-on' : 'usage-define' : 'requirements' : 'include'
- # 'include' only for non-canonical include paths.
+ # 'include' only for non-canonical include paths.
     add-shared-library QtGui : QtCore : QT_GUI_LIB : $(target-requirements) ;
     add-shared-library QtNetwork : QtCore : QT_NETWORK_LIB : $(target-requirements) ;
     add-shared-library QtSql : QtCore : QT_SQL_LIB : $(target-requirements) ;
     add-shared-library QtXml : QtCore : QT_XML_LIB : $(target-requirements) ;
 
- add-shared-library Qt3Support : QtGui QtNetwork QtXml QtSql
+ add-shared-library Qt3Support : QtGui QtNetwork QtXml QtSql
                                   : QT_QT3SUPPORT_LIB QT3_SUPPORT
                                   : <qt3support>on $(target-requirements) ;
 
@@ -432,20 +432,20 @@
     # WebKit (Qt 4.4)
     add-shared-library QtWebKit : QtGui : QT_WEBKIT_LIB : $(target-requirements) ;
 
- # Phonon Multimedia (Qt 4.4)
+ # Phonon Multimedia (Qt 4.4)
     add-shared-library phonon : QtGui QtXml : QT_PHONON_LIB : $(target-requirements) ;
 
- # Multimedia engine (Qt 4.6)
+ # Multimedia engine (Qt 4.6)
     add-shared-library QtMultimedia : QtGui : QT_MULTIMEDIA_LIB : $(target-requirements) ;
 
- # XmlPatterns-Engine (Qt 4.4)
+ # XmlPatterns-Engine (Qt 4.4)
     add-shared-library QtXmlPatterns : QtNetwork : QT_XMLPATTERNS_LIB : $(target-requirements) ;
 
- # Help-Engine (Qt 4.4)
+ # Help-Engine (Qt 4.4)
     add-shared-library QtHelp : QtGui QtSql QtXml : : $(target-requirements) ;
     add-shared-library QtCLucene : QCore QtSql QtXml : : $(target-requirements) ;
 
- # QML-Engine (Qt 4.7)
+ # QML-Engine (Qt 4.7)
     add-shared-library QtDeclarative : QtGui QtXml : : $(target-requirements) ;
 
     # AssistantClient Support
@@ -627,8 +627,8 @@
         local real_include ;
         real_include ?= $(include) ;
         real_include ?= $(lib-name) ;
-
- lib $(lib-name)
+
+ lib $(lib-name)
            : # sources
              $(depends-on)
            : # requirements
@@ -642,7 +642,7 @@
 
         if $(.have_separate_debug) = TRUE
         {
- lib $(lib-name)
+ lib $(lib-name)
                : # sources
                  $(depends-on)
                : # requirements
@@ -655,7 +655,7 @@
                  <include>$(.incprefix)/$(real_include)
                ;
         }
- }
+ }
 
     # Make library explicit so that a simple <use>qt4 will not bring in everything.
     # And some components like QtDBus/Phonon may not be available on all platforms.
@@ -669,21 +669,25 @@
 flags qt4.moc INCLUDES <include> ;
 flags qt4.moc DEFINES <define> ;
 
+# need a newline for expansion of DEFINES and INCLUDES in the response file.
+.nl = "
+" ;
+
 # Processes headers to create Qt MetaObject information. Qt4-moc has its
 # c++-parser, so pass INCLUDES and DEFINES.
-#
+# We use response file with one INCLUDE/DEFINE per line
+#
 actions moc
 {
- $(.BINPREFIX[-1])/moc -I"$(INCLUDES)" -D$(DEFINES) -f $(>) -o $(<)
+ $(.BINPREFIX[-1])/moc -f $(>) -o $(<) @"@($(<).rsp:E=-D$(DEFINES)$(.nl) -I"$(INCLUDES:T)"$(.nl))"
 }
 
-
 # When moccing files for include only, we don't need -f, otherwise the generated
 # code will include the .cpp and we'll get duplicated symbols.
 #
 actions moc.inc
 {
- $(.BINPREFIX[-1])/moc -I"$(INCLUDES)" -D$(DEFINES) $(>) -o $(<)
+ $(.BINPREFIX[-1])/moc $(>) -o $(<) @"@($(<).rsp:E=-D$(DEFINES)$(.nl) -I"$(INCLUDES:T)"$(.nl))"
 }
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk