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

Refactor/improve <tag> support.

* build/targets.jam (generate-realy):
  After applying tag, we used to 'temporary' change self.name,
  which is horrible. How pass the name to 'construct'.

  (construct): New parameter 'name'.

  (tag-name): New rule, extracted from basic-target. This needs to be
  separate rule so that we can call it from 'stage'. Check for a value of
  from '@something' and interpret 'something' as a rule which returns the
  new name.


[SVN r26408]
This commit is contained in:
Vladimir Prus
2004-12-03 08:28:37 +00:00
parent 8bb8145360
commit aabded2811
6 changed files with 56 additions and 37 deletions

View File

@@ -41,7 +41,7 @@ class alias-target-class : basic-target
: $(default-build) : $(usage-requirements) ;
}
rule construct ( source-targets * : property-set )
rule construct ( name : source-targets * : property-set )
{
return [ property-set.empty ] $(source-targets) ;
}

View File

@@ -982,27 +982,6 @@ class basic-target : abstract-target
return no-match ;
}
}
#
# Allows the user to tag the name of the target, according to properties.
#
rule tag-name ( name : property-set )
{
local properties = [ $(property-set).raw ] ;
local tagged-name = $(name) ;
if <tag> in $(properties:G)
{
local tags = [ $(property-set).get <tag> ] ;
for local tag in $(tags)
{
tagged-name = $(tagged-name)$(tag) ;
}
}
return $(tagged-name) ;
}
# Takes a target reference, which might be either target id
# or a dependency property, and generates that target using
@@ -1073,13 +1052,14 @@ class basic-target : abstract-target
# usage requirements.
source-targets = [ sequence.unique $(source-targets) ] ;
local tagged-name = [ tag-name $(self.name) : $(rproperties) ] ;
local original-name = $(self.name) ;
self.name = $(tagged-name) ;
# Compute the real name for generated targets, using
# the <tag> feature.
local tagged-name = [
targets.tag-name $(self.name) : $(rproperties) ] ;
local result =
[ construct $(source-targets) : $(rproperties) ] ;
[ construct $(tagged-name) :
$(source-targets) : $(rproperties) ] ;
local gur = $(result[1]) ;
result = $(result[2-]) ;
@@ -1091,8 +1071,6 @@ class basic-target : abstract-target
ur = [ $(ur).add $(gur) ] ;
$(s).set-usage-requirements $(ur) ;
self.generated.$(property-set) = $(ur) $(result) ;
self.name = $(original-name) ;
}
else
{
@@ -1182,7 +1160,7 @@ class basic-target : abstract-target
# Constructs the virtual targets for this abstract targets and
# the dependecy graph. Returns the list of virtual targets.
# Should be overrided in derived classes.
rule construct ( source-targets * : properties * )
rule construct ( name : source-targets * : properties * )
{
errors.error "method should be defined in derived classes" ;
}
@@ -1206,9 +1184,9 @@ class typed-target : basic-target
return $(self.type) ;
}
rule construct ( source-targets * : property-set )
rule construct ( name : source-targets * : property-set )
{
local r = [ generators.construct $(self.project) $(self.name) : $(self.type)
local r = [ generators.construct $(self.project) $(name) : $(self.type)
: [ property-set.create [ $(property-set).raw ] # [ feature.expand
<main-target-type>$(self.type) ]
# ]
@@ -1222,6 +1200,47 @@ class typed-target : basic-target
}
}
#
# Given a base target name and a set of properties, returns the
# name which should be really used, by looking at the <tag> properties.
# The tag properties come in two flavour:
# - <tag>value,
# - <tag>@rule-name
# In the first case, value is just added to name
# In the second case, the specified rule is called with name and properties
# and should return the new name.
rule tag-name ( name : property-set )
{
local properties = [ $(property-set).raw ] ;
local tagged-name = $(name) ;
if <tag> in $(properties:G)
{
local tags = [ $(property-set).get <tag> ] ;
local rule-name = [ MATCH ^@(.*) : $(tags) ] ;
if $(rule-name)
{
if $(tags[2])
{
errors.error "<tag>@rulename is present but is the the only <tag> feature" ;
}
tagged-name = [ $(rule-name) $(name) : $(property-set) ] ;
}
else
{
for local tag in $(tags)
{
tagged-name = $(tagged-name)$(tag) ;
}
}
}
return $(tagged-name) ;
}
# Return the list of sources to use, if main target rule is invoked
# with 'sources'. If there are any objects in 'sources', they are treated
# as main target instances, and WRITEME.

View File

@@ -28,7 +28,7 @@ class make-target-class : basic-target
self.make-rule = $(make-rule) ;
}
rule construct ( source-targets * : property-set )
rule construct ( name : source-targets * : property-set )
{
local t = [ new file-target $(self.name:S=) : [ type.type $(self.name) ]
: $(self.project) ] ;

View File

@@ -104,7 +104,7 @@ class stage-target-class : basic-target
return $(targets[2-]) ;
}
rule construct ( source-targets * : property-set )
rule construct ( name : source-targets * : property-set )
{
local name = [ $(property-set).get <name> ] ;
if $(name) && $(source-targets[2])

View File

@@ -120,7 +120,7 @@ class stlport-target-class : basic-target
}
rule construct ( source-targets * : property-set )
rule construct ( name : source-targets * : property-set )
{
# Deduce the name of stlport library, based on toolset and
# debug setting.

View File

@@ -51,7 +51,7 @@ class symlink-targets : basic-target
self.virtual-targets = ;
}
rule construct ( source-targets * : property-set )
rule construct ( name : source-targets * : property-set )
{
local i = 1 ;
for local t in $(source-targets)