mirror of
https://github.com/boostorg/build.git
synced 2026-02-16 01:12:13 +00:00
Apply feature defaults when building.
* new/build-request.jam (expand-with-defaults): New rule
* new/build-system.jam, new/targets.jam: Use 'expand-with-defaults' instead
of 'expand'.
* new/builtin.jam: Define new feature 'threading'.
* test/project_test3.py: Test that feature defaults are applied.
[SVN r14307]
This commit is contained in:
@@ -96,6 +96,25 @@ local rule x-product ( property-sets * : feature-space )
|
||||
# otherwise return empty
|
||||
}
|
||||
|
||||
#
|
||||
# Returns the result of 'expand' after appying feature default to it.
|
||||
#
|
||||
rule expand-with-defaults ( property-sets * : feature-space ? )
|
||||
{
|
||||
feature-space ?= feature ;
|
||||
local expanded = [ expand $(property-sets) : $(feature-space) ] ;
|
||||
local result = ;
|
||||
|
||||
for local p in $(expanded)
|
||||
{
|
||||
p = [ $(feature-space).split $(p) ] ;
|
||||
p = [ $(feature-space).add-defaults $(p) ] ;
|
||||
result += $(p:J=/) ;
|
||||
}
|
||||
return $(result) ;
|
||||
}
|
||||
|
||||
|
||||
# Takes the command line tokens (such as taken from ARGV rule) and constructs
|
||||
# build request from it.
|
||||
# Returns a vector of two vectors (where "vector" means container.jam's "vector").
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import project ;
|
||||
import sequence ;
|
||||
import modules ;
|
||||
import feature ;
|
||||
|
||||
import builtin ;
|
||||
import make ;
|
||||
@@ -17,7 +18,8 @@ build-request = [ build-request.from-command-line [ modules.peek : ARGV ] ] ;
|
||||
|
||||
targets = [ $(build-request).get-at 1 ] ;
|
||||
properties = [ $(build-request).get-at 2 ] ;
|
||||
expanded = [ build-request.expand $(properties) ] ;
|
||||
expanded = [ build-request.expand-with-defaults $(properties) ] ;
|
||||
|
||||
|
||||
root-target = [ $(current-project).target ] ;
|
||||
virtual-targets = ;
|
||||
|
||||
@@ -9,6 +9,7 @@ import feature : feature compose ;
|
||||
|
||||
feature toolset : gcc : implicit ;
|
||||
feature optimization : off on ;
|
||||
feature threading : single multi ;
|
||||
|
||||
feature variant : debug release : implicit composite ;
|
||||
compose <variant>debug : <optimization>off ;
|
||||
|
||||
@@ -198,7 +198,7 @@ rule basic-target ( name : project
|
||||
if ! $(properties)
|
||||
{
|
||||
# CONSIDER: I'm really not sure if this is correct...
|
||||
properties = [ build-request.expand $(self.default-build) ] ;
|
||||
properties = [ build-request.expand-with-defaults $(self.default-build) ] ;
|
||||
local result = ;
|
||||
for local p in $(properties)
|
||||
{
|
||||
|
||||
@@ -19,24 +19,25 @@ Please consult the documentation at 'http://www.boost.org'.
|
||||
t.set_tree("project-test3")
|
||||
t.run_build_system()
|
||||
|
||||
t.expect_addition("bin/debug/a.obj")
|
||||
t.expect_content("bin/debug/a.obj",
|
||||
"""debug
|
||||
t.expect_addition("bin/gcc/debug/threading-single/a.obj")
|
||||
t.expect_content("bin/gcc/debug/threading-single/a.obj",
|
||||
"""gcc/debug/threading-single
|
||||
a.cpp
|
||||
""")
|
||||
|
||||
t.expect_addition("bin/debug/a.exe")
|
||||
t.expect_content("bin/debug/a.exe",
|
||||
"""debug
|
||||
bin/debug/a.obj
|
||||
t.expect_addition("bin/gcc/debug/threading-single/a.exe")
|
||||
t.expect_content("bin/gcc/debug/threading-single/a.exe",
|
||||
"""gcc/debug/threading-single
|
||||
bin/gcc/debug/threading-single/a.obj
|
||||
""")
|
||||
|
||||
t.touch("a.cpp")
|
||||
t.run_build_system()
|
||||
t.expect_touch(["bin/debug/a.obj", "bin/debug/a.exe"])
|
||||
t.expect_touch(["bin/gcc/debug/threading-single/a.obj", "bin/gcc/debug/threading-single/a.exe"])
|
||||
|
||||
|
||||
t.run_build_system(extra_args="release optimization=off,on")
|
||||
t.expect_addition(["bin/release/a.exe", "bin/release/a.obj",
|
||||
"bin/release/optimization-off/a.exe",
|
||||
"bin/release/optimization-off/a.obj"])
|
||||
t.expect_addition([ "bin/gcc/release/threading-single/a.exe",
|
||||
"bin/gcc/release/threading-single/a.obj",
|
||||
"bin/gcc/release/optimization-off/threading-single/a.exe",
|
||||
"bin/gcc/release/optimization-off/threading-single/a.obj"])
|
||||
|
||||
@@ -96,6 +96,25 @@ local rule x-product ( property-sets * : feature-space )
|
||||
# otherwise return empty
|
||||
}
|
||||
|
||||
#
|
||||
# Returns the result of 'expand' after appying feature default to it.
|
||||
#
|
||||
rule expand-with-defaults ( property-sets * : feature-space ? )
|
||||
{
|
||||
feature-space ?= feature ;
|
||||
local expanded = [ expand $(property-sets) : $(feature-space) ] ;
|
||||
local result = ;
|
||||
|
||||
for local p in $(expanded)
|
||||
{
|
||||
p = [ $(feature-space).split $(p) ] ;
|
||||
p = [ $(feature-space).add-defaults $(p) ] ;
|
||||
result += $(p:J=/) ;
|
||||
}
|
||||
return $(result) ;
|
||||
}
|
||||
|
||||
|
||||
# Takes the command line tokens (such as taken from ARGV rule) and constructs
|
||||
# build request from it.
|
||||
# Returns a vector of two vectors (where "vector" means container.jam's "vector").
|
||||
|
||||
@@ -198,7 +198,7 @@ rule basic-target ( name : project
|
||||
if ! $(properties)
|
||||
{
|
||||
# CONSIDER: I'm really not sure if this is correct...
|
||||
properties = [ build-request.expand $(self.default-build) ] ;
|
||||
properties = [ build-request.expand-with-defaults $(self.default-build) ] ;
|
||||
local result = ;
|
||||
for local p in $(properties)
|
||||
{
|
||||
|
||||
@@ -19,24 +19,25 @@ Please consult the documentation at 'http://www.boost.org'.
|
||||
t.set_tree("project-test3")
|
||||
t.run_build_system()
|
||||
|
||||
t.expect_addition("bin/debug/a.obj")
|
||||
t.expect_content("bin/debug/a.obj",
|
||||
"""debug
|
||||
t.expect_addition("bin/gcc/debug/threading-single/a.obj")
|
||||
t.expect_content("bin/gcc/debug/threading-single/a.obj",
|
||||
"""gcc/debug/threading-single
|
||||
a.cpp
|
||||
""")
|
||||
|
||||
t.expect_addition("bin/debug/a.exe")
|
||||
t.expect_content("bin/debug/a.exe",
|
||||
"""debug
|
||||
bin/debug/a.obj
|
||||
t.expect_addition("bin/gcc/debug/threading-single/a.exe")
|
||||
t.expect_content("bin/gcc/debug/threading-single/a.exe",
|
||||
"""gcc/debug/threading-single
|
||||
bin/gcc/debug/threading-single/a.obj
|
||||
""")
|
||||
|
||||
t.touch("a.cpp")
|
||||
t.run_build_system()
|
||||
t.expect_touch(["bin/debug/a.obj", "bin/debug/a.exe"])
|
||||
t.expect_touch(["bin/gcc/debug/threading-single/a.obj", "bin/gcc/debug/threading-single/a.exe"])
|
||||
|
||||
|
||||
t.run_build_system(extra_args="release optimization=off,on")
|
||||
t.expect_addition(["bin/release/a.exe", "bin/release/a.obj",
|
||||
"bin/release/optimization-off/a.exe",
|
||||
"bin/release/optimization-off/a.obj"])
|
||||
t.expect_addition([ "bin/gcc/release/threading-single/a.exe",
|
||||
"bin/gcc/release/threading-single/a.obj",
|
||||
"bin/gcc/release/optimization-off/threading-single/a.exe",
|
||||
"bin/gcc/release/optimization-off/threading-single/a.obj"])
|
||||
|
||||
@@ -9,6 +9,7 @@ import feature : feature compose ;
|
||||
|
||||
feature toolset : gcc : implicit ;
|
||||
feature optimization : off on ;
|
||||
feature threading : single multi ;
|
||||
|
||||
feature variant : debug release : implicit composite ;
|
||||
compose <variant>debug : <optimization>off ;
|
||||
|
||||
Reference in New Issue
Block a user