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

Further generators simplications.

1. If when generating something, we find more that one suitable generators,
   run them and more then one return something, immediately report ambiguity.
   Don't care if the produced targets are the same. This is better that
   running several generators all the time, performance wise.

2. Remove the notion of 'intermediate' virtual-targets. IIRC, they were used
   to prevent staging of RSP files, and we don't stage them anyway now.


[SVN r29491]
This commit is contained in:
Vladimir Prus
2005-06-09 08:12:21 +00:00
parent 900240c47d
commit 5fab631f5d
11 changed files with 41 additions and 139 deletions

View File

@@ -1054,66 +1054,7 @@ local rule find-viable-generators ( target-type : property-set )
return $(result) ;
}
# Given a vector of vectors, of of them represents results of running some
# generator, returns the 'best' result, it it exists. Otherwise, exit with
# and error. Result is returned as plain jam list.
local rule select-dependency-graph ( options )
{
if [ $(options).size ] = 0
{
return ;
}
else if [ $(options).size ] = 1
{
return [ $(options).get-at 1 ] ;
}
else
{
# We have several alternatives and need to check if they
# are the same.
for local r in [ $(options).get ]
{
normalize-target-list $(r) ;
local v = [ $(r).get ] ;
generators.dout $(v[2-]) ;
}
# One note why we can compare object names directly,
# without using deep copy. All the targets here are
# produced by some generators, and generators should
# pass the targets they've returned via 'virtual-target.register'.
# So, two elements can only be equivalent, if they are just
# the same object.
local f = [ $(options).at 1 ] ;
f = [ $(f).get ] ;
f = $(f[2-]) ;
local mismatch ;
for local r in [ $(options).get ]
{
local v = [ $(r).get ] ;
v = $(v[2-]) ;
if $(f) != $(v)
{
mismatch = true ;
}
}
if ! $(mismatch)
{
local v = [ $(options).at 1 ] ;
return [ $(v).get ] ;
}
else
{
error [ $(options).size ] "possible generations for "
$(target-types) "Can't handle this now." ;
}
}
}
.construct-stack = ;
# Attempts to construct target by finding viable generators, running them
@@ -1122,12 +1063,11 @@ local rule construct-really (
project name ? : target-type : property-set : sources * )
{
viable-generators = [ find-viable-generators $(target-type) : $(property-set) ] ;
local results = [ new vector ] ;
generators.dout [ indent ] "*** " [ sequence.length $(viable-generators) ]
" viable generators" ;
local result ;
for local g in $(viable-generators)
{
# This variable will be restored on exit from this scope.
@@ -1138,11 +1078,18 @@ local rule construct-really (
if $(r)
{
$(results).push-back [ new vector $(r) ] ;
if $(result)
{
error "Ambiguity found when searching for best transformation" ;
}
else
{
result = $(r) ;
}
}
}
return [ select-dependency-graph $(results) ] ;
return $(result) ;
}
@@ -1164,43 +1111,26 @@ local rule construct-really (
rule construct ( project name ? : target-type : property-set * : sources *
: allowed-type * )
{
allowed-type ?= $(target-type) ;
if (.construct-stack)
{
ensure-type $(sources) ;
}
# Intermediate targets are not passed to generators
# and just returned unmodified.
local intermediate ;
if ! $(.construct-stack)
{
local sources2 ;
for local s in $(sources)
{
if ! [ $(s).intermediate ]
{
sources2 += $(s) ;
}
else
{
intermediate += $(s) ;
}
}
sources = $(sources2) ;
}
.construct-stack += 1 ;
increase-indent ;
if $(.debug)
{
generators.dout [ indent ] "*** construct" $(target-type) ;
generators.dout [ indent ] "*** construct" $(target-type) ;
for local s in $(sources)
{
generators.dout [ indent ] " from" $(s) ;
for local s in $(sources)
{
generators.dout [ indent ] " from" $(s) ;
}
generators.dout [ indent ] " properties:" [ $(property-set).raw ] ;
}
generators.dout [ indent ] " properties:" [ $(property-set).raw ] ;
local result = [ construct-really $(project) $(name)
: $(target-type) : $(property-set) : $(sources) ] ;
@@ -1208,30 +1138,7 @@ rule construct ( project name ? : target-type : property-set * : sources *
decrease-indent ;
.construct-stack = $(.construct-stack[2-]) ;
if ! $(.construct-stack)
{
result += $(intermediate) ;
}
# For all targets of 'allowed-type', reset the 'intermediate' attribute.
if ! $(.construct-stack) && $(allowed-type) != * # This is first invocation in stack
{
local result2 ;
for local t in $(result[2-])
{
local type = [ $(t).type ] ;
# Return only targets of the requested type, unless 'return-all'
# is specified. If we don't do this, then all targets calling
# 'construct' will get unused target returned, which will break
# checking for unused sources a bit harder.
if $(type) && ( $(type) = $(target-type) || [ type.is-derived $(type) $(allowed-type) ] )
{
$(t).set-intermediate ;
}
}
}
return $(result) ;
}

View File

@@ -257,18 +257,6 @@ class abstract-file-target : virtual-target
return $(self.root) ;
}
rule set-intermediate ( value ? )
{
self.intermediate = $(value) ;
}
rule intermediate ( )
{
return $(self.intermediate) ;
}
# Gets or sets the subvariant which created this target. Subvariant
# is set when target is brought into existance, and is never changed
# after that. In particual, if target is shared by subvariant, only
@@ -506,7 +494,7 @@ class file-target : abstract-file-target
abstract-file-target.__init__ $(name) $(exact) : $(type) : $(project)
: $(action) ;
self.path = $(path) ;
self.path = $(path) ;
}
rule actualize-location ( target )
@@ -783,7 +771,7 @@ rule from-file ( file : file-loc : project )
local type = [ type.type $(file) ] ;
local result ;
result = [ new file-target $(file)
result = [ new file-target $(file)
: $(type)
: $(project)
: #action
@@ -801,7 +789,8 @@ rule from-file ( file : file-loc : project )
rule register ( target )
{
local signature = [ sequence.join
[ $(target).name ] : - ] ;
[ $(target).name ] : - ] ;
local result ;
for local t in $(.cache.$(signature))

View File

@@ -10,9 +10,11 @@
import toolset : flags ;
import feature ;
import generators ;
feature.extend toolset : acc ;
toolset.inherit acc : unix ;
generators.override builtin.lib-generator : acc.prebuilt ;
feature.subfeature toolset acc : version ;
# Configures the acc toolset.

View File

@@ -11,13 +11,16 @@ import toolset ;
import feature ;
import toolset : flags ;
import common ;
import generators ;
import unix ;
import como ;
feature.extend-subfeature toolset como : platform : linux ;
toolset.inherit-generators como-linux
<toolset>como <toolset-como:platform>linux : unix ;
generators.override builtin.lib-generator : como-linux.prebuilt ;
toolset.inherit-flags como-linux : unix ;
toolset.inherit-rules como-linux : gcc ;

View File

@@ -11,10 +11,12 @@ import feature : feature ;
import toolset : flags ;
import type ;
import common ;
import generators ;
toolset.register darwin ;
import gcc ;
toolset.inherit-generators darwin : gcc ;
generators.override builtin.lib-generator : darwin.prebuilt ;
toolset.inherit-rules darwin : gcc ;
toolset.inherit-flags darwin : gcc ;

View File

@@ -21,6 +21,7 @@ feature.extend toolset : gcc ;
import unix ;
toolset.inherit-generators gcc : unix : unix.link unix.link.dll ;
generators.override builtin.lib-generator : gcc.prebuilt ;
toolset.inherit-flags gcc : unix ;
toolset.inherit-rules gcc : unix ;

View File

@@ -12,11 +12,13 @@ import intel ;
import gcc ;
import common ;
import errors ;
import generators ;
feature.extend-subfeature toolset intel : platform : linux ;
toolset.inherit-generators intel-linux
<toolset>intel <toolset-intel:platform>linux : gcc ;
generators.override builtin.lib-generator : intel-linux.prebuilt ;
toolset.inherit-rules intel-linux : gcc ;
toolset.inherit-flags intel-linux : gcc
: <inlining>off <inlining>on <inlining>full <optimization>space ;

View File

@@ -180,14 +180,7 @@ class install-target-class : basic-target
}
else
{
# Intermediate targets are those with
# "unrequested" types. Unless specific list
# of target types is given, we don't install
# such targets.
if ! [ $(r).intermediate ]
{
result += $(r) ;
}
result += $(r) ;
}
}
}

View File

@@ -14,6 +14,7 @@ import common ;
feature.extend toolset : sun ;
toolset.inherit sun : unix ;
generators.override builtin.lib-generator : sun.prebuilt ;
feature.subfeature toolset sun : version ;
feature.extend stdlib : sun-stlport ;

View File

@@ -138,7 +138,7 @@ generators.register
[ new unix-prebuilt-lib-generator unix.prebuilt : : LIB
: <file> <toolset>unix ] ;
generators.override builtin.lib-generator : unix.prebuilt ;
# Declare generators

View File

@@ -11,9 +11,11 @@
import toolset : flags ;
import feature ;
import common ;
import generators ;
feature.extend toolset : vacpp ;
toolset.inherit vacpp : unix ;
generators.override builtin.lib-generator : vacpp.prebuilt ;
feature.subfeature toolset vacpp : version ;
# Configures the vacpp toolset.