From 0e6cb164f787fe47ade89e30f380d5ed72b255da Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 8 Dec 2006 14:27:09 +0000 Subject: [PATCH] handle comma-separated toolsets [SVN r36301] --- src/build-system.jam | 100 ++++++++++++++++++++++--------------------- src/util/regex.jam | 12 ++++++ 2 files changed, 63 insertions(+), 49 deletions(-) diff --git a/src/build-system.jam b/src/build-system.jam index f32460469..f938aa00e 100755 --- a/src/build-system.jam +++ b/src/build-system.jam @@ -23,6 +23,7 @@ import errors : error ; import virtual-target ; import "class" : new ; import toolset ; +import regex ; import builtin ; import make ; @@ -123,68 +124,69 @@ module user-config load-config user-config : $(user-path) ; # -# Autoconfigure toolsets based on any instances of --toolset=xxx or -# toolset=xxx in the command line +# Autoconfigure toolsets based on any instances of --toolset=xx,yy,...zz or +# toolset=xx,yy,...zz in the command line # local argv = [ modules.peek : ARGV ] ; -local toolset-version = [ MATCH ^-?-?toolset=(.*) : $(argv) ] ; -# if the user specified --toolset=..., we need to add toolset=... to -# the build request -local extra-build-request ; +local option-toolsets = [ regex.split-list [ MATCH ^--toolset=(.*) : $(argv) ] : "," ] ; +local feature-toolsets = [ regex.split-list [ MATCH ^toolset=(.*) : $(argv) ] : "," ] ; -if $(toolset-version) && ! $(ignore-config) +if ! $(ignore-config) { - local toolset = [ MATCH ([^-]+).* : $(toolset-version) ] ; - local version = [ MATCH [^-]+-(.+) : $(toolset-version) ] ; - - if $(debug-config) - { - ECHO notice: [cmdline-cfg] Detected command-line request for - $(toolset-version): toolset= \"$(toolset)\" "version= \""$(version)\" ; - } - - local known ; - - # if the toolset isn't known, configure it now. - if $(toolset) in [ feature.values ] - { - known = true ; - } - - if $(known) && $(version) - && ! [ feature.is-subvalue toolset : $(toolset) : version : $(version) ] - { - known = ; - } - - if ! $(known) + for local toolset-version in $(option-toolsets) $(feature-toolsets) { + local toolset = [ MATCH ([^-]+).* : $(toolset-version) ] ; + local version = [ MATCH [^-]+-(.+) : $(toolset-version) ] ; + if $(debug-config) { - ECHO notice: [cmdline-cfg] toolset $(toolset-version) - not previously configured; configuring now ; + ECHO notice: [cmdline-cfg] Detected command-line request for + $(toolset-version): toolset= \"$(toolset)\" "version= \""$(version)\" ; } - toolset.using $(toolset) : $(version) ; - } - else - { - if $(debug-config) + + local known ; + + # if the toolset isn't known, configure it now. + if $(toolset) in [ feature.values ] { - ECHO notice: [cmdline-cfg] toolset $(toolset-version) already configured ; + known = true ; } - } - - # make sure we get an appropriate property in the build request into - # case the user used the "--toolset=..." form - if ! $(toolset-version) in $(argv) - && ! toolset=$(toolset-version) in $(argv) - { - if $(debug-config) + + if $(known) && $(version) + && ! [ feature.is-subvalue toolset : $(toolset) : version : $(version) ] { - ECHO notice: [cmdline-cfg] adding toolset=$(toolset-version) "to build request." ; + known = ; + } + + if ! $(known) + { + if $(debug-config) + { + ECHO notice: [cmdline-cfg] toolset $(toolset-version) + not previously configured; configuring now ; + } + toolset.using $(toolset) : $(version) ; + } + else + { + if $(debug-config) + { + ECHO notice: [cmdline-cfg] toolset $(toolset-version) already configured ; + } + } + + # make sure we get an appropriate property into the build request in + # case the user used the "--toolset=..." form + if ! $(toolset-version) in $(argv) + && ! $(toolset-version) in $(feature-toolsets) + { + if $(debug-config) + { + ECHO notice: [cmdline-cfg] adding toolset=$(toolset-version) "to build request." ; + } + extra-build-request += toolset=$(toolset-version) ; } - extra-build-request += toolset=$(toolset-version) ; } } diff --git a/src/util/regex.jam b/src/util/regex.jam index c805abb2c..1b59f86a8 100644 --- a/src/util/regex.jam +++ b/src/util/regex.jam @@ -34,6 +34,18 @@ rule split ( string separator ) return $(s) $(result) ; } +# Returns the concatenated results of Applying regex.split to every +# element of list using the separator pattern. +rule split-list ( list * : separator ) +{ + local result ; + for s in $(list) + { + result += [ split $(s) $(separator) ] ; + } + return $(result) ; +} + # Match string against pattern, and return the elements indicated by # indices. rule match ( pattern : string : indices * )