|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56042 - in trunk/tools/build/v2: . build test tools util
From: ghost_at_[hidden]
Date: 2009-09-05 08:44:30
Author: vladimir_prus
Date: 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
New Revision: 56042
URL: http://svn.boost.org/trac/boost/changeset/56042
Log:
Reset everyting back to revision 56032.
My partial reverts of things appear to be creating bigger mess.
Removed:
trunk/tools/build/v2/to_merge.sh
Text files modified:
trunk/tools/build/v2/build-system.jam | 12
trunk/tools/build/v2/build/alias.jam | 83 +-
trunk/tools/build/v2/build/feature.jam | 914 ++++++++++++++++++++-------------------
trunk/tools/build/v2/build/generators.jam | 6
trunk/tools/build/v2/build/project.jam | 111 ++--
trunk/tools/build/v2/build/property.jam | 9
trunk/tools/build/v2/build/targets.jam | 88 ++-
trunk/tools/build/v2/build/type.jam | 109 ++--
trunk/tools/build/v2/build/virtual-target.jam | 121 ++--
trunk/tools/build/v2/test/project_test3.py | 1
trunk/tools/build/v2/tools/builtin.jam | 52 +-
trunk/tools/build/v2/tools/cast.jam | 64 +-
trunk/tools/build/v2/tools/make.jam | 9
trunk/tools/build/v2/tools/testing.jam | 59 +-
trunk/tools/build/v2/util/path.jam | 51 +-
15 files changed, 869 insertions(+), 820 deletions(-)
Modified: trunk/tools/build/v2/build-system.jam
==============================================================================
--- trunk/tools/build/v2/build-system.jam (original)
+++ trunk/tools/build/v2/build-system.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -91,8 +91,8 @@
# Returns the location of the build system. The primary use case is building
-# Boost where it's sometimes needed to get the location of other components
-# (e.g. BoostBook files) and it's convenient to use locations relative to the
+# Boost where it is sometimes needed to get the location of other components
+# (e.g. BoostBook files) and it is convenient to use locations relative to the
# Boost Build path.
#
rule location ( )
@@ -139,7 +139,7 @@
local targets-to-clean ;
for local t in $(.results-of-main-targets)
{
- # Don't include roots or sources.
+ # Do not include roots or sources.
targets-to-clean += [ virtual-target.traverse $(t) ] ;
}
targets-to-clean = [ sequence.unique $(targets-to-clean) ] ;
@@ -170,8 +170,8 @@
# Given a target id, try to find and return the corresponding target. This is
-# only invoked when there's no Jamfile in ".". This code somewhat duplicates
-# code in project-target.find but we can't reuse that code without a
+# only invoked when there is no Jamfile in ".". This code somewhat duplicates
+# code in project-target.find but we can not reuse that code without a
# project-targets instance.
#
local rule find-target ( target-id )
@@ -673,7 +673,7 @@
if ! $(t)
{
ECHO "notice: could not find main target" $(id) ;
- ECHO "notice: assuming it's a name of file to create." ;
+ ECHO "notice: assuming it is a name of file to create." ;
explicitly-requested-files += $(id) ;
}
else
Modified: trunk/tools/build/v2/build/alias.jam
==============================================================================
--- trunk/tools/build/v2/build/alias.jam (original)
+++ trunk/tools/build/v2/build/alias.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -1,72 +1,73 @@
-# Copyright 2003, 2004, 2006 Vladimir Prus
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+# Copyright 2003, 2004, 2006 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
-# This module defines the 'alias' rule and associated class.
+# This module defines the 'alias' rule and the associated target class.
#
-# Alias is just a main target which returns its source targets without any
-# processing. For example::
+# Alias is just a main target which returns its source targets without any
+# processing. For example:
#
-# alias bin : hello test_hello ;
-# alias lib : helpers xml_parser ;
+# alias bin : hello test_hello ;
+# alias lib : helpers xml_parser ;
#
-# Another important use of 'alias' is to conveniently group source files::
+# Another important use of 'alias' is to conveniently group source files:
#
-# alias platform-src : win.cpp : <os>NT ;
-# alias platform-src : linux.cpp : <os>LINUX ;
-# exe main : main.cpp platform-src ;
-#
-# Lastly, it's possible to create local alias for some target, with different
-# properties::
+# alias platform-src : win.cpp : <os>NT ;
+# alias platform-src : linux.cpp : <os>LINUX ;
+# exe main : main.cpp platform-src ;
#
-# alias big_lib : : @/external_project/big_lib/<link>static ;
+# Lastly, it is possible to create a local alias for some target, with different
+# properties:
+#
+# alias big_lib : : @/external_project/big_lib/<link>static ;
#
-import targets ;
import "class" : new ;
-import errors : error ;
import project ;
import property-set ;
+import targets ;
+
-class alias-target-class : basic-target
+class alias-target-class : basic-target
{
- rule __init__ ( name : project : sources * : requirements *
+ rule __init__ ( name : project : sources * : requirements *
: default-build * : usage-requirements * )
{
- basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements)
- : $(default-build) : $(usage-requirements) ;
+ basic-target.__init__ $(name) : $(project) : $(sources) :
+ $(requirements) : $(default-build) : $(usage-requirements) ;
}
-
+
rule construct ( name : source-targets * : property-set )
{
return [ property-set.empty ] $(source-targets) ;
- }
-
- rule compute-usage-requirements ( subvariant )
+ }
+
+ rule compute-usage-requirements ( subvariant )
{
local base = [ basic-target.compute-usage-requirements $(subvariant) ] ;
- # Add source's usage requirement. If we don't do this, "alias" does not
- # look like 100% alias.
return [ $(base).add [ $(subvariant).sources-usage-requirements ] ] ;
}
-
}
-# Declares the 'alias' target. It will build sources, and return them unaltered.
-rule alias ( name : sources * : requirements * : default-build * : usage-requirements * )
+
+# Declares the 'alias' target. It will process its sources virtual-targets by
+# returning them unaltered as its own constructed virtual-targets.
+#
+rule alias ( name : sources * : requirements * : default-build * :
+ usage-requirements * )
{
local project = [ project.current ] ;
-
+
targets.main-target-alternative
- [ new alias-target-class $(name) : $(project)
- : [ targets.main-target-sources $(sources) : $(name) : no-renaming ]
- : [ targets.main-target-requirements $(requirements) : $(project) ]
- : [ targets.main-target-default-build $(default-build) : $(project) ]
- : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ]
- ] ;
+ [ new alias-target-class $(name) : $(project)
+ : [ targets.main-target-sources $(sources) : $(name) : no-renaming ]
+ : [ targets.main-target-requirements $(requirements) : $(project) ]
+ : [ targets.main-target-default-build $(default-build) : $(project)
+ ]
+ : [ targets.main-target-usage-requirements $(usage-requirements) :
+ $(project) ]
+ ] ;
}
-IMPORT $(__name__) : alias : : alias ;
-
-
+IMPORT $(__name__) : alias : : alias ;
Modified: trunk/tools/build/v2/build/feature.jam
==============================================================================
--- trunk/tools/build/v2/build/feature.jam (original)
+++ trunk/tools/build/v2/build/feature.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -1,52 +1,53 @@
-# Copyright 2001, 2002, 2003 Dave Abrahams
-# Copyright 2002, 2006 Rene Rivera
-# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+# Copyright 2001, 2002, 2003 Dave Abrahams
+# Copyright 2002, 2006 Rene Rivera
+# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+import assert : * ;
import "class" : * ;
-
-import errors : error lol->list ;
-import sequence ;
+import errors : lol->list ;
+import indirect ;
+import modules ;
import regex ;
+import sequence ;
import set ;
import utility ;
-import modules indirect ;
-import assert : * ;
+
local rule setup ( )
{
.all-attributes =
-
- implicit
- executed
- composite
- optional
- symmetric
- free
- incidental
- path
- dependency
- propagated
- link-incompatible
- subfeature
- order-sensitive
- ;
+ implicit
+ composite
+ optional
+ symmetric
+ free
+ incidental
+ path
+ dependency
+ propagated
+ link-incompatible
+ subfeature
+ order-sensitive
+ ;
.all-features = ;
- .all-subfeatures = ; # non-subfeatures
- .all-top-features = ; # non-subfeatures
+ .all-subfeatures = ;
+ .all-top-features = ; # non-subfeatures
.all-implicit-values = ;
}
setup ;
-# prepare a fresh space to test in by moving all global variable
-# settings into the given temporary module and erasing them here.
+
+# Prepare a fresh space to test in by moving all global variable settings into
+# the given temporary module and erasing them here.
+#
rule prepare-test ( temp-module )
{
DELETE_MODULE $(temp-module) ;
-
- # transfer globals to temp-module
+
+ # Transfer globals to temp-module.
for local v in [ VARNAMES feature ]
{
if [ MATCH (\\.) : $(v) ]
@@ -58,11 +59,13 @@
setup ;
}
-# clear out all global variables and recover all variables from the
-# given temporary module
+
+# Clear out all global variables and recover all variables from the given
+# temporary module.
+#
rule finish-test ( temp-module )
{
- # clear globals
+ # Clear globals.
for local v in [ VARNAMES feature ]
{
if [ MATCH (\\.) : $(v) ]
@@ -70,7 +73,7 @@
$(v) = ;
}
}
-
+
for local v in [ VARNAMES $(temp-module) ]
{
$(v) = [ modules.peek $(temp-module) : $(v) ] ;
@@ -79,33 +82,33 @@
}
-# Transform features by bracketing any elements which aren't already
-# bracketed by "<>"
+# Transform features by bracketing any elements which are not already bracketed
+# by "<>".
+#
local rule grist ( features * )
{
local empty = "" ;
- local r = $(empty:G=$(features)) ;
- return $(r) ;
+ return $(empty:G=$(features)) ;
}
-empty = "" ;
-# declare a new feature with the given name, values, and attributes.
-rule feature (
- name # feature name
- : values * # the allowable values - may be extended later with feature.extend
- : attributes * # The feature's attributes (e.g. implicit, free, propagated...)
+# Declare a new feature with the given name, values, and attributes.
+#
+rule feature (
+ name # Feature name.
+ : values * # Allowable values - may be extended later using feature.extend.
+ : attributes * # Feature attributes (e.g. implicit, free, propagated...).
)
{
name = [ grist $(name) ] ;
local error ;
- # if there are any unknown attributes...
+ # Check for any unknown attributes.
if ! ( $(attributes) in $(.all-attributes) )
{
error = unknown attributes:
- [ set.difference $(attributes) : $(.all-attributes) ] ;
+ [ set.difference $(attributes) : $(.all-attributes) ] ;
}
else if $(name) in $(.all-features)
{
@@ -116,24 +119,23 @@
error = free features cannot also be implicit ;
}
else if free in $(attributes) && propagated in $(attributes)
- {
+ {
error = free features cannot be propagated ;
- }
-
- else
+ }
+ else
{
local m = [ MATCH (.*=.*) : $(values) ] ;
if $(m[1])
{
error = "feature value may not contain '='" ;
- }
+ }
}
-
+
if $(error)
{
- error $(error)
- : "in" feature declaration:
- : feature [ lol->list $(1) : $(2) : $(3) ] ;
+ errors.error $(error)
+ : "in" feature declaration:
+ : feature [ lol->list $(1) : $(2) : $(3) ] ;
}
$(name).values ?= ;
@@ -150,11 +152,12 @@
{
.all-top-features += $(name) ;
}
- extend $(name) : $(values) ;
+ extend $(name) : $(values) ;
}
-# set default value of the given feature, overriding any previous
-# default.
+
+# Sets the default value of the given feature, overriding any previous default.
+#
rule set-default ( feature : value )
{
local f = [ grist $(feature) ] ;
@@ -174,14 +177,15 @@
}
if ! $(value) in $($(f).values)
{
- errors.error "The specified default value, '$(value)' is invalid"
+ errors.error "The specified default value, '$(value)' is invalid"
: "allowed values are: " $($(f).values) ;
- }
+ }
$(f).default = $(value) ;
}
-# return the default property values for the given features.
+# Returns the default property values for the given features.
+#
rule defaults ( features * )
{
local result ;
@@ -200,7 +204,9 @@
return $(result) ;
}
-# returns true iff all elements of names are valid features.
+
+# Returns true iff all 'names' elements are valid features.
+#
rule valid ( names + )
{
if $(names) in $(.all-features)
@@ -209,31 +215,36 @@
}
}
-# return the attibutes of the given feature
+
+# Returns the attibutes of the given feature.
+#
rule attributes ( feature )
{
return $($(:E=:G=$(feature)).attributes) ;
}
-# return the values of the given feature
+
+# Returns the values of the given feature.
+#
rule values ( feature )
{
return $($(:E=:G=$(feature)).values) ;
}
-# returns true iff 'value-string' is a value-string of an implicit feature
+
+# Returns true iff 'value-string' is a value-string of an implicit feature.
+#
rule is-implicit-value ( value-string )
{
local v = [ regex.split $(value-string) - ] ;
local failed ;
- if ! $(v[1]) in $(.all-implicit-values)
+ if ! $(v[1]) in $(.all-implicit-values)
{
failed = true ;
}
- else
+ else
{
local feature = $($(v[1]).implicit-feature) ;
-
for local subvalue in $(v[2-])
{
if ! [ find-implied-subfeature $(feature) $(subvalue) : $(v[1]) ]
@@ -242,82 +253,91 @@
}
}
}
-
- if ! $(failed)
+
+ if ! $(failed)
{
return true ;
}
}
-# return the implicit feature associated with the given implicit value.
+
+# Returns the implicit feature associated with the given implicit value.
+#
rule implied-feature ( implicit-value )
{
local components = [ regex.split $(implicit-value) "-" ] ;
-
+
local feature = $($(components[1]).implicit-feature) ;
if ! $(feature)
{
- error \"$(implicit-value)\" is not a value of an implicit feature ;
- feature = "" ; # keep testing happy; it expects a result.
+ errors.error \"$(implicit-value)\" is not a value of an implicit feature ;
+ feature = "" ; # Keep testing happy; it expects a result.
}
return $(feature) ;
}
+
local rule find-implied-subfeature ( feature subvalue : value-string ? )
{
- # feature should be of the form <feature-name>
+ # Feature should be of the form <feature-name>.
if $(feature) != $(feature:G)
{
- error invalid feature $(feature) ;
+ errors.error invalid feature $(feature) ;
}
return $($(feature)$(value-string:E="")<>$(subvalue).subfeature) ;
}
-# Given a feature and a value of one of its subfeatures, find the name
-# of the subfeature. If value-string is supplied, looks for implied
-# subfeatures that are specific to that value of feature
-rule implied-subfeature (
- feature # The main feature name
- subvalue # The value of one of its subfeatures
- : value-string ? # The value of the main feature
+
+# Given a feature and a value of one of its subfeatures, find the name of the
+# subfeature. If value-string is supplied, looks for implied subfeatures that
+# are specific to that value of feature
+#
+rule implied-subfeature (
+ feature # The main feature name.
+ subvalue # The value of one of its subfeatures.
+ : value-string ? # The value of the main feature.
)
{
local subfeature = [ find-implied-subfeature $(feature) $(subvalue)
- : $(value-string) ] ;
-
+ : $(value-string) ] ;
if ! $(subfeature)
{
value-string ?= "" ;
- error \"$(subvalue)\" is not a known subfeature value of
- $(feature)$(value-string) ;
+ errors.error \"$(subvalue)\" is not a known subfeature value of
+ $(feature)$(value-string) ;
}
-
return $(subfeature) ;
}
-# generate an error if the feature is unknown
+
+# Generate an error if the feature is unknown.
+#
local rule validate-feature ( feature )
{
if ! $(feature) in $(.all-features)
{
- error unknown feature \"$(feature)\" ;
+ errors.error unknown feature \"$(feature)\" ;
}
}
-# Given a feature and value, or just a value corresponding to an
-# implicit feature, returns a property set consisting of all component
-# subfeatures and their values. For example:
+
+# Given a feature and its value or just a value corresponding to an implicit
+# feature, returns a property set consisting of all component subfeatures and
+# their values. For example all the following calls:
#
-# expand-subfeatures <toolset>gcc-2.95.2-linux-x86
-# -> <toolset>gcc <toolset-version>2.95.2 <toolset-os>linux <toolset-cpu>x86
+# expand-subfeatures-aux <toolset>gcc-2.95.2-linux-x86
+# expand-subfeatures-aux gcc-2.95.2-linux-x86
#
-# equivalent to:
-# expand-subfeatures gcc-2.95.2-linux-x86
-local rule expand-subfeatures-aux (
- feature ? # The name of the feature, or empty if value corresponds to an implicit property
- : value # The value of the feature.
- : dont-validate ? # If set, no validation of value string will be done
+# return:
+#
+# <toolset>gcc <toolset-version>2.95.2 <toolset-os>linux <toolset-cpu>x86
+#
+local rule expand-subfeatures-aux (
+ feature ? # Feature name or empty if value corresponds to an
+ # implicit property.
+ : value # Feature value.
+ : dont-validate ? # If set, no value string validation will be done.
)
{
if $(feature)
@@ -334,31 +354,32 @@
validate-feature $(feature) ;
}
if ! $(dont-validate)
- {
+ {
validate-value-string $(feature) $(value) ;
}
-
+
local components = [ regex.split $(value) "-" ] ;
-
- # get the top-level feature's value
+
+ # Get the top-level feature's value.
local value = $(components[1]:G=) ;
local result = $(components[1]:G=$(feature)) ;
-
+
local subvalues = $(components[2-]) ;
while $(subvalues)
{
- local subvalue = $(subvalues[1]) ; # pop the head off of subvalues
+ local subvalue = $(subvalues[1]) ; # Pop the head off of subvalues.
subvalues = $(subvalues[2-]) ;
-
- local subfeature = [ find-implied-subfeature $(feature) $(subvalue) : $(value) ] ;
-
- # If no subfeature was found, reconstitute the value string and use that
+
+ local subfeature = [ find-implied-subfeature $(feature) $(subvalue) :
+ $(value) ] ;
+
+ # If no subfeature was found reconstitute the value string and use that.
if ! $(subfeature)
{
result = $(components:J=-) ;
result = $(result:G=$(feature)) ;
- subvalues = ; # stop looping
+ subvalues = ; # Stop looping.
}
else
{
@@ -366,25 +387,27 @@
result += $(subvalue:G=$(f)-$(subfeature)) ;
}
}
-
+
return $(result) ;
}
-# Make all elements of properties corresponding to implicit features
-# explicit, and express all subfeature values as separate properties
-# in their own right. For example, the property
+
+# Make all elements of properties corresponding to implicit features explicit,
+# and express all subfeature values as separate properties in their own right.
+# For example, all of the following properties
#
# gcc-2.95.2-linux-x86
+# <toolset>gcc-2.95.2-linux-x86
#
# might expand to
#
# <toolset>gcc <toolset-version>2.95.2 <toolset-os>linux <toolset-cpu>x86
#
-rule expand-subfeatures (
- properties * # property set with elements of the form
- # <feature>value-string or just value-string in the
- # case of implicit features.
- : dont-validate ?
+rule expand-subfeatures (
+ properties * # Property set with elements of the form
+ # <feature>value-string or just value-string in the case
+ # of implicit features.
+ : dont-validate ?
)
{
local result ;
@@ -392,18 +415,20 @@
{
# Don't expand subfeatures in subfeatures
if ! [ MATCH "(:)" : $(p:G) ]
- {
+ {
result += [ expand-subfeatures-aux $(p:G) : $(p:G=) : $(dont-validate) ] ;
}
else
{
result += $(p) ;
- }
+ }
}
return $(result) ;
}
+
# Helper for extend, below. Handles the feature case.
+#
local rule extend-feature ( feature : values * )
{
feature = [ grist $(feature) ] ;
@@ -414,7 +439,7 @@
{
if $($(v).implicit-feature)
{
- error $(v) is already associated with the \"$($(v).implicit-feature)\" feature ;
+ errors.error $(v) is already associated with the \"$($(v).implicit-feature)\" feature ;
}
$(v).implicit-feature = $(feature) ;
}
@@ -423,23 +448,25 @@
}
if ! $($(feature).values)
{
- # This is the first value specified for this feature,
- # take it as default value
+ # This is the first value specified for this feature so make it be the
+ # default.
$(feature).default = $(values[1]) ;
- }
+ }
$(feature).values += $(values) ;
}
+
# Checks that value-string is a valid value-string for the given feature.
+#
rule validate-value-string ( feature value-string )
-{
- if ! (
- free in $($(feature).attributes)
- || ( $(value-string) in $(feature).values )
+{
+ if ! (
+ free in $($(feature).attributes)
+ || ( $(value-string) in $(feature).values )
)
{
local values = $(value-string) ;
-
+
if $($(feature).subfeatures)
{
if ! ( $(value-string) in $($(feature).subfeatures) ) {
@@ -449,38 +476,34 @@
if ! ( $(values[1]) in $($(feature).values) ) &&
- # An empty value is allowed for optional features
- ( $(values[1]) || ! ( optional in $($(feature).attributes) ) )
+ # An empty value is allowed for optional features.
+ ( $(values[1]) || ! ( optional in $($(feature).attributes) ) )
{
- error \"$(values[1])\" is not a known value of feature $(feature)
- : legal values: \"$($(feature).values)\" ;
+ errors.error \"$(values[1])\" is not a known value of feature $(feature)
+ : legal values: \"$($(feature).values)\" ;
}
for local v in $(values[2-])
{
- # this will validate any subfeature values in value-string
+ # This will validate any subfeature values in value-string.
implied-subfeature $(feature) $(v) : $(values[1]) ;
}
}
}
+
# A helper that computes:
-# * the name(s) of the module-local variable(s) used to record the
-# correspondence between subvalue(s) and a subfeature
-#
-# * the value of that variable when such a subfeature/subvalue has
-# been defined
+# * name(s) of module-local variable(s) used to record the correspondence
+# between subvalue(s) and a subfeature
+# * value of that variable when such a subfeature/subvalue has been defined and
+# returns a list consisting of the latter followed by the former.
#
-# Returns a list consisting of the latter followed by the former
-local rule subvalue-var (
- feature # Main feature name
-
- value-string ? # If supplied, specifies a specific value of the
- # main feature for which the subfeature values
- # are valid
-
- : subfeature # The name of the subfeature
- : subvalues * # The subfeature values
+local rule subvalue-var (
+ feature # Main feature name.
+ value-string ? # If supplied, specifies a specific value of the main
+ # feature for which the subfeature values are valid.
+ : subfeature # Subfeature name.
+ : subvalues * # Subfeature values.
)
{
feature = [ grist $(feature) ] ;
@@ -496,68 +519,69 @@
$(feature)$(value-string:E="")<>$(subvalues).subfeature ;
}
-# Extends the given subfeature with the subvalues. If the optional
-# value-string is provided, the subvalues are only valid for the given
-# value of the feature. Thus, you could say that
-# <target-platform>mingw is specifc to <toolset>gcc-2.95.2 as follows:
+
+# Extends the given subfeature with the subvalues. If the optional value-string
+# is provided, the subvalues are only valid for the given value of the feature.
+# Thus, you could say that <target-platform>mingw is specific to
+# <toolset>gcc-2.95.2 as follows:
#
# extend-subfeature toolset gcc-2.95.2 : target-platform : mingw ;
#
-rule extend-subfeature (
- feature # The feature whose subfeature is being extended
-
- value-string ? # If supplied, specifies a specific value of the
- # main feature for which the new subfeature values
- # are valid
-
- : subfeature # The name of the subfeature
- : subvalues * # The additional values of the subfeature being defined.
+rule extend-subfeature (
+ feature # The feature whose subfeature is being extended.
+
+ value-string ? # If supplied, specifies a specific value of the main
+ # feature for which the new subfeature values are valid.
+
+ : subfeature # Subfeature name.
+ : subvalues * # Additional subfeature values.
)
{
- local subfeature-vars = [
- subvalue-var $(feature) $(value-string) : $(subfeature) : $(subvalues) ] ;
-
+ local subfeature-vars = [ subvalue-var $(feature) $(value-string)
+ : $(subfeature) : $(subvalues) ] ;
+
local f = [ utility.ungrist [ grist $(feature) ] ] ;
extend $(f)-$(subfeature-vars[1]) : $(subvalues) ;
-
- # provide a way to get from the given feature or property and
- # subfeature value to the subfeature name.
+
+ # Provide a way to get from the given feature or property and subfeature
+ # value to the subfeature name.
$(subfeature-vars[2-]) = $(subfeature-vars[1]) ;
}
-# Returns true iff the subvalues are valid for the feature. When the
-# optional value-string is provided, returns true iff the subvalues
-# are valid for the given value of the feature.
+
+# Returns true iff the subvalues are valid for the feature. When the optional
+# value-string is provided, returns true iff the subvalues are valid for the
+# given value of the feature.
+#
rule is-subvalue ( feature : value-string ? : subfeature : subvalue )
{
- local subfeature-vars = [
- subvalue-var $(feature) $(value-string) : $(subfeature) : $(subvalue) ] ;
-
- if $($(subfeature-vars[2])) = $(subfeature-vars[1])
+ local subfeature-vars = [ subvalue-var $(feature) $(value-string)
+ : $(subfeature) : $(subvalue) ] ;
+
+ if $($(subfeature-vars[2])) = $(subfeature-vars[1])
{
return true ;
}
}
+
# Can be called three ways:
#
# 1. extend feature : values *
# 2. extend <feature> subfeature : values *
# 3. extend <feature>value-string subfeature : values *
#
-# * Form 1 adds the given values to the given feature
-# * Forms 2 and 3 add subfeature values to the given feature
-# * Form 3 adds the subfeature values as specific to the given
-# property value-string.
+# * Form 1 adds the given values to the given feature.
+# * Forms 2 and 3 add subfeature values to the given feature.
+# * Form 3 adds the subfeature values as specific to the given property
+# value-string.
#
rule extend ( feature-or-property subfeature ? : values * )
{
- local
- feature # If a property was specified this is its feature
- value-string # E.G., the gcc-2.95-2 part of <toolset>gcc-2.95.2
- ;
+ local feature ; # If a property was specified this is its feature.
+ local value-string ; # E.g., the gcc-2.95-2 part of <toolset>gcc-2.95.2.
- # if a property was specified
+ # If a property was specified.
if $(feature-or-property:G) && $(feature-or-property:G=)
{
# Extract the feature and value-string, if any.
@@ -569,140 +593,149 @@
feature = [ grist $(feature-or-property) ] ;
}
- # Dispatch to the appropriate handler
+ # Dispatch to the appropriate handler.
if $(subfeature)
{
- extend-subfeature $(feature) $(value-string)
- : $(subfeature) : $(values) ;
+ extend-subfeature $(feature) $(value-string) : $(subfeature)
+ : $(values) ;
}
else
{
- # If no subfeature was specified, we didn't expect to see a
- # value-string
+ # If no subfeature was specified, we do not expect to see a
+ # value-string.
if $(value-string)
{
- error can only be specify a property as the first argument
- when extending a subfeature
- : usage:
- : " extend" feature ":" values...
- : " | extend" <feature>value-string subfeature ":" values...
- ;
+ errors.error can only specify a property as the first argument when
+ extending a subfeature
+ : usage:
+ : " extend" feature ":" values...
+ : " | extend" <feature>value-string subfeature ":" values...
+ ;
}
extend-feature $(feature) : $(values) ;
}
}
+
local rule get-subfeature-name ( subfeature value-string ? )
{
local prefix = $(value-string): ;
return $(prefix:E="")$(subfeature) ;
}
-# Declares a subfeature
-rule subfeature (
- feature # Root feature that is not a subfeature
- value-string ? # A value-string specifying which feature or
- # subfeature values this subfeature is specific to,
- # if any
-
- : subfeature # The name of the subfeature being declared
- : subvalues * # The allowed values of this subfeature
- : attributes * # The attributes of the subfeature
+
+# Declares a subfeature.
+#
+rule subfeature (
+ feature # Root feature that is not a subfeature.
+ value-string ? # A value-string specifying which feature or subfeature
+ # values this subfeature is specific to, if any.
+ : subfeature # The name of the subfeature being declared.
+ : subvalues * # The allowed values of this subfeature.
+ : attributes * # The attributes of the subfeature.
)
{
feature = [ grist $(feature) ] ;
validate-feature $(feature) ;
-
- # Add grist to the subfeature name if a value-string was supplied
+
+ # Add grist to the subfeature name if a value-string was supplied.
local subfeature-name = [ get-subfeature-name $(subfeature) $(value-string) ] ;
-
+
if $(subfeature-name) in $($(feature).subfeatures)
{
- error \"$(subfeature)\" already declared as a subfeature of \"$(feature)\"
- "specific to "$(value-string) ;
+ errors.error \"$(subfeature)\" already declared as a subfeature of \"$(feature)\"
+ "specific to "$(value-string) ;
}
$(feature).subfeatures += $(subfeature-name) ;
-
- # First declare the subfeature as a feature in its own right
+
+ # First declare the subfeature as a feature in its own right.
local f = [ utility.ungrist $(feature) ] ;
feature $(f)-$(subfeature-name) : $(subvalues) : $(attributes) subfeature ;
-
+
# Now make sure the subfeature values are known.
extend-subfeature $(feature) $(value-string) : $(subfeature) : $(subvalues) ;
}
-# Set the components of the given composite property
+
+# Set components of the given composite property.
+#
rule compose ( composite-property : component-properties * )
{
local feature = $(composite-property:G) ;
if ! ( composite in [ attributes $(feature) ] )
{
- error "$(feature)" is not a composite feature ;
+ errors.error "$(feature)" is not a composite feature ;
}
$(composite-property).components ?= ;
if $($(composite-property).components)
{
- error components of "$(composite-property)" already set:
- $($(composite-property).components) ;
+ errors.error components of "$(composite-property)" already set:
+ $($(composite-property).components) ;
}
if $(composite-property) in $(component-properties)
{
- error composite property "$(composite-property)" cannot have itself as a component ;
+ errors.error composite property "$(composite-property)" cannot have itself as a component ;
}
$(composite-property).components = $(component-properties) ;
}
+
local rule expand-composite ( property )
{
return $(property)
- [ sequence.transform expand-composite : $($(property).components) ] ;
+ [ sequence.transform expand-composite : $($(property).components) ] ;
}
-# return all values of the given feature specified by the given property set.
+
+# Return all values of the given feature specified by the given property set.
+#
rule get-values ( feature : properties * )
{
local result ;
-
- feature = $(:E=:G=$(feature)) ; # add <> if necessary.
+
+ feature = $(:E=:G=$(feature)) ; # Add <> if necessary.
for local p in $(properties)
{
if $(p:G) = $(feature)
{
- #~ Use MATCH instead if :G= to get the value, in order to preserve
- #~ the value intact instead of having bjam treat it as a decompossible
- #~ path.
+ # Use MATCH instead of :G= to get the value, in order to preserve
+ # the value intact instead of having bjam treat it as a decomposable
+ # path.
result += [ MATCH ">(.*)" : $(p) ] ;
}
}
return $(result) ;
}
+
rule free-features ( )
{
return $(free.features) ;
}
-# Expand all composite properties in the set so that all components
-# are explicitly expressed.
+
+# Expand all composite properties in the set so that all components are
+# explicitly expressed.
+#
rule expand-composites ( properties * )
{
local explicit-features = $(properties:G) ;
-
local result ;
- # now expand composite features
+
+ # Now expand composite features.
for local p in $(properties)
{
local expanded = [ expand-composite $(p) ] ;
-
+
for local x in $(expanded)
{
if ! $(x) in $(result)
{
local f = $(x:G) ;
-
+
if $(f) in $(free.features)
{
result += $(x) ;
@@ -713,21 +746,21 @@
{
if $(f) in $(result:G)
{
- error expansions of composite features result in conflicting
- values for $(f)
- : values: [ get-values $(f) : $(result) ] $(x:G=)
- : one contributing composite property was $(p) ;
+ errors.error expansions of composite features result
+ in conflicting values for $(f)
+ : values: [ get-values $(f) : $(result) ] $(x:G=)
+ : one contributing composite property was $(p) ;
}
else
{
result += $(x) ;
}
}
- }
+ }
else if $(f) in $(result:G)
{
- error explicitly-specified values of non-free feature
- $(f) conflict :
+ errors.error explicitly-specified values of non-free feature
+ $(f) conflict :
"existing values:" [ get-values $(f) : $(properties) ] :
"value from expanding " $(p) ":" $(x:G=) ;
}
@@ -735,15 +768,17 @@
{
result += $(x) ;
}
- }
+ }
}
}
return $(result) ;
}
-# Return true iff f is an ordinary subfeature of the parent-property's
-# feature, or if f is a subfeature fo the parent-property's feature
-# specific to the parent-property's value
+
+# Return true iff f is an ordinary subfeature of the parent-property's feature,
+# or if f is a subfeature of the parent-property's feature specific to the
+# parent-property's value.
+#
local rule is-subfeature-of ( parent-property f )
{
if subfeature in $($(f).attributes)
@@ -751,10 +786,10 @@
local specific-subfeature = [ MATCH <(.*):(.*)> : $(f) ] ;
if $(specific-subfeature)
{
- # The feature has the form
- # <topfeature-topvalue:subfeature>,
- # e.g. <toolset-msvc:version>
- local feature-value = [ split-top-feature $(specific-subfeature[1]) ] ;
+ # The feature has the form <topfeature-topvalue:subfeature>, e.g.
+ # <toolset-msvc:version>.
+ local feature-value = [ split-top-feature $(specific-subfeature[1])
+ ] ;
if <$(feature-value[1])>$(feature-value[2]) = $(parent-property)
{
return true ;
@@ -762,10 +797,9 @@
}
else
{
- # The feature has the form <topfeature-subfeature>,
- # e.g. <toolset-version>
+ # The feature has the form <topfeature-subfeature>, e.g.
+ # <toolset-version>
local top-sub = [ split-top-feature [ utility.ungrist $(f) ] ] ;
-
if $(top-sub[2]) && <$(top-sub[1])> = $(parent-property:G)
{
return true ;
@@ -774,46 +808,52 @@
}
}
-# as above, for subproperties
+
+# As for is-subfeature-of but for subproperties.
+#
local rule is-subproperty-of ( parent-property p )
{
return [ is-subfeature-of $(parent-property) $(p:G) ] ;
}
-# Given a property, return the subset of features consisting of all
-# ordinary subfeatures of the property's feature, and all specific
-# subfeatures of the property's feature which are conditional on the
-# property's value.
+
+# Given a property, return the subset of features consisting of all ordinary
+# subfeatures of the property's feature, and all specific subfeatures of the
+# property's feature which are conditional on the property's value.
+#
local rule select-subfeatures ( parent-property : features * )
{
return [ sequence.filter is-subfeature-of $(parent-property) : $(features) ] ;
}
-
-# as above, for subproperties
+
+
+# As for select-subfeatures but for subproperties.
+#
local rule select-subproperties ( parent-property : properties * )
{
return [ sequence.filter is-subproperty-of $(parent-property) : $(properties) ] ;
}
-# Given a property set which may consist of composite and implicit
-# properties and combined subfeature values, returns an expanded,
-# normalized property set with all implicit features expressed
-# explicitly, all subfeature values individually expressed, and all
-# components of composite properties expanded. Non-free features
-# directly expressed in the input properties cause any values of
-# those features due to composite feature expansion to be dropped. If
-# two values of a given non-free feature are directly expressed in the
-# input, an error is issued.
+
+# Given a property set which may consist of composite and implicit properties
+# and combined subfeature values, returns an expanded, normalized property set
+# with all implicit features expressed explicitly, all subfeature values
+# individually expressed, and all components of composite properties expanded.
+# Non-free features directly expressed in the input properties cause any values
+# of those features due to composite feature expansion to be dropped. If two
+# values of a given non-free feature are directly expressed in the input, an
+# error is issued.
+#
rule expand ( properties * )
{
local expanded = [ expand-subfeatures $(properties) ] ;
-
return [ expand-composites $(expanded) ] ;
}
-# Helper rule for minimize, below - return true iff property's feature
-# is present in the contents of the variable named by feature-set-var.
+# Helper rule for minimize. Returns true iff property's feature is present in
+# the contents of the variable named by feature-set-var.
+#
local rule in-features ( feature-set-var property )
{
if $(property:G) in $($(feature-set-var))
@@ -822,9 +862,10 @@
}
}
-# Helper for minimize, below - returns the list with
-# the same properties, but where all subfeatures
-# are in the end of the list
+
+# Helper rule for minimize. Returns the list with the same properties, but with
+# all subfeatures moved to the end of the list.
+#
local rule move-subfeatures-to-the-end ( properties * )
{
local x1 ;
@@ -838,53 +879,54 @@
else
{
x1 += $(p) ;
- }
+ }
}
- return $(x1) $(x2) ;
+ return $(x1) $(x2) ;
}
-# Given an expanded property set, eliminate all redundancy: properties
-# which are elements of other (composite) properties in the set will
-# be eliminated. Non-symmetric properties equal to default values will be
-# eliminated, unless the override a value from some composite property.
-# Implicit properties will be expressed without feature
-# grist, and sub-property values will be expressed as elements joined
-# to the corresponding main property.
+# Given an expanded property set, eliminate all redundancy: properties that are
+# elements of other (composite) properties in the set will be eliminated.
+# Non-symmetric properties equal to default values will be eliminated unless
+# they override a value from some composite property. Implicit properties will
+# be expressed without feature grist, and sub-property values will be expressed
+# as elements joined to the corresponding main property.
+#
rule minimize ( properties * )
{
# Precondition checking
local implicits = [ set.intersection $(p:G=) : $(p:G) ] ;
if $(implicits)
{
- error minimize requires an expanded property set, but \"$(implicits[1])\"
- appears to be the value of an un-expanded implicit feature ;
+ errors.error minimize requires an expanded property set, but
+ \"$(implicits[1])\" appears to be the value of an un-expanded
+ implicit feature ;
}
-
- # remove properties implied by composite features
+
+ # Remove properties implied by composite features.
local components = $($(properties).components) ;
local x = [ set.difference $(properties) : $(components) ] ;
-
- # handle subfeatures and implicit features
- x = [ move-subfeatures-to-the-end $(x) ] ;
+
+ # Handle subfeatures and implicit features.
+ x = [ move-subfeatures-to-the-end $(x) ] ;
local result ;
while $(x)
{
local p fullp = $(x[1]) ;
local f = $(p:G) ;
local v = $(p:G=) ;
-
- # eliminate features in implicit properties.
+
+ # Eliminate features in implicit properties.
if implicit in [ attributes $(f) ]
{
p = $(v) ;
}
- # locate all subproperties of $(x[1]) in the property set
+ # Locate all subproperties of $(x[1]) in the property set.
local subproperties = [ select-subproperties $(fullp) : $(x) ] ;
if $(subproperties)
{
- # reconstitute the joined property name
+ # Reconstitute the joined property name.
local sorted = [ sequence.insertion-sort $(subproperties) ] ;
result += $(p)-$(sorted:G="":J=-) ;
@@ -892,16 +934,16 @@
}
else
{
- # eliminate properties whose value is equal to feature's
- # default and which are not symmetric and which do not
- # contradict values implied by composite properties.
-
- # since all component properties of composites in the set
- # have been eliminated, any remaining property whose
- # feature is the same as a component of a composite in the
- # set must have a non-redundant value.
+ # Eliminate properties whose value is equal to feature's default,
+ # which are not symmetric and which do not contradict values implied
+ # by composite properties.
+
+ # Since all component properties of composites in the set have been
+ # eliminated, any remaining property whose feature is the same as a
+ # component of a composite in the set must have a non-redundant
+ # value.
if $(fullp) != [ defaults $(f) ]
- || symmetric in [ attributes $(f) ]
+ || symmetric in [ attributes $(f) ]
|| $(fullp:G) in $(components:G)
{
result += $(p) ;
@@ -913,18 +955,21 @@
return $(result) ;
}
+
# Combine all subproperties into their parent properties
#
-# Requires: for every subproperty, there is a parent property. All
-# features are explicitly expressed.
+# Requires: for every subproperty, there is a parent property. All features are
+# explicitly expressed.
+#
+# This rule probably should not be needed, but build-request.expand-no-defaults
+# is being abused for unintended purposes and it needs help.
#
-# This rule probably shouldn't be needed, but
-# build-request.expand-no-defaults is being abused for unintended
-# purposes and it needs help
rule compress-subproperties ( properties * )
{
- local all-subs matched-subs result ;
-
+ local all-subs ;
+ local matched-subs ;
+ local result ;
+
for local p in $(properties)
{
if ! $(p:G)
@@ -932,15 +977,12 @@
# Expecting fully-gristed properties.
assert.variable-not-empty p:G ;
}
-
-
+
if ! subfeature in $($(p:G).attributes)
{
- local subs = [
- sequence.insertion-sort
- [ sequence.filter is-subproperty-of $(p) : $(properties) ]
- ] ;
-
+ local subs = [ sequence.insertion-sort
+ [ sequence.filter is-subproperty-of $(p) : $(properties) ] ] ;
+
matched-subs += $(subs) ;
local subvalues = -$(subs:G=:J=-) ;
@@ -955,17 +997,17 @@
assert.result true : set.equal $(all-subs) : $(matched-subs) ;
return $(result) ;
}
-
-# given an ungristed string, finds the longest prefix which is a
-# top-level feature name followed by a dash, and return a pair
-# consisting of the parts before and after that dash. More
-# interesting than a simple split because feature names can contain
-# dashes.
+
+
+# Given an ungristed string, finds the longest prefix which is a top-level
+# feature name followed by a dash, and return a pair consisting of the parts
+# before and after that dash. More interesting than a simple split because
+# feature names may contain dashes.
+#
local rule split-top-feature ( feature-plus )
{
local e = [ regex.split $(feature-plus) - ] ;
local f = $(e[1]) ;
-
local v ;
while $(e)
{
@@ -978,45 +1020,49 @@
}
return $(v) ;
}
-
-# Given a set of properties, add default values for features not
-# represented in the set.
-# Note: if there's there's ordinary feature F1 and composite feature
-# F2, which includes some value for F1, and both feature have default values,
-# then the default value of F1 will be added, not the value in F2. This might
-# not be right idea: consider
+
+
+# Given a set of properties, add default values for features not represented in
+# the set.
+#
+# Note: if there's an ordinary feature F1 and a composite feature F2 which
+# includes some value for F1 and both feature have default values then the
+# default value of F1 will be added (as opposed to the value in F2). This might
+# not be the right idea, e.g. consider:
#
# feature variant : debug ... ;
# <variant>debug : .... <runtime-debugging>on
# feature <runtime-debugging> : off on ;
-#
+#
# Here, when adding default for an empty property set, we'll get
#
# <variant>debug <runtime_debugging>off
-#
+#
# and that's kind of strange.
+#
rule add-defaults ( properties * )
{
for local v in $(properties:G=)
{
if $(v) in $(properties)
{
- error add-defaults requires explicitly specified features,
- but \"$(v)\" appears to be the value of an un-expanded implicit feature ;
+ errors.error add-defaults requires explicitly specified features,
+ but \"$(v)\" appears to be the value of an un-expanded implicit
+ feature ;
}
}
# We don't add default for elements with ":" inside. This catches:
# 1. Conditional properties --- we don't want <variant>debug:<define>DEBUG
# to be takes as specified value for <variant>
- # 2. Free properties with ":" in values. We don't care, since free properties
- # don't have defaults.
+ # 2. Free properties with ":" in values. We don't care, since free
+ # properties don't have defaults.
local xproperties = [ MATCH "^([^:]+)$" : $(properties) ] ;
local missing-top = [ set.difference $(.all-top-features) : $(xproperties:G) ] ;
local more = [ defaults $(missing-top) ] ;
properties += $(more) ;
xproperties += $(more) ;
-
- # Add defaults for subfeatures of features which are present
+
+ # Add defaults for subfeatures of features which are present.
for local p in $(xproperties)
{
local s = $($(p:G).subfeatures) ;
@@ -1024,19 +1070,21 @@
local missing-subs = [ set.difference <$(f)-$(s)> : $(properties:G) ] ;
properties += [ defaults [ select-subfeatures $(p) : $(missing-subs) ] ] ;
}
-
+
return $(properties) ;
}
+
# Given a property-set of the form
# v1/v2/...vN-1/<fN>vN/<fN+1>vN+1/...<fM>vM
#
# Returns
# v1 v2 ... vN-1 <fN>vN <fN+1>vN+1 ... <fM>vM
#
-# Note that vN...vM may contain slashes. This is resilient to the
-# substitution of backslashes for slashes, since Jam, unbidden,
-# sometimes swaps slash direction on NT.
+# Note that vN...vM may contain slashes. This needs to be resilient to the
+# substitution of backslashes for slashes, since Jam, unbidden, sometimes swaps
+# slash direction on NT.
+#
rule split ( property-set )
{
local pieces = [ regex.split $(property-set) [\\/] ] ;
@@ -1057,18 +1105,20 @@
return $(result) ;
}
-# tests of module feature
+
+# Tests of module feature.
+#
rule __test__ ( )
{
- # use a fresh copy of the feature module
+ # Use a fresh copy of the feature module.
prepare-test feature-test-temp ;
- # These are local rules and so must be explicitly reimported into
- # the testing module
- import feature : extend-feature validate-feature select-subfeatures ;
-
- import errors : try catch ;
import assert ;
+ import errors : try catch ;
+
+ # These are local rules and so must be explicitly reimported into the
+ # testing module.
+ import feature : extend-feature validate-feature select-subfeatures ;
feature toolset : gcc : implicit ;
feature define : : free ;
@@ -1088,84 +1138,74 @@
{
compose <variant>profile : <variant>profile ;
}
- catch composite property <variant>profile cannot have itself as a component ;
+ catch composite property <variant>profile cannot have itself as a component ;
extend-feature toolset : msvc metrowerks ;
- subfeature toolset gcc : version : 2.95.2 2.95.3 2.95.4
- 3.0 3.0.1 3.0.2 ;
-
+ subfeature toolset gcc : version : 2.95.2 2.95.3 2.95.4 3.0 3.0.1 3.0.2 ;
+
assert.true is-subvalue toolset : gcc : version : 2.95.3 ;
assert.false is-subvalue toolset : gcc : version : 1.1 ;
assert.false is-subvalue toolset : msvc : version : 2.95.3 ;
assert.false is-subvalue toolset : : version : yabba ;
-
+
feature yabba ;
subfeature yabba : version : dabba ;
assert.true is-subvalue yabba : : version : dabba ;
-
-
+
subfeature toolset gcc : platform : linux cygwin : optional ;
-
+
assert.result <toolset-gcc:version>
- : select-subfeatures <toolset>gcc
- : <toolset-gcc:version>
- <toolset-msvc:version>
- <toolset-version>
- <stdlib>
- ;
-
+ : select-subfeatures <toolset>gcc
+ : <toolset-gcc:version>
+ <toolset-msvc:version>
+ <toolset-version>
+ <stdlib> ;
+
subfeature stdlib : version : 3 4 : optional ;
assert.result <stdlib-version>
- : select-subfeatures <stdlib>native
- : <toolset-gcc:version>
- <toolset-msvc:version>
- <toolset-version>
- <stdlib-version>
- ;
-
+ : select-subfeatures <stdlib>native
+ : <toolset-gcc:version>
+ <toolset-msvc:version>
+ <toolset-version>
+ <stdlib-version> ;
+
assert.result <toolset>gcc <toolset-gcc:version>3.0.1
- : expand-subfeatures <toolset>gcc-3.0.1 ;
-
+ : expand-subfeatures <toolset>gcc-3.0.1 ;
+
assert.result <toolset>gcc <toolset-gcc:version>3.0.1 <toolset-gcc:platform>linux
- : expand-subfeatures <toolset>gcc-3.0.1-linux ;
+ : expand-subfeatures <toolset>gcc-3.0.1-linux ;
-
assert.result <toolset>gcc <toolset-gcc:version>3.0.1
- : expand <toolset>gcc <toolset-gcc:version>3.0.1 ;
-
+ : expand <toolset>gcc <toolset-gcc:version>3.0.1 ;
+
assert.result <define>foo=x-y
- : expand-subfeatures <define>foo=x-y ;
+ : expand-subfeatures <define>foo=x-y ;
assert.result <toolset>gcc <toolset-gcc:version>3.0.1
- : expand-subfeatures gcc-3.0.1 ;
-
+ : expand-subfeatures gcc-3.0.1 ;
+
assert.result a c e
- : get-values <x> : <x>a <y>b <x>c <y>d <x>e ;
+ : get-values <x> : <x>a <y>b <x>c <y>d <x>e ;
assert.result <toolset>gcc <toolset-gcc:version>3.0.1
- <variant>debug <define>_DEBUG <optimization>on
- : expand gcc-3.0.1 debug <optimization>on
- ;
-
+ <variant>debug <define>_DEBUG <optimization>on
+ : expand gcc-3.0.1 debug <optimization>on ;
+
assert.result <variant>debug <define>_DEBUG <optimization>on
- : expand debug <optimization>on
- ;
+ : expand debug <optimization>on ;
- assert.result <optimization>on <variant>debug <define>_DEBUG
- : expand <optimization>on debug
- ;
+ assert.result <optimization>on <variant>debug <define>_DEBUG
+ : expand <optimization>on debug ;
assert.result <runtime-link>dynamic <optimization>on
- : defaults <runtime-link> <define> <optimization>
- ;
-
- # make sure defaults is resilient to missing grist.
+ : defaults <runtime-link> <define> <optimization> ;
+
+ # Make sure defaults is resilient to missing grist.
assert.result <runtime-link>dynamic <optimization>on
- : defaults runtime-link define optimization
- ;
-
+ : defaults runtime-link define optimization ;
+
feature dummy : dummy1 dummy2 ;
subfeature dummy : subdummy : x y z : optional ;
@@ -1175,68 +1215,54 @@
assert.result optional : attributes <fu> ;
assert.result optional : attributes fu ;
-
- assert.result <runtime-link>static <define>foobar <optimization>on <toolset>gcc:<define>FOO
- <toolset>gcc <variant>debug <stdlib>native <dummy>dummy1 <toolset-gcc:version>2.95.2
-
- : add-defaults <runtime-link>static <define>foobar
- <optimization>on <toolset>gcc:<define>FOO
- ;
-
- assert.result <runtime-link>static <define>foobar <optimization>on <toolset>gcc:<define>FOO
- <fu>fu1 <toolset>gcc <variant>debug <stdlib>native <dummy>dummy1 <fu-subfu2>q
- <toolset-gcc:version>2.95.2
-
- : add-defaults <runtime-link>static <define>foobar
- <optimization>on <toolset>gcc:<define>FOO <fu>fu1
- ;
-
+
+ assert.result <runtime-link>static <define>foobar <optimization>on
+ <toolset>gcc:<define>FOO <toolset>gcc <variant>debug <stdlib>native
+ <dummy>dummy1 <toolset-gcc:version>2.95.2
+ : add-defaults <runtime-link>static <define>foobar <optimization>on
+ <toolset>gcc:<define>FOO ;
+
+ assert.result <runtime-link>static <define>foobar <optimization>on
+ <toolset>gcc:<define>FOO <fu>fu1 <toolset>gcc <variant>debug
+ <stdlib>native <dummy>dummy1 <fu-subfu2>q <toolset-gcc:version>2.95.2
+ : add-defaults <runtime-link>static <define>foobar <optimization>on
+ <toolset>gcc:<define>FOO <fu>fu1 ;
+
set-default <runtime-link> : static ;
- assert.result <runtime-link>static
- : defaults <runtime-link>
- ;
-
+ assert.result <runtime-link>static : defaults <runtime-link> ;
+
assert.result gcc-3.0.1 debug <optimization>on
- : minimize [ expand gcc-3.0.1 debug <optimization>on <stdlib>native ]
- ;
+ : minimize [ expand gcc-3.0.1 debug <optimization>on <stdlib>native ] ;
assert.result gcc-3.0.1 debug <runtime-link>dynamic
- : minimize [ expand gcc-3.0.1 debug <optimization>off <runtime-link>dynamic ]
- ;
+ : minimize
+ [ expand gcc-3.0.1 debug <optimization>off <runtime-link>dynamic ] ;
assert.result gcc-3.0.1 debug
- : minimize [ expand gcc-3.0.1 debug <optimization>off ]
- ;
+ : minimize [ expand gcc-3.0.1 debug <optimization>off ] ;
assert.result debug <optimization>on
- : minimize [ expand debug <optimization>on ]
- ;
+ : minimize [ expand debug <optimization>on ] ;
assert.result gcc-3.0
- : minimize <toolset>gcc <toolset-gcc:version>3.0
- ;
+ : minimize <toolset>gcc <toolset-gcc:version>3.0 ;
assert.result gcc-3.0
- : minimize <toolset-gcc:version>3.0 <toolset>gcc
- ;
+ : minimize <toolset-gcc:version>3.0 <toolset>gcc ;
assert.result <x>y/z <a>b/c <d>e/f
- : split <x>y/z/<a>b/c/<d>e/f
- ;
+ : split <x>y/z/<a>b/c/<d>e/f ;
assert.result <x>y/z <a>b/c <d>e/f
- : split <x>y\\z\\<a>b\\c\\<d>e\\f
- ;
+ : split <x>y\\z\\<a>b\\c\\<d>e\\f ;
assert.result a b c <d>e/f/g <h>i/j/k
- : split a/b/c/<d>e/f/g/<h>i/j/k
- ;
+ : split a/b/c/<d>e/f/g/<h>i/j/k ;
assert.result a b c <d>e/f/g <h>i/j/k
- : split a\\b\\c\\<d>e\\f\\g\\<h>i\\j\\k
- ;
+ : split a\\b\\c\\<d>e\\f\\g\\<h>i\\j\\k ;
- # test error checking
+ # Test error checking.
try ;
{
@@ -1294,16 +1320,14 @@
{
implied-subfeature <toolset> 3.0.1 ;
}
- catch \"3.0.1\" is not a known subfeature value of
- <toolset> ;
+ catch \"3.0.1\" is not a known subfeature value of <toolset> ;
try ;
{
implied-subfeature <toolset> not-a-version : gcc ;
}
- catch \"not-a-version\" is not a known subfeature value of
- <toolset>gcc ;
+ catch \"not-a-version\" is not a known subfeature value of <toolset>gcc ;
- # leave a clean copy of the features module behind
+ # Leave a clean copy of the features module behind.
finish-test feature-test-temp ;
}
Modified: trunk/tools/build/v2/build/generators.jam
==============================================================================
--- trunk/tools/build/v2/build/generators.jam (original)
+++ trunk/tools/build/v2/build/generators.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -68,11 +68,7 @@
#
rule update-cached-information-with-a-new-type ( type )
{
- # TODO: There really ought be an interface to ask for a direct base target
- # type without having to go through a list of all the base target types.
- local all-base-types = [ type.all-bases $(type) ] ;
- local base-type = $(all-base-types[2]) ;
-
+ local base-type = [ type.base $(type) ] ;
if $(base-type)
{
for local g in $(.vstg-cached-generators)
Modified: trunk/tools/build/v2/build/project.jam
==============================================================================
--- trunk/tools/build/v2/build/project.jam (original)
+++ trunk/tools/build/v2/build/project.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -103,14 +103,13 @@
#
rule load-parent ( location )
{
- local found = [ path.glob-in-parents $(location) :
- $(JAMROOT) $(JAMFILE) ] ;
+ local found = [ path.glob-in-parents $(location) : $(JAMROOT) $(JAMFILE) ] ;
if ! $(found)
{
- ECHO "error: Could not find parent for project at '$(location)'" ;
- ECHO "error: Did not find Jamfile.jam or Jamroot.jam in any parent directory." ;
- EXIT ;
+ ECHO error: Could not find parent for project at '$(location)' ;
+ EXIT error: Did not find Jamfile.jam or Jamroot.jam in any parent
+ directory. ;
}
return [ load $(found[1]:D) ] ;
@@ -153,8 +152,8 @@
if ! $(project-module)
{
- local location = [ path.root
- [ path.make $(name) ] $(current-location) ] ;
+ local location = [ path.root [ path.make $(name) ] $(current-location) ]
+ ;
# If no project is registered for the given location, try to load it.
# First see if we have a Jamfile. If not, then see if we might have a
@@ -220,8 +219,8 @@
{
if ! $(.parent-jamfile.$(dir))
{
- .parent-jamfile.$(dir) =
- [ path.glob-in-parents $(dir) : $(JAMFILE) ] ;
+ .parent-jamfile.$(dir) = [ path.glob-in-parents $(dir) : $(JAMFILE)
+ ] ;
}
jamfile-glob = $(.parent-jamfile.$(dir)) ;
}
@@ -237,7 +236,7 @@
local jamfile-to-load = $(jamfile-glob) ;
# Multiple Jamfiles found in the same place. Warn about this and ensure we
- # use only one of them. As a temporary convenience measure, if there's
+ # use only one of them. As a temporary convenience measure, if there is
# Jamfile.v2 among found files, suppress the warning and use it.
#
if $(jamfile-to-load[2-])
@@ -262,11 +261,10 @@
#
if ! $(no-errors) && ! $(jamfile-to-load)
{
- errors.error
- "Unable to load Jamfile." :
- "Could not find a Jamfile in directory '$(dir)'". :
- "Attempted to find it with pattern '"$(JAMFILE:J=" ")"'." :
- "Please consult the documentation at 'http://www.boost.org'." ;
+ errors.error Unable to load Jamfile.
+ : Could not find a Jamfile in directory '$(dir)'.
+ : Attempted to find it with pattern '"$(JAMFILE:J=" ")"'.
+ : Please consult the documentation at 'http://www.boost.org'. ;
}
return $(jamfile-to-load) ;
@@ -325,13 +323,12 @@
# Now do some checks.
if $(.current-project) != $(saved-project)
{
- errors.error "The value of the .current-project variable"
- : "has magically changed after loading a Jamfile."
- : "This means some of the targets might be defined in the wrong project."
- : "after loading" $(jamfile-module)
- : "expected value" $(saved-project)
- : "actual value" $(.current-project)
- ;
+ errors.error "The value of the .current-project variable has magically"
+ : "changed after loading a Jamfile. This means some of the targets"
+ : "might be defined in the wrong project."
+ : "after loading" $(jamfile-module)
+ : "expected value" $(saved-project)
+ : "actual value" $(.current-project) ;
}
if $(.global-build-dir)
@@ -605,10 +602,8 @@
if $(result[1]) = "@error"
{
- errors.error
- "Requirements for project at '$(self.location)'"
- "conflict with parent's." :
- "Explanation: " $(result[2-]) ;
+ errors.error Requirements for project at '$(self.location)'
+ conflict with parent's. : Explanation: $(result[2-]) ;
}
else
{
@@ -628,7 +623,8 @@
local non-free = [ property.remove free : $(unconditional) ] ;
if $(non-free)
{
- errors.error "usage-requirements" $(specification) "have non-free properties" $(non-free) ;
+ errors.error usage-requirements $(specification) have non-free
+ properties $(non-free) ;
}
local t = [ property.translate-paths $(specification)
: $(self.location) ] ;
@@ -651,8 +647,8 @@
self.source-location = ;
for local src-path in $(specification)
{
- self.source-location += [ path.root
- [ path.make $(src-path) ] $(self.location) ] ;
+ self.source-location += [ path.root [ path.make $(src-path) ]
+ $(self.location) ] ;
}
}
else if $(attribute) = "build-dir"
@@ -669,8 +665,8 @@
else if ! $(attribute) in "default-build" "location" "parent"
"projects-to-build" "project-root" "source-location"
{
- errors.error "Invalid project attribute '$(attribute)' specified"
- "for project at '$(self.location)'" ;
+ errors.error Invalid project attribute '$(attribute)' specified for
+ project at '$(self.location)' ;
}
else
{
@@ -771,11 +767,11 @@
{
# The project at 'location' either has no id or that id is not equal to
# the 'id' parameter.
- if $($(id).jamfile-module)
- && $($(id).jamfile-module) != $(project-module)
+ if $($(id).jamfile-module) && ( $($(id).jamfile-module) !=
+ $(project-module) )
{
- errors.user-error
- "Attempt to redeclare already existing project id '$(id)'" ;
+ errors.user-error Attempt to redeclare already existing project id
+ '$(id)' ;
}
$(id).jamfile-module = $(project-module) ;
}
@@ -810,12 +806,13 @@
# Create the project data, and bring in the project rules into the
# module.
- project.initialize $(__name__) :
- [ path.join [ project.attribute $(root-project) location ] ext $(1:L) ] ;
+ project.initialize $(__name__) : [ path.join [ project.attribute
+ $(root-project) location ] ext $(1:L) ] ;
# Create the project itself, i.e. the attributes. All extensions are
# created in the "/ext" project space.
- project /ext/$(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
+ project /ext/$(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) :
+ $(9) ;
local attributes = [ project.attributes $(__name__) ] ;
# Inherit from the root project of whomever is defining us.
@@ -830,12 +827,12 @@
local location = [ $(project).get source-location ] ;
local result ;
- local paths = [ path.$(rule-name) $(location)
- : [ sequence.transform path.make : $(wildcards) ]
- : [ sequence.transform path.make : $(excludes) ] ] ;
+ local paths = [ path.$(rule-name) $(location) :
+ [ sequence.transform path.make : $(wildcards) ] :
+ [ sequence.transform path.make : $(excludes) ] ] ;
if $(wildcards:D) || $(rule-name) != glob
{
- # The paths we've found are relative to the current directory, but the
+ # The paths we have found are relative to the current directory, but the
# names specified in the sources list are assumed to be relative to the
# source directory of the corresponding project. So, just make the names
# absolute.
@@ -943,8 +940,8 @@
local location = [ $(attributes).get location ] ;
# Project with an empty location is a 'standalone' project such as
# user-config or qt. It has no build dir. If we try to set build dir
- # for user-config, we'll then try to inherit it, with either weird
- # or wrong consequences.
+ # for user-config, we shall then try to inherit it, with either
+ # weird or wrong consequences.
if $(location) && $(location) = [ $(attributes).get project-root ]
{
# Re-read the project id, since it might have been changed in
@@ -953,12 +950,12 @@
# This is Jamroot.
if $(id)
{
- if $(explicit-build-dir)
- && [ path.is-rooted $(explicit-build-dir) ]
+ if $(explicit-build-dir) &&
+ [ path.is-rooted $(explicit-build-dir) ]
{
- errors.user-error "Absolute directory specified via 'build-dir' project attribute"
- : "Don't know how to combine that with the --build-dir option."
- ;
+ errors.user-error Absolute directory specified via
+ 'build-dir' project attribute : Do not know how to
+ combine that with the --build-dir option. ;
}
# Strip the leading slash from id.
local rid = [ MATCH /(.*) : $(id) ] ;
@@ -970,11 +967,12 @@
}
else
{
- # Not Jamroot
+ # Not Jamroot.
if $(explicit-build-dir)
{
- errors.user-error "When --build-dir is specified, the 'build-dir' project"
- : "attribute is allowed only for top-level 'project' invocations" ;
+ errors.user-error When --build-dir is specified, the
+ 'build-dir' project : attribute is allowed only for
+ top-level 'project' invocations ;
}
}
}
@@ -987,7 +985,7 @@
rule constant (
name # Variable name of the constant.
: value + # Value of the constant.
- )
+ )
{
import project ;
local p = [ project.target $(__name__) ] ;
@@ -1049,10 +1047,11 @@
if $(wildcards:D) || $(excludes:D)
{
- errors.user-error "The patterns to 'glob-tree' may not include directory" ;
+ errors.user-error The patterns to 'glob-tree' may not include
+ directory ;
}
- return [ project.glob-internal [ project.current ]
- : $(wildcards) : $(excludes) : glob-tree ] ;
+ return [ project.glob-internal [ project.current ] : $(wildcards) :
+ $(excludes) : glob-tree ] ;
}
# Calculates conditional requirements for multiple requirements at once.
Modified: trunk/tools/build/v2/build/property.jam
==============================================================================
--- trunk/tools/build/v2/build/property.jam (original)
+++ trunk/tools/build/v2/build/property.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -469,7 +469,8 @@
# Assumes that all feature values that start with '@' are names of rules, used
# in 'context-module'. Such rules can be either local to the module or global.
# Converts such values into 'indirect-rule' format (see indirect.jam), so they
-# can be called from other modules.
+# can be called from other modules. Does nothing for such values that are
+# already in the 'indirect-rule' format.
#
rule translate-indirect ( specification * : context-module )
{
@@ -482,7 +483,7 @@
local v ;
if [ MATCH "^([^%]*)%([^%]+)$" : $(m) ]
{
- # Rule is already in indirect format.
+ # Rule is already in the 'indirect-rule' format.
v = $(m) ;
}
else
@@ -541,7 +542,9 @@
else if [ path.is-rooted $(p:G=) ]
{
result += $(condition)$(p) ;
- } else {
+ }
+ else
+ {
result += $(condition)$(p:G)$(project-id)//$(p:G=) ;
}
}
Modified: trunk/tools/build/v2/build/targets.jam
==============================================================================
--- trunk/tools/build/v2/build/targets.jam (original)
+++ trunk/tools/build/v2/build/targets.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -13,8 +13,8 @@
# each Jamfile, and can be obtained by the 'target' rule in the Jamfile's module
# (see project.jam).
#
-# Project targets keep a list of 'main-target' instances. A main target is
-# what the user explicitly defines in a Jamfile. It is possible to have several
+# Project targets keep a list of 'main-target' instances. A main target is what
+# the user explicitly defines in a Jamfile. It is possible to have several
# definitions for a main target, for example to have different lists of sources
# for different platforms. So, main targets keep a list of alternatives.
#
@@ -90,8 +90,8 @@
import "class" ;
import errors ;
- rule __init__ ( name # name of the target in Jamfile
- : project-target # the project target to which this one belongs
+ rule __init__ ( name # Name of the target in Jamfile.
+ : project-target # The project target to which this one belongs.
)
{
# Note: it might seem that we don't need either name or project at all.
@@ -233,10 +233,8 @@
self.build-dir = [ get build-dir ] ;
if ! $(self.build-dir)
{
- self.build-dir = [ path.join
- [ $(self.project).get location ]
- bin
- ] ;
+ self.build-dir = [ path.join [ $(self.project).get location ]
+ bin ] ;
}
}
return $(self.build-dir) ;
@@ -301,8 +299,8 @@
#
rule mark-target-as-explicit ( target-name )
{
- # Record the name of the target, not instance, since this
- # rule is called before main target instaces are created.
+ # Record the name of the target, not instance, since this rule is called
+ # before main target instances are created.
self.explicit-targets += $(target-name) ;
}
@@ -312,13 +310,13 @@
{
if $(self.built-main-targets)
{
- errors.error "add-alternative called when main targets are already created."
- : "in project" [ full-name ] ;
+ errors.error add-alternative called when main targets are already
+ created. : in project [ full-name ] ;
}
self.alternatives += $(target-instance) ;
}
- # Returns a 'main-target' class instance corresponding to the 'name'.
+ # Returns a 'main-target' class instance corresponding to 'name'.
#
rule main-target ( name )
{
@@ -326,11 +324,10 @@
{
build-main-targets ;
}
-
return $(self.main-target.$(name)) ;
}
- # Tells if a main target with the specified name exists.
+ # Returns whether a main target with the specified name exists.
#
rule has-main-target ( name )
{
@@ -345,13 +342,12 @@
}
}
- # Find and return the target with the specified id, treated relative to
- # self.
+ # Worker function for the find rule not implementing any caching and simply
+ # returning nothing in case the target can not be found.
#
rule find-really ( id )
{
local result ;
- local project = $(self.project) ;
local current-location = [ get location ] ;
local split = [ MATCH (.*)//(.*) : $(id) ] ;
@@ -361,8 +357,8 @@
local extra-error-message ;
if $(project-part)
{
- # There's explicit project part in id. Looks up the project and
- # passes the request to it.
+ # There is an explicitly specified project part in id. Looks up the
+ # project and passes the request to it.
local pm = [ project.find $(project-part) : $(current-location) ] ;
if $(pm)
{
@@ -371,37 +367,44 @@
}
else
{
- extra-error-message = "error: could not find project '$(project-part)'" ;
+ # TODO: This extra error message will not get displayed most
+ # likely due to some buggy refactoring. Refactor the code so the
+ # message gets diplayed again.
+ extra-error-message = error: could not find project
+ '$(project-part)' ;
}
}
else
{
# Interpret target-name as name of main target. Need to do this
- # before checking for file. Consider this:
+ # before checking for file. Consider the following scenario with a
+ # toolset not modifying its executable's names, e.g. gcc on
+ # Unix-like platforms:
#
# exe test : test.cpp ;
# install s : test : <location>. ;
#
- # After first build we'll have target 'test' in Jamfile and file
- # 'test' on the disk. We need target to override the file.
+ # After the first build we would have a target named 'test' in the
+ # Jamfile and a file named 'test' on the disk. We need the target to
+ # override the file.
result = [ main-target $(id) ] ;
-
+
+ # Interpret id as an existing file reference.
if ! $(result)
{
- result = [ new file-reference [ path.make $(id) ] : $(project) ] ;
-
+ result = [ new file-reference [ path.make $(id) ] :
+ $(self.project) ] ;
if ! [ $(result).exists ]
{
- # File actually does not exist. Reset 'target' so that an
- # error is issued.
result = ;
}
}
- # Interpret id as project-id
+ # Interpret id as project-id.
if ! $(result)
{
- local project-module = [ project.find $(id) : $(current-location) ] ;
+ local project-module = [ project.find $(id) :
+ $(current-location) ] ;
if $(project-module)
{
result = [ project.target $(project-module) ] ;
@@ -412,6 +415,11 @@
return $(result) ;
}
+ # Find and return the target with the specified id, treated relative to
+ # self. Id may specify either a target or a file name with the target taking
+ # priority. May report an error or return nothing if the target is not found
+ # depending on the 'no-error' parameter.
+ #
rule find ( id : no-error ? )
{
local v = $(.id.$(id)) ;
@@ -714,7 +722,7 @@
}
-# Abstract target which refers to a source file. This is an artificial entity
+# Abstract target refering to a source file. This is an artificial entity
# allowing sources to a target to be represented using a list of abstract target
# instances.
#
@@ -731,11 +739,8 @@
rule generate ( properties )
{
- location ;
- return [ property-set.empty ]
- [ virtual-target.from-file $(self.name)
- : $(self.file-location)
- : $(self.project) ] ;
+ return [ property-set.empty ] [ virtual-target.from-file $(self.name) :
+ [ location ] : $(self.project) ] ;
}
# Returns true if the referred file really exists.
@@ -1081,7 +1086,8 @@
if $(sources:G)
{
- errors.user-error "properties found in the 'sources' parameter for" [ full-name ] ;
+ errors.user-error properties found in the 'sources' parameter for
+ [ full-name ] ;
}
}
@@ -1205,7 +1211,8 @@
ECHO [ targets.indent ] "Common properties: " [ $(rproperties).raw ] ;
}
- if $(rproperties[1]) != "@error" && [ $(rproperties).get <build> ] != no
+ if ( $(rproperties[1]) != "@error" ) && ( [ $(rproperties).get
+ <build> ] != no )
{
local source-targets ;
local properties = [ $(rproperties).non-dependency ] ;
@@ -1427,8 +1434,7 @@
rule construct ( name : source-targets * : property-set )
{
- local r = [ generators.construct $(self.project) $(name:S=)
- : $(self.type)
+ local r = [ generators.construct $(self.project) $(name:S=) : $(self.type)
: [ property-set.create [ $(property-set).raw ]
<main-target-type>$(self.type) ]
: $(source-targets) : true ] ;
Modified: trunk/tools/build/v2/build/type.jam
==============================================================================
--- trunk/tools/build/v2/build/type.jam (original)
+++ trunk/tools/build/v2/build/type.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -49,15 +49,15 @@
else
{
.types += $(type) ;
- .bases.$(type) = $(base-type) ;
+ .base.$(type) = $(base-type) ;
.derived.$(base-type) += $(type) ;
if $(suffixes)-is-not-empty
{
# Specify mapping from suffixes to type.
register-suffixes $(suffixes) : $(type) ;
- # Generated targets of 'type' will use the first of 'suffixes'. This
- # may be overriden.
+ # By default generated targets of 'type' will use the first of
+ #'suffixes'. This may be overriden.
set-generated-target-suffix $(type) : : $(suffixes[1]) ;
}
@@ -69,23 +69,17 @@
feature.compose <base-target-type>$(type) : <base-target-type>$(base-type) ;
# We used to declare the main target rule only when a 'main' parameter
- # was specified. However, it is hard to decide that a type will *never*
- # need a main target rule and so from time to time we needed to make yet
- # another type 'main'. So now a main target rule is defined for each
- # type.
+ # has been specified. However, it is hard to decide that a type will
+ # *never* need a main target rule and so from time to time we needed to
+ # make yet another type 'main'. So now a main target rule is defined for
+ # each type.
main-rule-name = [ type-to-rule-name $(type) ] ;
.main-target-type.$(main-rule-name) = $(type) ;
-
IMPORT $(__name__) : main-target-rule : : $(main-rule-name) ;
- # This is a hack to invalidate generator selection related cached viable
- # source target type information because it adding a new derived target
- # type logically adds the new type to the any viable source target type
- # lists already containing its base type.
- #
- # We can improve the current implementation by not clearing the whole
- # cache but simply updating the cached values. That might be more
- # performant but needs to be tested and implemented at a later time.
+ # Adding a new derived type affects generator selection so we need to
+ # make the generator selection module update any of its cached
+ # information related to a new derived type being defined.
generators.update-cached-information-with-a-new-type $(type) ;
}
}
@@ -125,8 +119,8 @@
}
else if $(.type.$(s)) != $(type)
{
- errors.error Attempting to specify multiple types for suffix \"$(s)\"
- : "Old type $(.type.$(s)), New type $(type)" ;
+ errors.error Attempting to specify multiple types for suffix
+ \"$(s)\" : "Old type $(.type.$(s)), New type $(type)" ;
}
}
}
@@ -147,7 +141,7 @@
#
rule validate ( type )
{
- if ! $(type) in $(.types)
+ if ! [ registered $(type) ]
{
errors.error "Unknown target type $(type)" ;
}
@@ -158,10 +152,7 @@
#
rule set-scanner ( type : scanner )
{
- if ! $(type) in $(.types)
- {
- error "Type" $(type) "is not declared" ;
- }
+ validate $(type) ;
.scanner.$(type) = $(scanner) ;
}
@@ -177,6 +168,15 @@
}
+# Returns a base type for the given type or nothing in case the given type is
+# not derived.
+#
+rule base ( type )
+{
+ return $(.base.$(type)) ;
+}
+
+
# Returns the given type and all of its base types in order of their distance
# from type.
#
@@ -185,13 +185,16 @@
local result = $(type) ;
while $(type)
{
- type = $(.bases.$(type)) ;
+ type = [ base $(type) ] ;
result += $(type) ;
}
return $(result) ;
}
+# Returns the given type and all of its derived types in order of their distance
+# from type.
+#
rule all-derived ( type )
{
local result = $(type) ;
@@ -203,7 +206,8 @@
}
-# Returns true if 'type' has 'base' as its direct or indirect base.
+# Returns true if 'type' is equal to 'base' or has 'base' as its direct or
+# indirect base.
#
rule is-derived ( type base )
{
@@ -213,19 +217,15 @@
}
}
-
# Returns true if 'type' is either derived from or is equal to 'base'.
#
+# TODO: It might be that is-derived and is-subtype were meant to be different
+# rules - one returning true for type = base and one not, but as currently
+# implemented they are actually the same. Clean this up.
+#
rule is-subtype ( type base )
{
- if $(type) = $(base)
- {
- return true ;
- }
- else
- {
- return [ is-derived $(type) $(base) ] ;
- }
+ return [ is-derived $(type) $(base) ] ;
}
@@ -340,7 +340,7 @@
{
found = true ;
}
- type = $(.bases.$(type)) ;
+ type = $(.base.$(type)) ;
}
if $(result) = ""
{
@@ -356,8 +356,8 @@
local v = $($(key)) ;
if ! $(v)
{
- v = [ generated-target-ps-real $(ps) : $(type)
- : [ $(property-set).raw ] ] ;
+ v = [ generated-target-ps-real $(ps) : $(type) : [ $(property-set).raw ]
+ ] ;
if ! $(v)
{
v = none ;
@@ -394,23 +394,32 @@
# Rule used to construct all main targets. Note that this rule gets imported
-# into the global namespace under different alias names and exactly what type of
-# target it is supposed to construct is read from the name of the alias rule
-# actually used to invoke it.
+# into the global namespace under different alias names and the exact target
+# type to construct is selected based on the alias used to actually invoke this
+# rule.
#
-rule main-target-rule ( name : sources * : requirements * : default-build *
- : usage-requirements * )
+rule main-target-rule ( name : sources * : requirements * : default-build * :
+ usage-requirements * )
{
- # First discover the required target type, which is equal to the rule name
- # used to invoke us.
+ # First discover the required target type based on the exact alias used to
+ # invoke this rule.
local bt = [ BACKTRACE 1 ] ;
local rulename = $(bt[4]) ;
+ local target-type = [ type-from-rule-name $(rulename) ] ;
- local project = [ project.current ] ;
-
- # This is a circular module dependency so it must be imported here.
+ # This is a circular module dependency and so must be imported here.
import targets ;
- return [ targets.create-typed-target $(.main-target-type.$(rulename))
- : $(project) : $(name) : $(sources) : $(requirements)
- : $(default-build) : $(usage-requirements) ] ;
+
+ return [ targets.create-typed-target $(target-type) : [ project.current ] :
+ $(name) : $(sources) : $(requirements) : $(default-build) :
+ $(usage-requirements) ] ;
+}
+
+
+rule __test__ ( )
+{
+ import assert ;
+
+ # TODO: Add tests for all the is-derived, is-base & related type relation
+ # checking rules.
}
Modified: trunk/tools/build/v2/build/virtual-target.jam
==============================================================================
--- trunk/tools/build/v2/build/virtual-target.jam (original)
+++ trunk/tools/build/v2/build/virtual-target.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -6,7 +6,7 @@
# Implements virtual targets, which correspond to actual files created during a
# build, but are not yet targets in Jam sense. They are needed, for example,
-# when searching for possible transformation sequences, when it's not yet known
+# when searching for possible transformation sequences, when it is not yet known
# whether a particular target should be created at all.
import "class" : new ;
@@ -17,6 +17,7 @@
import type ;
import utility ;
+
# +--------------------------+
# | virtual-target |
# +==========================+
@@ -88,18 +89,24 @@
# Name of this target.
#
- rule name ( ) { return $(self.name) ; }
+ rule name ( )
+ {
+ return $(self.name) ;
+ }
# Project of this target.
#
- rule project ( ) { return $(self.project) ; }
+ rule project ( )
+ {
+ return $(self.project) ;
+ }
# Adds additional 'virtual-target' instances this one depends on.
#
rule depends ( d + )
{
- self.dependencies = [ sequence.merge $(self.dependencies)
- : [ sequence.insertion-sort $(d) ] ] ;
+ self.dependencies = [ sequence.merge $(self.dependencies) :
+ [ sequence.insertion-sort $(d) ] ] ;
}
rule dependencies ( )
@@ -195,7 +202,8 @@
{
# In fact, we just need to merge virtual-target with
# abstract-file-target as the latter is the only class derived from the
- # former. But that's for later.
+ # former. But that has been left for later.
+
errors.error "method should be defined in derived classes" ;
}
}
@@ -207,8 +215,9 @@
# May be a source file (when no action is specified) or a derived file
# (otherwise).
#
-# The target's grist is concatenation of its project's location, properties of
-# action (for derived files) and, optionally, value identifying the main target.
+# The target's grist is a concatenation of its project's location, action
+# properties (for derived targets) and, optionally, value identifying the main
+# target.
#
class abstract-file-target : virtual-target
{
@@ -246,7 +255,10 @@
}
}
- rule type ( ) { return $(self.type) ; }
+ rule type ( )
+ {
+ return $(self.type) ;
+ }
# Sets the path. When generating target name, it will override any path
# computation from properties.
@@ -301,11 +313,11 @@
}
# Return a human-readable representation of this target. If this target has
- # an action, that's:
+ # an action, that is:
#
# { <action-name>-<self.name>.<self.type> <action-sources>... }
#
- # otherwise, it's:
+ # otherwise, it is:
#
# { <self.name>.<self.type> }
#
@@ -451,7 +463,7 @@
}
}
- # If there's no tag or the tag rule returned nothing.
+ # If there is no tag or the tag rule returned nothing.
if ! $(tag) || ! $(self.name)
{
self.name = [ virtual-target.add-prefix-and-suffix $(specified-name)
@@ -470,7 +482,7 @@
if $(self.action)
{
- # For non-derived target, we don't care if there are several
+ # For non-derived target, we do not care if there are several
# virtual targets that refer to the same name. One case when
# this is unavoidable is when the file name is main.cpp and two
# targets have types CPP (for compiling) and MOCCABLE_CPP (for
@@ -541,23 +553,23 @@
import errors ;
rule __init__ (
- name exact ?
- : type ? # Optional type for this target
+ name exact ?
+ : type ? # Optional type for this target.
: project
: action ?
: path ?
)
{
- abstract-file-target.__init__ $(name) $(exact) : $(type) : $(project)
- : $(action) ;
+ abstract-file-target.__init__ $(name) $(exact) : $(type) : $(project) :
+ $(action) ;
self.path = $(path) ;
}
rule clone-with-different-type ( new-type )
{
- return [ new file-target $(self.name) exact : $(new-type)
- : $(self.project) : $(self.action) : $(self.path) ] ;
+ return [ new file-target $(self.name) exact : $(new-type) :
+ $(self.project) : $(self.action) : $(self.path) ] ;
}
rule actualize-location ( target )
@@ -591,14 +603,14 @@
# target has no directory name and uses a special <e> grist.
#
# First, that means that "bjam hello.o" will build all known hello.o
- # targets. Second, the <e> grist makes sure this target won't be
+ # targets. Second, the <e> grist makes sure this target will not be
# confused with other targets, for example, if we have subdir 'test'
# with target 'test' in it that includes a 'test.o' file, then the
# target for directory will be just 'test' the target for test.o
# will be <ptest/bin/gcc/debug>test.o and the target we create below
# will be <e>test.o
DEPENDS $(target:G=e) : $(target) ;
- # Allow bjam <path-to-file>/<file> to work. This won't catch all
+ # Allow bjam <path-to-file>/<file> to work. This will not catch all
# possible ways to refer to the path (relative/absolute, extra ".",
# various "..", but should help in obvious cases.
DEPENDS $(target:G=e:R=$(path)) : $(target) ;
@@ -618,13 +630,13 @@
if $(self.action)
{
local p = [ $(self.action).properties ] ;
- local path = [ $(p).target-path ] ;
+ local path,relative-to-build-dir = [ $(p).target-path ] ;
+ local path = $(path,relative-to-build-dir[1]) ;
+ local relative-to-build-dir = $(path,relative-to-build-dir[2]) ;
- if $(path[2]) = true
+ if $(relative-to-build-dir)
{
- # Indicates that the path is relative to the build dir.
- path = [ path.join [ $(self.project).build-dir ]
- $(path[1]) ] ;
+ path = [ path.join [ $(self.project).build-dir ] $(path) ] ;
}
self.path = [ path.native $(path) ] ;
@@ -746,7 +758,8 @@
actualize-sources [ sources ] : $(properties) ;
- DEPENDS $(actual-targets) : $(self.actual-sources) $(self.dependency-only-sources) ;
+ DEPENDS $(actual-targets) : $(self.actual-sources)
+ $(self.dependency-only-sources) ;
# Action name can include additional argument to rule, which should
# not be passed to 'set-target-variables'
@@ -813,8 +826,8 @@
#
# For bjam to find the dependency the generated target must be
# actualized (i.e. have its Jam target constructed). In the above case,
- # if we're building just hello ("bjam hello"), 'a.h' won't be actualized
- # unless we do it here.
+ # if we are building just hello ("bjam hello"), 'a.h' will not be
+ # actualized unless we do it here.
local implicit = [ $(self.properties).get <implicit-dependency> ] ;
for local i in $(implicit)
{
@@ -835,7 +848,7 @@
# Action class which does nothing --- it produces the targets with specific
-# properties out of nowhere. It's needed to distinguish virtual targets with
+# properties out of nowhere. It is needed to distinguish virtual targets with
# different properties that are known to exist and have no actions which create
# them.
#
@@ -885,16 +898,21 @@
# Creates a virtual target with an appropriate name and type from 'file'. If a
# target with that name in that project already exists, returns that already
# created target.
+#
# FIXME: a more correct way would be to compute the path to the file, based on
# name and source location for the project, and use that path to determine if
-# the target was already created.
+# the target has already been created. This logic should be shared with how we
+# usually find targets identified by a specific target id. It should also be
+# updated to work correctly when the file is specified using both relative and
+# absolute paths.
+#
# TODO: passing a project with all virtual targets is starting to be annoying.
#
rule from-file ( file : file-loc : project )
{
import type ; # Had to do this here to break a circular dependency.
- # Check if we've created a target corresponding to this file.
+ # Check whether we already created a target corresponding to this file.
local path = [ path.root [ path.root $(file) $(file-loc) ] [ path.pwd ] ] ;
if $(.files.$(path))
@@ -907,11 +925,8 @@
local type = [ type.type $(file) ] ;
local result ;
- result = [ new file-target $(file)
- : $(type)
- : $(project)
- : #action
- : $(file-loc) ] ;
+ result = [ new file-target $(file) : $(type) : $(project) : :
+ $(file-loc) ] ;
.files.$(path) = $(result) ;
return $(result) ;
@@ -919,7 +934,7 @@
}
-# Registers a new virtual target. Checks if there's already a registered target
+# Registers a new virtual target. Checks if there is already a registered target
# with the same name, type, project and subvariant properties as well as the
# same sources and equal action. If such target is found it is returned and a
# new 'target' is not registered. Otherwise, 'target' is registered and
@@ -945,15 +960,15 @@
else
{
if $(a1) && $(a2) &&
- [ $(a1).action-name ] = [ $(a2).action-name ] &&
- [ $(a1).sources ] = [ $(a2).sources ]
+ ( [ $(a1).action-name ] = [ $(a2).action-name ] ) &&
+ ( [ $(a1).sources ] = [ $(a2).sources ] )
{
local ps1 = [ $(a1).properties ] ;
local ps2 = [ $(a2).properties ] ;
- local p1 = [ $(ps1).base ] [ $(ps1).free ]
- [ set.difference [ $(ps1).dependency ] : [ $(ps1).incidental ] ] ;
- local p2 = [ $(ps2).base ] [ $(ps2).free ]
- [ set.difference [ $(ps2).dependency ] : [ $(ps2).incidental ] ] ;
+ local p1 = [ $(ps1).base ] [ $(ps1).free ] [ set.difference
+ [ $(ps1).dependency ] : [ $(ps1).incidental ] ] ;
+ local p2 = [ $(ps2).base ] [ $(ps2).free ] [ set.difference
+ [ $(ps2).dependency ] : [ $(ps2).incidental ] ] ;
if $(p1) = $(p2)
{
result = $(t) ;
@@ -976,10 +991,10 @@
}
-# Each target returned by 'register' is added to a .recent-targets list,
+# Each target returned by 'register' is added to the .recent-targets list,
# returned by this function. This allows us to find all virtual targets created
-# when building a given main target, even those constructed only as intermediate
-# targets.
+# when building a specific main target, even those constructed only as
+# intermediate targets.
#
rule recent-targets ( )
{
@@ -1059,9 +1074,9 @@
# Traverses the dependency graph of 'target' and return all targets that will be
# created before this one is created. If the root of some dependency graph is
-# found during traversal, it's either included or not, depending on the value of
-# 'include-roots'. In either case traversal stops at root targets, i.e. sources
-# of root targets are not traversed.
+# found during traversal, it is either included or not, depending on the
+# 'include-roots' value. In either case traversal stops at root targets, i.e.
+# root target sources are not traversed.
#
rule traverse ( target : include-roots ? : include-sources ? )
{
@@ -1116,9 +1131,9 @@
for local target in [ $(action).targets ]
{
local n = [ $(target).name ] ;
- # Don't modify produced targets names.
- local cloned-target = [ class.new file-target $(n) exact
- : [ $(target).type ] : $(new-project) : $(cloned-action) ] ;
+ # Do not modify produced target names.
+ local cloned-target = [ class.new file-target $(n) exact :
+ [ $(target).type ] : $(new-project) : $(cloned-action) ] ;
local d = [ $(target).dependencies ] ;
if $(d)
{
Modified: trunk/tools/build/v2/test/project_test3.py
==============================================================================
--- trunk/tools/build/v2/test/project_test3.py (original)
+++ trunk/tools/build/v2/test/project_test3.py 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -16,7 +16,6 @@
t.run_build_system(status=1, stdout=
"""error: Could not find parent for project at '.'
error: Did not find Jamfile.jam or Jamroot.jam in any parent directory.
-
""")
t.set_tree("project-test3")
Deleted: trunk/tools/build/v2/to_merge.sh
==============================================================================
--- trunk/tools/build/v2/to_merge.sh 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
+++ (empty file)
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-for python in build/*.py; do
- jam="${python%.py}.jam"
- if [ -f "$jam" ]; then
- line=`grep "Base revision" $python`
- revision=`echo $line | sed 's/# Base revision: \([0-9]*\).*/\1/'`
- if [ -e "$revision" ] ; then
- echo "No base version for $python" >&2
- else
- svn diff -r $revision:HEAD "$jam"
- fi
- fi
-done
-
-
Modified: trunk/tools/build/v2/tools/builtin.jam
==============================================================================
--- trunk/tools/build/v2/tools/builtin.jam (original)
+++ trunk/tools/build/v2/tools/builtin.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -6,7 +6,7 @@
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
-# Defines standard features and rules.
+# Defines standard features and rules.
import alias ;
import "class" : new ;
@@ -461,9 +461,9 @@
# Attach binding of including file to included targets. When a target is
# directly created from virtual target this extra information is
# unnecessary. But in other cases, it allows us to distinguish between
- # two headers of the same name included from different places. We don't
+ # two headers of the same name included from different places. We do not
# need this extra information for angle includes, since they should not
- # depend on including file (we can't get literal "." in include path).
+ # depend on including file (we can not get literal "." in include path).
local g2 = $(g)"#"$(b) ;
angle = $(angle:G=$(g)) ;
@@ -526,7 +526,7 @@
# Determine the needed target type.
local actual-type ;
# <source>files can be generated by <conditional>@rule feature
- # in which case we don't consider it a SEARCHED_LIB type.
+ # in which case we do not consider it a SEARCHED_LIB type.
if ! <source> in $(properties:G) &&
( <search> in $(properties:G) || <name> in $(properties:G) )
{
@@ -572,12 +572,12 @@
if <name> in $(requirements:G)
{
errors.user-error "When several names are given to the 'lib' rule" :
- "it's not allowed to specify the <name> feature." ;
+ "it is not allowed to specify the <name> feature." ;
}
if $(sources)
{
errors.user-error "When several names are given to the 'lib' rule" :
- "it's not allowed to specify sources." ;
+ "it is not allowed to specify sources." ;
}
}
@@ -645,7 +645,7 @@
lib-name ?= $(name) ;
local t = [ new searched-lib-target $(lib-name) : $(project)
: $(shared) : $(search) : $(a) ] ;
- # We return sources for a simple reason. If there's
+ # We return sources for a simple reason. If there is
# lib png : z : <name>png ;
# the 'z' target should be returned, so that apps linking to 'png'
# will link to 'z', too.
@@ -723,11 +723,11 @@
rule register-c-compiler ( id : source-types + : target-types + : requirements *
: optional-properties * )
{
- generators.register [ new C-compiling-generator $(id) : $(source-types)
- : $(target-types) : $(requirements) : $(optional-properties) ] ;
+ generators.register [ new C-compiling-generator $(id) : $(source-types) :
+ $(target-types) : $(requirements) : $(optional-properties) ] ;
}
-# FIXME: this is ugly, should find a better way (we'd like client code to
+# FIXME: this is ugly, should find a better way (we would like client code to
# register all generators as "generators.some-rule" instead of
# "some-module.some-rule".)
#
@@ -772,18 +772,22 @@
}
}
- # It's possible that sources include shared libraries that did not came
+ # It is possible that sources include shared libraries that did not came
# from 'lib' targets, e.g. .so files specified as sources. In this case
# we have to add extra dll-path properties and propagate extra xdll-path
- # properties so that application linking to use will get xdll-path to
+ # properties so that application linking to us will get xdll-path to
# those libraries.
local extra-xdll-paths ;
for local s in $(sources)
{
if [ type.is-derived [ $(s).type ] SHARED_LIB ] && ! [ $(s).action ]
{
- # Unfortunately, we don't have a good way to find the path to a
+ # Unfortunately, we do not have a good way to find the path to a
# file, so use this nasty approach.
+ #
+ # TODO: This needs to be done better. One thing that is really
+ # broken with this is that it does not work correctly with
+ # projects having multiple source locations.
local p = [ $(s).project ] ;
local location = [ path.root [ $(s).name ]
[ $(p).get source-location ] ] ;
@@ -792,8 +796,8 @@
}
# Hardcode DLL paths only when linking executables.
- # Pros: don't need to relink libraries when installing.
- # Cons: "standalone" libraries (plugins, python extensions) can't
+ # Pros: do not need to relink libraries when installing.
+ # Cons: "standalone" libraries (plugins, python extensions) can not
# hardcode paths to dependent libraries.
if [ $(property-set).get <hardcode-dll-paths> ] = true
&& [ type.is-derived $(self.target-types[1]) EXE ]
@@ -846,9 +850,9 @@
# to other shared libraries this one depends on in order to be able to
# find them all at runtime.
- # Just pass all features in property-set, it's theorically possible that
- # we'll propagate <xdll-path> features explicitly specified by the user,
- # but then the user's to blaim for using an internal feature.
+ # Just pass all features in property-set, it is theorically possible
+ # that we will propagate <xdll-path> features explicitly specified by
+ # the user, but then the user is to blaim for using an internal feature.
local values = [ $(property-set).get <xdll-path> ] ;
extra += $(values:G=<xdll-path>) ;
@@ -927,7 +931,7 @@
local result = [ generator.run $(project) $(name) : $(property-set)
: $(sources) ] ;
- # For static linking, if we get a library in source, we can't directly
+ # For static linking, if we get a library in source, we can not directly
# link to it so we need to cause our dependencies to link to that
# library. There are two approaches:
# - adding the library to the list of returned targets.
@@ -938,11 +942,11 @@
# lib a2 : a2.cpp a1 : <link>static ;
# install dist : a2 ;
#
- # here we'll try to install 'a1', even though it's not necessary in the
- # general case. With the second approach, even indirect dependants will
- # link to the library, but it should not cause any harm. So, return all
- # LIB sources together with created targets, so that dependants link to
- # them.
+ # here we will try to install 'a1', even though it is not necessary in
+ # the general case. With the second approach, even indirect dependants
+ # will link to the library, but it should not cause any harm. So, return
+ # all LIB sources together with created targets, so that dependants link
+ # to them.
local usage-requirements ;
if [ $(property-set).get <link> ] = static
{
Modified: trunk/tools/build/v2/tools/cast.jam
==============================================================================
--- trunk/tools/build/v2/tools/cast.jam (original)
+++ trunk/tools/build/v2/tools/cast.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -3,24 +3,25 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-# Defines main target 'cast', used to change type for target. For example,
-# in Qt library one wants two kinds of CPP files -- those that just compiled
-# and those that are passed via the MOC tool.
+# Defines main target 'cast', used to change type for target. For example, in Qt
+# library one wants two kinds of CPP files -- those that just compiled and those
+# that are passed via the MOC tool.
#
# This is done with:
#
# exe main : main.cpp [ cast _ moccable-cpp : widget.cpp ] ;
#
-# Boost.Build will assing target type CPP to both main.cpp and widget.cpp.
-# Then, the cast rule will change target type of widget.cpp to
-# MOCCABLE-CPP, and Qt support will run MOC tool as part of build process.
+# Boost.Build will assing target type CPP to both main.cpp and widget.cpp. Then,
+# the cast rule will change target type of widget.cpp to MOCCABLE-CPP, and Qt
+# support will run the MOC tool as part of the build process.
#
# At the moment, the 'cast' rule only works for non-derived (source) targets.
#
-# Another solution would be to add separate main target 'moc-them' that
-# will moc all the passed sources, not matter what's the type, but I prefer
-# cast, as defining new target type + generator for that type is somewhat
-# simpler then defining main target rule.
+# TODO: The following comment is unclear or incorrect. Clean it up.
+# > Another solution would be to add a separate main target 'moc-them' that
+# > would moc all the passed sources, no matter what their type is, but I prefer
+# > cast, as defining a new target type + generator for that type is somewhat
+# > simpler than defining a main target rule.
import "class" : new ;
import errors ;
@@ -34,11 +35,11 @@
{
import type ;
- rule __init__ ( name : project : type : sources * : requirements *
- : default-build * : usage-requirements * )
+ rule __init__ ( name : project : type : sources * : requirements * :
+ default-build * : usage-requirements * )
{
- typed-target.__init__ $(name) : $(project) : $(type) : $(sources)
- : $(requirements) : $(default-build) : $(usage-requirements) ;
+ typed-target.__init__ $(name) : $(project) : $(type) : $(sources) :
+ $(requirements) : $(default-build) : $(usage-requirements) ;
}
rule construct ( name : source-targets * : property-set )
@@ -48,14 +49,14 @@
{
if ! [ class.is-a $(s) : file-target ]
{
- ECHO "error: source to the 'cast' rule is not a file!" ;
- EXIT ;
+ import errors ;
+ errors.user-error Source to the 'cast' rule is not a file! ;
}
if [ $(s).action ]
{
- ECHO "error: only non-derived target are allowed for 'cast'." ;
- ECHO "error: when building " [ full-name ] ;
- EXIT ;
+ import errors ;
+ errors.user-error Only non-derived target are allowed for
+ 'cast'. : when building [ full-name ] ;
}
local r = [ $(s).clone-with-different-type $(self.type) ] ;
result += [ virtual-target.register $(r) ] ;
@@ -65,27 +66,26 @@
}
-rule cast ( name type : sources * : requirements * : default-build *
- : usage-requirements * )
+rule cast ( name type : sources * : requirements * : default-build * :
+ usage-requirements * )
{
local project = [ project.current ] ;
local real-type = [ type.type-from-rule-name $(type) ] ;
if ! $(real-type)
{
- errors.user-error "No type corresponds to main target rule name '$(type)'"
- : "Hint: try lowercase name" ;
+ errors.user-error No type corresponds to the main target rule name
+ '$(type)' : "Hint: try a lowercase name" ;
}
- # This is a circular module dependency so it must be imported here.
- import targets ;
- targets.main-target-alternative
- [ new cast-target-class $(name) : $(project) : $(real-type)
- : [ targets.main-target-sources $(sources) : $(name) ]
- : [ targets.main-target-requirements $(requirements) : $(project) ]
- : [ targets.main-target-default-build $(default-build) : $(project) ]
- : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ]
- ] ;
+ targets.main-target-alternative [ new cast-target-class $(name) : $(project)
+ : $(real-type)
+ : [ targets.main-target-sources $(sources) : $(name) ]
+ : [ targets.main-target-requirements $(requirements) : $(project) ]
+ : [ targets.main-target-default-build $(default-build) : $(project) ]
+ : [ targets.main-target-usage-requirements $(usage-requirements) :
+ $(project) ] ] ;
}
+
IMPORT $(__name__) : cast : : cast ;
Modified: trunk/tools/build/v2/tools/make.jam
==============================================================================
--- trunk/tools/build/v2/tools/make.jam (original)
+++ trunk/tools/build/v2/tools/make.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -7,14 +7,13 @@
# This module defines the 'make' main target rule.
-import targets ;
import "class" : new ;
-import property ;
import errors : error ;
-import type : type ;
-import regex ;
-import property-set ;
import project ;
+import property ;
+import property-set ;
+import regex ;
+import targets ;
class make-target-class : basic-target
Modified: trunk/tools/build/v2/tools/testing.jam
==============================================================================
--- trunk/tools/build/v2/tools/testing.jam (original)
+++ trunk/tools/build/v2/tools/testing.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -32,7 +32,7 @@
import alias ;
-import "class" : new ;
+import "class" ;
import common ;
import errors ;
import feature ;
@@ -99,11 +99,9 @@
# The <location-prefix> forces the build system for generate paths in the
# form '$build_dir/array1.test/gcc/debug'. This is necessary to allow
# post-processing tools to work.
- local t =
- [ targets.create-typed-target
- [ type.type-from-rule-name $(target-type) ] : $(project)
- : $(real-name) : $(sources)
- : $(requirements) <location-prefix>$(real-name).test ] ;
+ local t = [ targets.create-typed-target [ type.type-from-rule-name
+ $(target-type) ] : $(project) : $(real-name) : $(sources) :
+ $(requirements) <location-prefix>$(real-name).test ] ;
# The alias to the real target, per period replacement above.
if $(real-name) != $(target-name)
@@ -122,15 +120,18 @@
# Note: passing more that one cpp file here is known to fail. Passing a cpp file
# and a library target works.
+#
rule compile ( sources + : requirements * : target-name ? )
{
- return [ make-test compile : $(sources) : $(requirements) : $(target-name) ] ;
+ return [ make-test compile : $(sources) : $(requirements) : $(target-name) ]
+ ;
}
rule compile-fail ( sources + : requirements * : target-name ? )
{
- return [ make-test compile-fail : $(sources) : $(requirements) : $(target-name) ] ;
+ return [ make-test compile-fail : $(sources) : $(requirements) :
+ $(target-name) ] ;
}
@@ -142,7 +143,8 @@
rule link-fail ( sources + : requirements * : target-name ? )
{
- return [ make-test link-fail : $(sources) : $(requirements) : $(target-name) ] ;
+ return [ make-test link-fail : $(sources) : $(requirements) : $(target-name)
+ ] ;
}
@@ -162,8 +164,8 @@
}
-rule run ( sources + : args * : input-files * : requirements * : target-name ?
- : default-build * )
+rule run ( sources + : args * : input-files * : requirements * : target-name ? :
+ default-build * )
{
requirements += <testing.arg>$(args:J=" ") ;
requirements += [ handle-input-files $(input-files) ] ;
@@ -171,12 +173,13 @@
}
-rule run-fail ( sources + : args * : input-files * : requirements *
- : target-name ? : default-build * )
+rule run-fail ( sources + : args * : input-files * : requirements * :
+ target-name ? : default-build * )
{
requirements += <testing.arg>$(args:J=" ") ;
requirements += [ handle-input-files $(input-files) ] ;
- return [ make-test run-fail : $(sources) : $(requirements) : $(target-name) ] ;
+ return [ make-test run-fail : $(sources) : $(requirements) : $(target-name)
+ ] ;
}
@@ -187,7 +190,7 @@
# For all main targets in 'project-module', which are typed targets with type
# derived from 'TEST', produce some interesting information.
#
-rule dump-tests # ( project-module )
+rule dump-tests
{
for local t in $(.all-tests)
{
@@ -248,19 +251,16 @@
{
if [ class.is-a $(s) : file-reference ]
{
- local location =
- [ path.root
- [ path.root [ $(s).name ] [ $(s).location ] ]
- [ path.pwd ] ] ;
-
- source-files +=
- [ path.relative-to
- [ path.root $(project-root) [ path.pwd ] ]
- $(location) ] ;
+ local location = [ path.root [ path.root [ $(s).name ]
+ [ $(s).location ] ] [ path.pwd ] ] ;
+
+ source-files += [ path.relative-to [ path.root $(project-root)
+ [ path.pwd ] ] $(location) ] ;
}
}
- local target-name = [ $(project).get location ] // [ $(target).name ] .test ;
+ local target-name = [ $(project).get location ] // [ $(target).name ] .test
+ ;
target-name = $(target-name:J=) ;
local r = [ $(target).requirements ] ;
@@ -286,9 +286,8 @@
# Format them into a single string of quoted strings.
test-info = \"$(test-info:J=\"\ \")\" ;
- ECHO boost-test($(type)) \"$(name)\"
- [$(test-info)]
- ":" \"$(source-files)\" ;
+ ECHO boost-test($(type)) \"$(name)\" [$(test-info)] ":"
+ \"$(source-files)\" ;
}
}
@@ -340,14 +339,14 @@
}
-# The rule/action combination used to report successfull passing of a test.
+# The rule/action combination used to report successful passing of a test.
#
rule **passed**
{
# Dump all the tests, if needed. We do it here, since dump should happen
# only after all Jamfiles have been read, and there is no such place
# currently defined (but there should be).
- if ! $(.dumped-tests) && --dump-tests in [ modules.peek : ARGV ]
+ if ! $(.dumped-tests) && ( --dump-tests in [ modules.peek : ARGV ] )
{
.dumped-tests = true ;
dump-tests ;
Modified: trunk/tools/build/v2/util/path.jam
==============================================================================
--- trunk/tools/build/v2/util/path.jam (original)
+++ trunk/tools/build/v2/util/path.jam 2009-09-05 08:44:28 EDT (Sat, 05 Sep 2009)
@@ -213,15 +213,11 @@
#
rule pwd ( )
{
- if $(.pwd)
- {
- return $(.pwd) ;
- }
- else
+ if ! $(.pwd)
{
.pwd = [ make [ PWD ] ] ;
- return $(.pwd) ;
}
+ return $(.pwd) ;
}
@@ -264,8 +260,8 @@
local exc = [ GLOB-RECURSIVELY $(real-exclude-patterns) ] ;
exc = [ sequence.transform NORMALIZE_PATH : $(exc) ] ;
- return [ sequence.transform path.make :
- [ set.difference $(inc) : $(exc) ] ] ;
+ return [ sequence.transform path.make : [ set.difference $(inc) : $(exc) ] ]
+ ;
}
@@ -277,11 +273,8 @@
#
rule glob-tree ( roots * : patterns + : exclude-patterns * )
{
- return [ sequence.transform path.make : [ .glob-tree
- [ sequence.transform path.native : $(roots) ]
- : $(patterns)
- : $(exclude-patterns)
- ] ] ;
+ return [ sequence.transform path.make : [ .glob-tree [ sequence.transform
+ path.native : $(roots) ] : $(patterns) : $(exclude-patterns) ] ] ;
}
@@ -304,7 +297,8 @@
}
if $(subdirs)
{
- result += [ .glob-tree $(subdirs) : $(patterns) : $(exclude-patterns) ] ;
+ result += [ .glob-tree $(subdirs) : $(patterns) : $(exclude-patterns) ]
+ ;
}
return $(result) ;
}
@@ -328,32 +322,33 @@
cwd ?= [ pwd ] ;
local path_ele = [ regex.split [ root $(path) $(cwd) ] "/" ] ;
- if ! $(upper_limit) {
+ if ! $(upper_limit)
+ {
upper_limit = / ;
}
local upper_ele = [ regex.split [ root $(upper_limit) $(cwd) ] "/" ] ;
- # Leave only elements in 'path_ele' below 'upper_ele'
- while $(path_ele) && $(upper_ele[1]) = $(path_ele[1]) {
+ # Leave only elements in 'path_ele' below 'upper_ele'.
+ while $(path_ele) && ( $(upper_ele[1]) = $(path_ele[1]) )
+ {
upper_ele = $(upper_ele[2-]) ;
path_ele = $(path_ele[2-]) ;
}
- # All upper elements removed ?
- if ! $(upper_ele)
+ # Have all upper elements been removed ?
+ if $(upper_ele)
{
- # Create the relative paths to parents, number of elements in 'path_ele'
- local result ;
- for local i in $(path_ele) {
- path = [ parent $(path) ] ;
- result += $(path) ;
- }
- return $(result) ;
+ errors.error "$(upper_limit) is not prefix of $(path)" ;
}
- else
+
+ # Create the relative paths to parents, number of elements in 'path_ele'.
+ local result ;
+ for local i in $(path_ele)
{
- errors.error "$(upper_limit) is not prefix of $(path)" ;
+ path = [ parent $(path) ] ;
+ result += $(path) ;
}
+ return $(result) ;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk