2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-12 12:02:24 +00:00
Files
build/modules.jam
Dave Abrahams bc99a39bf0 some small progress made
[SVN r11760]
2001-11-21 04:47:44 +00:00

93 lines
2.8 KiB
Plaintext

# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
# distribute this software is granted provided this copyright notice appears in
# all copies. This software is provided "as is" without express or implied
# warranty, and with no claim as to its suitability for any purpose.
# Keep a record so that no module is included multiple times
module local loaded-modules ;
# meant to be invoked from import when no __test__ rule is defined in a given
# module
local rule no_test_defined
{
ECHO warning: no __test__ rule defined in module [ CALLER_MODULE ] ;
}
# return the binding of the given module
rule binding ( module )
{
return $($(module).__binding__) ;
}
# load the indicated module. Any members of rules-opt will be available without
# qualification in the caller's module. Any members of rename-opt will be taken
# as the names of the rules in the caller's module, in place of the names they
# have in the imported module. If rules-opt = '*', all rules from the indicated
# module are imported into the caller's module.
rule import ( module-name : rules-opt * : rename-opt * )
{
# First see if the module needs to be loaded
if ! ( $(module-name) in $(loaded-modules) )
{
loaded-modules += $(module-name) ;
module $(module-name)
{
module local __name__ = $(module-name) ;
# Prepare a default behavior, in case no __test__ is defined.
IMPORT $(module-name) : modules : no_test_defined : __test__ ;
# Add some grist so that the module will have a unique target name
local module-target = $(module-name:G=module@:S=.jam) ;
SEARCH on $(module-target) = $(BOOST_BUILD_PATH) ;
BINDRULE on $(module-target) = modules.record-binding ;
include $(module-name:G=module@:S=.jam) ;
# run the module's test, if any.
if nonempty$(BOOST_BUILD_TEST)
{
ECHO testing module $(module-name)... ;
local ignored = [ __test__ ] ;
}
}
}
# If any rules are to be imported, do so now.
if $(rules-opt)
{
if $(rules-opt) = *
{
rules-opt = ;
}
IMPORT [ CALLER_MODULE ]
: $(module-name) : $(rules-opt) : $(rename-opt) ;
}
}
# This helper is used by import (above) to record the binding (path) of
# each loaded module.
rule record-binding ( module-target : binding )
{
module local $(module-target:G=:S=).__binding__ = $(binding) ;
}
# Returns the module-local value of a variable.
rule peek ( module-name variable )
{
module $(module-name)
{
return $($(variable)) ;
}
}
rule __test__ ( )
{
import assert ;
module modules.__test__
{
module local foo = bar ;
}
assert.result bar : peek modules.__test__ foo ;
}