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

Optimize the virtual-target.actual-basename rule.

[SVN r26577]
This commit is contained in:
Vladimir Prus
2004-12-23 08:17:52 +00:00
parent 21b0be6bfc
commit e61247f43e
4 changed files with 96 additions and 52 deletions

View File

@@ -32,6 +32,7 @@ class property-set
import property-set ;
import property ;
import set ;
import path ;
rule __init__ ( raw-properties * )
{
@@ -230,6 +231,40 @@ class property-set
return $(self.as-path) ;
}
rule target-path ( )
{
if ! $(self.target-path)
{
# The <location> feature can be used to explicitly
# change the location of generated targetsv
local l = [ get <location> ] ;
if $(l)
{
self.target-path = $(l) ;
}
else
{
local p = [ as-path ] ;
# Really, an ugly hack. Boost regression test system requires
# specific target paths, and it seems that changing it to handle
# other directory layout is really hard. For that reason,
# we teach V2 to do the things regression system requires.
# The value o '<location-prefix>' is predended to the path.
local prefix = [ get <location-prefix> ] ;
if $(prefix)
{
self.target-path = "." [ path.join $(prefix) $(p) ] ;
}
else
{
self.target-path = "." $(p) ;
}
}
}
return $(self.target-path) ;
}
rule add ( ps )
{
if ! $(self.added.$(ps))

View File

@@ -200,7 +200,7 @@ class project-target : abstract-target
self.location = [ project.attribute $(project-module) location ] ;
self.requirements = $(requirements) ;
self.default-build = $(default-build) ;
if $(parent-project)
{
inherit $(parent-project) ;
@@ -218,7 +218,22 @@ class project-target : abstract-target
{
return [ project.attribute $(self.project-module) $(attribute) ] ;
}
rule build-dir ( )
{
if ! $(self.build-dir)
{
self.build-dir = [ get build-dir ] ;
if ! $(self.build-dir)
{
self.build-dir = [ path.join
[ $(self.project).get location ]
bin
] ;
}
}
return $(self.build-dir) ;
}
# Generates all possible targets contained in this project.
rule generate ( property-set * )

View File

@@ -241,7 +241,7 @@ rule change-generated-target-suffix ( type : properties * : suffix )
# Returns suffix that should be used when generating target of 'type',
# with the specified properties. If not suffix were specified for
# 'type', returns suffix for base type, if any.
rule generated-target-suffix ( type : properties * )
rule generated-target-suffix-real ( type : properties * )
{
local result ;
local found ;
@@ -264,6 +264,28 @@ rule generated-target-suffix ( type : properties * )
return $(result) ;
}
rule generated-target-suffix ( type : property-set )
{
local key = .gts.$(type).$(property-set) ;
local v = $($(key)) ;
if ! $(v)
{
v = [ generated-target-suffix-real $(type)
: [ $(property-set).raw ] ] ;
if ! $(v)
{
v = none ;
}
$(key) = $(v) ;
}
if $(v) != none
{
return $(v) ;
}
}
# Returns file type given it's name. If there are several dots in filename,
# tries each suffix. E.g. for name of "file.so.1.2" suffixes "2", "1", and
# "so" will be tried.

View File

@@ -231,14 +231,15 @@ class abstract-file-target : virtual-target
{
if $(self.type)
{
local properties ;
# CONSIDER: is it ever possible that self.action is not defined?
# It theory, only possible for source files with no
# suffix at all.
if $(self.action)
{
local ps = [ $(self.action).properties ] ;
properties = [ $(ps).raw ] ;
}
self.suffix = [ type.generated-target-suffix $(self.type) :
$(properties) ] ;
local ps = [ $(self.action).properties ] ;
self.suffix = [ type.generated-target-suffix $(self.type) :
$(ps) ] ;
}
}
}
@@ -496,34 +497,21 @@ class file-target : abstract-file-target
{
if $(self.action)
{
# The <location> feature can be used to explicitly
# change the location of generated targetsv
local p = [ $(self.action).properties ] ;
local l = [ $(p).get <location> ] ;
if $(l)
{
self.path = [ path.native $(l) ] ;
local p = [ $(self.action).properties ] ;
local path = [ $(p).target-path ] ;
if $(path[1]) = "."
{
# Indicates that the path is relative to
# build dir.
path = [ path.root $(path[2])
[ $(self.project).build-dir ] ] ;
}
else
{
local build-dir = [ $(self.project).get build-dir ] ;
if ! $(build-dir)
{
build-dir = [ path.join
[ $(self.project).get location ]
bin
] ;
}
local path = [ path.join
$(build-dir)
[ $(self.action).path ]
] ;
# Store the computed path, so that it's not recomputed
# any more
self.path = [ path.native $(path) ] ;
}
# Store the computed path, so that it's not recomputed
# any more
self.path = [ path.native $(path) ] ;
}
}
return $(self.path) ;
@@ -675,22 +663,6 @@ class action
actualize-source-type $(sources) : $(property-set) ] ;
}
rule path ( )
{
local p = [ $(self.properties).as-path ] ;
# Really, an ugly hack. Boost regression test system requires
# specific target paths, and it seems that changing it to handle
# other directory layout is really hard. For that reason,
# we teach V2 to do the things regression system requires.
# The value o '<location-prefix>' is predended to the path.
local prefix = [ $(self.properties).get <location-prefix> ] ;
if $(prefix)
{
p = [ path.join $(prefix) $(p) ] ;
}
return $(p) ;
}
# Determined real properties when trying building with 'properties'.
# This is last chance to fix properties, for example to adjust includes
# to get generated headers correctly. Default implementation returns