2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-15 13:02:11 +00:00

Fix #5802: Add response file support for moc.

[SVN r74058]
This commit is contained in:
Jürgen Hunold
2011-08-25 18:09:59 +00:00
parent c3215e716a
commit 76d1ffc530
5 changed files with 101 additions and 43 deletions

View File

@@ -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 @@ if [ qt4.initialized ]
[ link phonon.cpp /qt//phonon ]
[ link qtmultimedia.cpp /qt//QtMultimedia ]
# QML
# QML
[ link qtdeclarative.cpp /qt//QtDeclarative ]
# Help systems.
@@ -52,12 +52,15 @@ if [ qt4.initialized ]
# 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

26
v2/test/qt4/mock.cpp Normal file
View File

@@ -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);
}

21
v2/test/qt4/mock.h Normal file
View File

@@ -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();
};

View File

@@ -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

View File

@@ -68,7 +68,7 @@ feature.feature qt3support : off on : propagated link-incompatible ;
# 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 @@ local rule read-output ( content )
# 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 @@ local rule check-version ( bin_prefix )
{
# Skip first line of output
}
else
else
{
temp = [ MATCH "([0-9]*)\\.([0-9]*)\\.([0-9]*)" : $(line) ] ;
}
@@ -144,14 +144,14 @@ local rule split-version ( version )
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 @@ rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : conditio
local inc_prefix lib_prefix bin_prefix ;
if $(full_inc)
{
inc_prefix = $(full_inc) ;
inc_prefix = $(full_inc) ;
}
else
{
@@ -236,7 +236,7 @@ rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : conditio
version = $(major-minor:J=.) ;
}
else
{
{
version = [ check-version $(bin_prefix) ] ;
if $(version)
{
@@ -259,7 +259,7 @@ rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : conditio
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 @@ rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : conditio
# 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 @@ rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : conditio
<variant>debug
$(target-requirements)
;
lib qtmain
: # sources
: # requirements
@@ -370,7 +370,7 @@ rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : conditio
;
if $(.have_separate_debug) = TRUE
{
{
debug-message Configure debug libraries with suffix '$(.suffix_debug)' ;
lib QtCore : $(main)
@@ -389,13 +389,13 @@ rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : conditio
# 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 @@ rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : conditio
# 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 @@ rule add-library ( lib-name : version ? : depends-on * : usage-defines * : requi
local real_include ;
real_include ?= $(include) ;
real_include ?= $(lib-name) ;
lib $(lib-name)
lib $(lib-name)
: # sources
$(depends-on)
: # requirements
@@ -642,7 +642,7 @@ rule add-library ( lib-name : version ? : depends-on * : usage-defines * : requi
if $(.have_separate_debug) = TRUE
{
lib $(lib-name)
lib $(lib-name)
: # sources
$(depends-on)
: # requirements
@@ -655,7 +655,7 @@ rule add-library ( lib-name : version ? : depends-on * : usage-defines * : requi
<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 @@ rule add-library ( lib-name : version ? : depends-on * : usage-defines * : requi
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))"
}