mirror of
https://github.com/boostorg/build.git
synced 2026-02-12 12:02:24 +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]
110 lines
2.1 KiB
Plaintext
110 lines
2.1 KiB
Plaintext
|
|
import type ;
|
|
import generators ;
|
|
import "class" : new ;
|
|
|
|
type.register WHL : whl ;
|
|
type.register DLP : dlp ;
|
|
type.register WHL_LR0 : lr0 ;
|
|
type.register WD : wd ;
|
|
|
|
generators.register-standard extra.whale : WHL : CPP WHL_LR0 H H(%_symbols) ;
|
|
generators.register-standard extra.dolphin : DLP : CPP ;
|
|
generators.register-standard extra.wd : WD : WHL(%_parser) DLP(%_lexer) ;
|
|
|
|
class wd-to-cpp : generator
|
|
{
|
|
rule __init__ ( * : * : * )
|
|
{
|
|
generator.__init__ $(1) : $(2) : $(3) ;
|
|
}
|
|
|
|
rule run ( project name ? : property-set : source )
|
|
{
|
|
local new-sources ;
|
|
if ! [ $(source).type ] in WHL DLP
|
|
{
|
|
local r1 = [ generators.construct $(project) $(name)
|
|
: WHL : $(property-set) : $(source) ] ;
|
|
local r2 = [ generators.construct $(project) $(name)
|
|
: DLP : $(property-set) : $(source) ] ;
|
|
|
|
new-sources = [ sequence.unique $(r1[2-]) $(r2[2-]) ] ;
|
|
}
|
|
else
|
|
{
|
|
new-sources = $(source) ;
|
|
}
|
|
|
|
local result ;
|
|
for local i in $(new-sources)
|
|
{
|
|
local t = [ generators.construct $(project) $(name) : CPP
|
|
: $(property-set) : $(i) ] ;
|
|
result += $(t[2-]) ;
|
|
}
|
|
return $(result) ;
|
|
}
|
|
}
|
|
generators.override extra.wd-to-cpp : extra.whale ;
|
|
generators.override extra.wd-to-cpp : extra.dolphin ;
|
|
|
|
|
|
generators.register [ new wd-to-cpp extra.wd-to-cpp : : CPP ] ;
|
|
|
|
rule whale ( targets * : sources * : properties * )
|
|
{
|
|
}
|
|
|
|
actions whale
|
|
{
|
|
echo "Whale consuming " $(>)
|
|
touch $(<)
|
|
}
|
|
|
|
rule dolphin ( targets * : source * : properties * )
|
|
{
|
|
}
|
|
|
|
actions dolphin
|
|
{
|
|
echo "Dolphin consuming" $(>)
|
|
touch $(<)
|
|
}
|
|
|
|
rule wd ( targets * : source * : properties * )
|
|
{
|
|
}
|
|
|
|
actions wd
|
|
{
|
|
echo "WD consuming" $(>)
|
|
touch $(<)
|
|
}
|
|
|
|
rule x ( target * : source * : properties * )
|
|
{
|
|
}
|
|
|
|
|
|
actions x
|
|
{
|
|
echo "X: source is " $(>)
|
|
touch $(<)
|
|
}
|
|
|
|
rule x_pro ( target * : source * : properties * )
|
|
{
|
|
}
|
|
|
|
|
|
actions x_pro
|
|
{
|
|
echo "X_PRO: source is " $(>)
|
|
touch $(<)
|
|
}
|
|
|
|
|
|
|
|
|