From 67ff0ed2a5aec552c0149cdba790eb94b7154dc3 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 27 Jan 2006 09:02:18 +0000 Subject: [PATCH] Improved Qt4 support. 1. Better qmake compatibility by adding the necessary defines for each Qt library. E.g. qmake defines QT_CORE_LIB when generating makefiles for a project using QtCore, QT_GUI_LIB for QtGui and so on. 2. Added support for QtTestLib, the Qt Test Framework ( Qt 4.1) 3. Added support for QtAssistantClient, Qt Integrated Help System 4. Better readability by adding explicit comments (# usage-requirements) and having one line per setting). 5. Add support for "moc-and-include header" by 5a. duplication of the "moccable-cpp" hack for headers. 5b. copy&change of "moc-h-generator" to "moc-inc-generator" 5c. renaming of the "moc.cpp" action to "moc.inc" and rearringing documentation. Patch from Juergen Hunold. [SVN r32428] --- v2/tools/qt4.jam | 173 +++++++++++++++++++++++++++++++++++------- v2/tools/types/qt.jam | 1 + 2 files changed, 147 insertions(+), 27 deletions(-) diff --git a/v2/tools/qt4.jam b/v2/tools/qt4.jam index 4aca67377..22b9c3606 100644 --- a/v2/tools/qt4.jam +++ b/v2/tools/qt4.jam @@ -86,7 +86,10 @@ rule init ( prefix ? ) # The OBJ result type is a fake here too. generators.register [ new moc-h-generator - qt4.moc.cpp : MOCCABLE_CPP : OBJ ] ; + qt4.moc.inc : MOCCABLE_CPP : OBJ ] ; + + generators.register [ new moc-inc-generator + qt4.moc.inc : MOCCABLE_H : OBJ ] ; # Generates .cpp file from qrc file generators.register-standard qt4.rcc : QRC : CPP(qrc_%) ; @@ -97,7 +100,6 @@ rule init ( prefix ? ) $(.prefix)/lib multi ; - local suffix ; if [ os.name ] = NT { @@ -115,77 +117,163 @@ rule init ( prefix ? ) suffix_version = "" ; suffix_debug = "_debug" ; } - + lib QtCore : $(main) : QtCore$(suffix_version) release : - : $(.prefix)/include/QtCore $(usage-requirements) - ; + : # usage-requirements + QT_CORE_LIB + $(.prefix)/include/QtCore + $(usage-requirements) + ; lib QtCore : $(main) : QtCore$(suffix_debug)$(suffix_version) debug : - : $(.prefix)/include/QtCore $(usage-requirements) ; + : # usage-requirements + QT_CORE_LIB + $(.prefix)/include/QtCore + $(usage-requirements) + ; + lib QtGui : QtCore : QtGui$(suffix_version) release : - : $(.prefix)/include/QtGui gui ; + : # usage-requirements + QT_GUI_LIB + $(.prefix)/include/QtGui + gui + ; + lib QtGui : QtCore : QtGui$(suffix_debug)$(suffix_version) debug : - : $(.prefix)/include/QtGui gui ; + : # usage-requirements + QT_GUI_LIB + $(.prefix)/include/QtGui + gui + ; + lib QtNetwork : QtCore : QtNetwork$(suffix_version) release : - : $(.prefix)/include/QtNetwork ; + : # usage-requirements + QT_NETWORK_LIB + $(.prefix)/include/QtNetwork + ; lib QtNetwork : QtCore : QtNetwork$(suffix_debug)$(suffix_version) debug : - : $(.prefix)/include/QtNetwork ; + : # usage-requirements + QT_NETWORK_LIB + $(.prefix)/include/QtNetwork + ; + lib QtSql : QtCore : QtSql$(suffix_version) release : - : $(.prefix)/include/QtSql ; + : # usage-requirements + QT_SQL_LIB + $(.prefix)/include/QtSql + ; lib QtSql : QtCore : QtSql$(suffix_debug)$(suffix_version) debug : - : $(.prefix)/include/QtSql ; + : # usage-requirements + QT_SQL_LIB + $(.prefix)/include/QtSql + ; + lib QtXml : QtCore : QtXml$(suffix_version) release : - : $(.prefix)/include/QtXml ; + : # usage-requirements + QT_XML_LIB + $(.prefix)/include/QtXml + ; lib QtXml : QtCore : QtXml$(suffix_debug)$(suffix_version) debug : - : $(.prefix)/include/QtXml ; - + : # usage-requirements + QT_XML_LIB + $(.prefix)/include/QtXml + ; + lib Qt3Support : QtGui QtNetwork QtXml QSql : Qt3Support$(suffix_version) release : - : $(.prefix)/include/Qt3Support ; + : # usage-requirements + QT_COMPAT_LIB + QT3_SUPPORT + $(.prefix)/include/Qt3Support + ; lib Qt3Support : QtGui QtNetwork QtXml QSql : Qt3Support$(suffix_debug)$(suffix_version) debug : - : $(.prefix)/include/Qt3Support ; - + : # usage-requirements + QT_COMPAT_LIB + QT3_SUPPORT + $(.prefix)/include/Qt3Support + ; + # OpenGl Support lib QtOpenGL : QtGui : QtOpenGL$(suffix_version) release : - : $(.prefix)/include/QtOpenGL ; + : # usage-requirements + QT_OPENGL_LIB + $(.prefix)/include/QtOpenGL + ; lib QtOpenGL : QtGui : QtOpenGL$(suffix_debug)$(suffix_version) debug : - : $(.prefix)/include/QtOpenGL ; + : # usage-requirements + QT_OPENGL_LIB + $(.prefix)/include/QtOpenGL + ; # SVG-Support (Qt 4.1) lib QtSvg : QtXml QtOpenGL : QtSvg$(suffix_version) release : - : $(.prefix)/include/QtSvg ; + : # usage-requirements + QT_SVG_LIB + $(.prefix)/include/QtSvg + ; lib QtSvg : QtXml QtOpenGL : QtSvg$(suffix_debug)$(suffix_version) debug : - : $(.prefix)/include/QtSvg ; + : # usage-requirements + QT_SVG_LIB + $(.prefix)/include/QtSvg + ; + + # Test-Support (Qt 4.1) + lib QtTest : QtCore + : QtTest$(suffix_version) release + : + : # usage-requirements + $(.prefix)/include/QtTest + ; + lib QtTest : QtCore + : QtTest$(suffix_debug)$(suffix_version) debug + : + : # usage-requirements + $(.prefix)/include/QtTest + ; + + # AssistantClient Support + lib QtAssistantClient : QtGui + : QtAssistantClient$(suffix_version) release + : + : # usage-requirements + $(.prefix)/include/QtAssistantClient + ; + lib QtAssistantClient : QtGui + : QtAssistantClient$(suffix_debug)$(suffix_version) debug + : + : # usage-requirements + $(.prefix)/include/QtAssistantClient + ; } } @@ -250,7 +338,7 @@ class moc-h-generator : generator name = [ $(sources[0]).name ] ; name = $(name:B) ; - local a = [ new action $(sources[1]) : qt4.moc.cpp : + local a = [ new action $(sources[1]) : qt4.moc.inc : $(property-set) ] ; local target = [ @@ -267,10 +355,40 @@ class moc-h-generator : generator return $(r) ; } + } +} +class moc-inc-generator : generator +{ + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule run ( project name ? : property-set : sources * ) + { + if ! $(sources[2]) && [ $(sources[1]).type ] = MOCCABLE_H + { + name = [ $(sources[0]).name ] ; + name = $(name:B) ; + + local a = [ new action $(sources[1]) : qt4.moc.inc : + $(property-set) ] ; + + local target = [ + new file-target moc_$(name) : CPP : $(project) : $(a) ] ; + + # Since this generator will return H target, the linking generator + # won't use it at all, and won't set any dependency on it. + # However, we need to target to be seen by bjam, so that dependency + # from sources to this generated header is detected -- if jam does + # not know about this target, it won't do anything. + DEPENDS all : [ $(target).actualize ] ; + + return [ virtual-target.register $(target) ] ; + } } } - # Query the installation directory # This is needed in at least two scenarios # First, when re-using sources from the Qt-Tree. @@ -291,9 +409,10 @@ actions moc $(.prefix)/bin/moc -I$(INCLUDES) -D$(DEFINES) -f $(>) -o $(<) } -# When moccing .cpp files, we don't need -f, otherwise generated -# code will include .cpp and we'll get duplicated symbols. -actions moc.cpp +# 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 { $(.prefix)/bin/moc -I$(INCLUDES) -D$(DEFINES) $(>) -o $(<) } diff --git a/v2/tools/types/qt.jam b/v2/tools/types/qt.jam index 9c8641da6..6d1dfbd42 100644 --- a/v2/tools/types/qt.jam +++ b/v2/tools/types/qt.jam @@ -5,5 +5,6 @@ type UI : ui ; type QRC : qrc ; type MOCCABLE_CPP ; +type MOCCABLE_H ; # Result of running moc. type MOC : moc : H ;