diff --git a/v2/build-system.jam b/v2/build-system.jam index 93cb87bb4..6c530564e 100755 --- a/v2/build-system.jam +++ b/v2/build-system.jam @@ -26,6 +26,7 @@ import "class" : new ; import builtin ; import make ; import os ; +import option ; import version ; @@ -131,6 +132,10 @@ if --version in [ modules.peek : ARGV ] EXIT ; } + +option.process ; + + # We always load project in "." so that 'use-project' directives has # any chance of been seen. Otherwise, we won't be able to refer to # subprojects using target ids. diff --git a/v2/kernel/bootstrap.jam b/v2/kernel/bootstrap.jam index 1b47b7302..a4c5300d3 100755 --- a/v2/kernel/bootstrap.jam +++ b/v2/kernel/bootstrap.jam @@ -28,7 +28,6 @@ for local r in $(required-rules) local native = regex transform 2 ; - while $(native) { if ! [ HAS_NATIVE_RULE $(native[1]) : @@ -113,68 +112,6 @@ IMPORT modules : import : : import ; # import modules ; -# Check command-line args as soon as possible. For each option try -# to load module named after option. Is that succeeds, invoke 'process' -# rule in the module. The rule may return "true" to indicate that the -# regular built process should not be attempted. -# -# Options take the general form of: --[=] [] -# -local dont-build ; -local args = $(ARGV) ; -while $(args) -{ - local arg = [ MATCH ^--(.*) : $(args[1]) ] ; - while $(args[2-]) && ! $(arg) - { - args = $(args[2-]) ; - arg = [ MATCH ^--(.*) : $(args[1]) ] ; - } - args = $(args[2-]) ; - - if $(arg) - { - local split = [ MATCH ^(([^-=]+)[^=]*)(=?)(.*)$ : $(arg) ] ; - local full-name = $(split[1]) ; - local prefix = $(split[2]) ; - local values ; - - if $(split[3]) - { - values = $(split[4]) ; - } - if $(args) && ! [ MATCH ^(--).* : $(args[1]) ] - { - values += $(args[1]) ; - args = $(args[2-]) ; - } - - # look in options subdirectories of BOOST_BUILD_PATH for modules - # matching the full option name and then its prefix. - local plugin-dir = options ; - local option-files = [ - GLOB $(plugin-dir:D=$(BOOST_BUILD_PATH)) : $(full-name).jam $(prefix).jam - ] ; - - if $(option-files) - { - # load the file into a module named for the option - local f = $(option-files[1]) ; - local module-name = --$(f:D=:S=) ; - modules.load $(module-name) : $(f:D=) : $(f:D) ; - - # if there's a process rule, call it with the full option name - # and its value (if any). If there was no "=" in the option, - # the value will be empty. - if process in [ RULENAMES $(module-name) ] - { - dont-build += - [ modules.call-in $(module-name) : process --$(full-name) : $(values) ] ; - } - } - } -} - if ! $(dont-build) { # Allow users to override the build system file from the diff --git a/v2/util/option.jam b/v2/util/option.jam index dda4753bb..ead4da062 100644 --- a/v2/util/option.jam +++ b/v2/util/option.jam @@ -19,3 +19,73 @@ rule get ( name : default-value ? ) } } + +rule process ( ) +{ + # Check command-line args as soon as possible. For each option try + # to load module named after option. Is that succeeds, invoke 'process' + # rule in the module. The rule may return "true" to indicate that the + # regular built process should not be attempted. + # + # Options take the general form of: --[=] [] + # + + local ARGV = [ modules.peek : ARGV ] ; + local BOOST_BUILD_PATH = [ modules.peek : BOOST_BUILD_PATH ] ; + + local dont-build ; + local args = $(ARGV) ; + while $(args) + { + local arg = [ MATCH ^--(.*) : $(args[1]) ] ; + while $(args[2-]) && ! $(arg) + { + args = $(args[2-]) ; + arg = [ MATCH ^--(.*) : $(args[1]) ] ; + } + args = $(args[2-]) ; + + if $(arg) + { + local split = [ MATCH ^(([^-=]+)[^=]*)(=?)(.*)$ : $(arg) ] ; + local full-name = $(split[1]) ; + local prefix = $(split[2]) ; + local values ; + + if $(split[3]) + { + values = $(split[4]) ; + } + if $(args) && ! [ MATCH ^(--).* : $(args[1]) ] + { + values += $(args[1]) ; + args = $(args[2-]) ; + } + + # look in options subdirectories of BOOST_BUILD_PATH for modules + # matching the full option name and then its prefix. + local plugin-dir = options ; + local option-files = [ + GLOB $(plugin-dir:D=$(BOOST_BUILD_PATH)) : $(full-name).jam $(prefix).jam + ] ; + + if $(option-files) + { + # load the file into a module named for the option + local f = $(option-files[1]) ; + local module-name = --$(f:D=:S=) ; + modules.load $(module-name) : $(f:D=) : $(f:D) ; + + # if there's a process rule, call it with the full option name + # and its value (if any). If there was no "=" in the option, + # the value will be empty. + if process in [ RULENAMES $(module-name) ] + { + dont-build += + [ modules.call-in $(module-name) : process --$(full-name) : $(values) ] ; + } + } + } + } +} +