mirror of
https://github.com/boostorg/build.git
synced 2026-02-16 13:22:11 +00:00
* If a generator was given a source it could not handle, it used to return
that source together with generated targets. This was nice for some use
cases, but no very nice for others, and this behaviour could not be turned
off. One use case where it worked bad was:
lib plugin : plugin.cpp helper ;
lib helper : helper.cpp ;
On windows, 'plugin' would link to the 'import library' and pass the DLL
target though. So, when installing 'plugin', we'd also install 'helper.dll',
and it was not possible to do anything about it.
* If we asked generators.construct to produce sources of type CPP,
and the selected generator produced both targets of type CPP, and of
some other type, we'd try again to convert those other targets to CPP.
This simply complicated the logic for no good reason.
* Most generator function had 'multiple' parameter, which function
was long forgotten by anybody.
As a bit of history, I believe some of the above decisions were due to a
certain use case:
CPP <------- WHL
\
WD
/
CPP <------- DLP
Here, a source file is converted to two targets with one command, and each
produced file is converted to CPP. Our generators search would notice that
there are two generators for CPP: the WHL->CPP and DPL->CPP
generators. Neither is better that the other so both are tried, and produce
(CPP, DPL) and (CPP, WHL) pairs of targets. To avoid reporting an ambiguity,
we'd try to convert, DLP to CPP and WHL to CPP, do it successfully, notice
that produced targets are the same and decide that there's no ambiguity.
However, this is rather complex logic for a relatively rare case. It can
be handled by writing another WD->CPP generator that would handle
disambiguation itself.
This commit has one user-visible change. The code:
exe a : a.cpp b ;
obj b : b.cpp helper;
lib helper ;
No longer works -- the 'a' target won't link to 'helper'. However, this is
pretty stange code and worked before almost by accident.
[SVN r29361]
159 lines
5.2 KiB
Plaintext
159 lines
5.2 KiB
Plaintext
# Copyright (C) Vladimir Prus 2002. Permission to copy, use, modify, sell and
|
|
# distribute this software is granted provided this copyright notice appears in
|
|
# all copies. This software is provided "as is" without express or implied
|
|
# warranty, and with no claim as to its suitability for any purpose.
|
|
|
|
import modules ;
|
|
import feature ;
|
|
import errors ;
|
|
import type ;
|
|
import "class" : new ;
|
|
import generators ;
|
|
import project ;
|
|
import toolset : flags ;
|
|
|
|
# Convert this module into a project, so that we can declare
|
|
# targets here.
|
|
|
|
project.initialize $(__name__) ;
|
|
project qt ;
|
|
|
|
# Initialized the QT support module. The 'prefix' parameter
|
|
# tells where QT is installed. When not given, environmental
|
|
# variable QTDIR should be set.
|
|
rule init ( prefix ? )
|
|
{
|
|
if ! $(prefix)
|
|
{
|
|
prefix = [ modules.peek : QTDIR ] ;
|
|
if ! $(prefix)
|
|
{
|
|
errors.error
|
|
"QT installation prefix not given and QTDIR variable is empty" ;
|
|
}
|
|
}
|
|
|
|
if $(.initialized)
|
|
{
|
|
if $(prefix) != $(.prefix)
|
|
{
|
|
errors.error
|
|
"Attempt the reinitialize QT with different installation prefix" ;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
.initialized = true ;
|
|
.prefix = $(prefix) ;
|
|
|
|
generators.register-standard qt.moc : H : CPP(moc_%) : <allow>qt ;
|
|
|
|
type.register UI : ui ;
|
|
type.register UIC_H : : H ;
|
|
|
|
generators.register-standard qt.uic-h : UI : UIC_H : <allow>qt ;
|
|
|
|
# The following generator is used to convert UI files to CPP
|
|
# It creates UIC_H from UI, and constructs CPP from UI/UIC_H
|
|
# In addition, it also returns UIC_H target, so that it can bee
|
|
# mocced.
|
|
class qt::uic-cpp-generator : generator
|
|
{
|
|
rule __init__ ( )
|
|
{
|
|
generator.__init__ qt.uic-cpp : UI UIC_H : CPP : <allow>qt ;
|
|
}
|
|
|
|
rule run ( project name ? : properties * : sources + )
|
|
{
|
|
# Consider this:
|
|
# obj test : test_a.cpp : <optimization>off ;
|
|
#
|
|
# This generator will somehow be called in this case, and,
|
|
# will fail -- which is okay. However, if there are <library>
|
|
# properties they will be converted to sources, so the size of
|
|
# 'sources' will be more than 1. In this case, the base generator
|
|
# will just crash -- and that's not good. Just use a quick test
|
|
# here.
|
|
|
|
local result ;
|
|
if ! $(sources[2])
|
|
{
|
|
# Construct CPP as usual
|
|
result = [ generator.run $(project) $(name)
|
|
: $(properties) : $(sources) ] ;
|
|
|
|
# If OK, process UIC_H with moc. It's pretty clear that
|
|
# the object generated with UIC will have Q_OBJECT macro.
|
|
if $(result)
|
|
{
|
|
local action = [ $(result[1]).action ] ;
|
|
local sources = [ $(action).sources ] ;
|
|
local mocced = [ generators.construct $(project) $(name)
|
|
: CPP : $(properties) : $(sources[2]) ] ;
|
|
result += $(mocced[2-]) ;
|
|
}
|
|
}
|
|
|
|
return $(result) ;
|
|
}
|
|
}
|
|
|
|
generators.register [ new qt::uic-cpp-generator ] ;
|
|
|
|
# Finally, declare prebuilt target for QT library.
|
|
local usage-requirements =
|
|
<include>$(.prefix)/include
|
|
<dll-path>$(.prefix)/lib
|
|
<library-path>$(.prefix)/lib
|
|
<allow>qt
|
|
;
|
|
lib qt : : <name>qt-mt <threading>multi : : $(usage-requirements) ;
|
|
lib qt : : <name>qt <threading>single : : $(usage-requirements) ;
|
|
}
|
|
}
|
|
|
|
# Query the installation directory
|
|
# This is needed in at least two scenarios
|
|
# First, when re-using sources from the Qt-Tree.
|
|
# Second, to "install" custom Qt plugins to the Qt-Tree.
|
|
rule directory
|
|
{
|
|
return $(.prefix) ;
|
|
}
|
|
|
|
# -f forces moc to include the processed source file.
|
|
# Without it, it would think that .qpp is not a header and would not
|
|
# include it from the generated file.
|
|
actions moc
|
|
{
|
|
$(.prefix)/bin/moc -f $(>) -o $(<)
|
|
}
|
|
|
|
space = " " ;
|
|
|
|
# Sometimes it's required to make 'plugins' available during
|
|
# uic invocation. To help with this we add paths to all dependency
|
|
# libraries to uic commane line. The intention is that it's possible
|
|
# to write
|
|
#
|
|
# exe a : ... a.ui ... : <uses>some_plugin ;
|
|
#
|
|
# and have everything work. We'd add quite a bunch of unrelated paths
|
|
# but it won't hurt.
|
|
flags qt.uic-h LIBRARY_PATH <xdll-path> ;
|
|
actions uic-h
|
|
{
|
|
$(.prefix)/bin/uic $(>) -o $(<) -L$(space)$(LIBRARY_PATH)
|
|
}
|
|
|
|
flags qt.uic-cpp LIBRARY_PATH <xdll-path> ;
|
|
# The second target is uic-generated header name. It's placed in
|
|
# build dir, but we want to include it using only basename.
|
|
actions uic-cpp
|
|
{
|
|
$(.prefix)/bin/uic $(>[1]) -i $(>[2]:D=) -o $(<) -L$(space)$(LIBRARY_PATH)
|
|
}
|
|
|
|
|