From 0bfc1049ee5d0cc31ce622bb52a1236da0f2e9d6 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 5 Jul 2002 15:09:28 +0000 Subject: [PATCH] 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] --- new/build-request.jam | 19 +++++++++++++++++++ new/build-system.jam | 4 +++- new/builtin.jam | 1 + new/targets.jam | 2 +- test/project_test3.py | 23 ++++++++++++----------- v2/build/build-request.jam | 19 +++++++++++++++++++ v2/build/targets.jam | 2 +- v2/test/project_test3.py | 23 ++++++++++++----------- v2/tools/builtin.jam | 1 + 9 files changed, 69 insertions(+), 25 deletions(-) diff --git a/new/build-request.jam b/new/build-request.jam index b5f82757c..796dfcf62 100644 --- a/new/build-request.jam +++ b/new/build-request.jam @@ -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"). diff --git a/new/build-system.jam b/new/build-system.jam index 90c6e1227..ebf246640 100644 --- a/new/build-system.jam +++ b/new/build-system.jam @@ -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 = ; diff --git a/new/builtin.jam b/new/builtin.jam index ffca7fdd1..45b3006a2 100644 --- a/new/builtin.jam +++ b/new/builtin.jam @@ -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 debug : off ; diff --git a/new/targets.jam b/new/targets.jam index 3af5dce1a..17dd22c6d 100644 --- a/new/targets.jam +++ b/new/targets.jam @@ -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) { diff --git a/test/project_test3.py b/test/project_test3.py index 71678abd8..d09f12c61 100644 --- a/test/project_test3.py +++ b/test/project_test3.py @@ -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"]) diff --git a/v2/build/build-request.jam b/v2/build/build-request.jam index b5f82757c..796dfcf62 100644 --- a/v2/build/build-request.jam +++ b/v2/build/build-request.jam @@ -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"). diff --git a/v2/build/targets.jam b/v2/build/targets.jam index 3af5dce1a..17dd22c6d 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -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) { diff --git a/v2/test/project_test3.py b/v2/test/project_test3.py index 71678abd8..d09f12c61 100644 --- a/v2/test/project_test3.py +++ b/v2/test/project_test3.py @@ -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"]) diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index ffca7fdd1..45b3006a2 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -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 debug : off ;