From cb9dee8347f8ed1edb8d1117e39862dd137ec421 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 14 Nov 2001 21:24:42 +0000 Subject: [PATCH] initial commit [SVN r11695] --- new/assert.jam | 72 ++++++++++++++++++++++++++++++++++++++++++ new/boost-build.jam | 14 ++++++++ new/build-system.jam | 6 ++++ new/modules.jam | 66 ++++++++++++++++++++++++++++++++++++++ new/os.jam | 23 ++++++++++++++ new/os.path.jam | 9 ++++++ new/regex.jam | 34 ++++++++++++++++++++ v2/doc/boost-build.jam | 14 ++++++++ v2/modules.jam | 66 ++++++++++++++++++++++++++++++++++++++ v2/os.path.jam | 9 ++++++ v2/util/assert.jam | 72 ++++++++++++++++++++++++++++++++++++++++++ v2/util/os.jam | 23 ++++++++++++++ v2/util/regex.jam | 34 ++++++++++++++++++++ 13 files changed, 442 insertions(+) create mode 100644 new/assert.jam create mode 100644 new/boost-build.jam create mode 100644 new/build-system.jam create mode 100644 new/modules.jam create mode 100644 new/os.jam create mode 100644 new/os.path.jam create mode 100644 new/regex.jam create mode 100644 v2/doc/boost-build.jam create mode 100644 v2/modules.jam create mode 100644 v2/os.path.jam create mode 100644 v2/util/assert.jam create mode 100644 v2/util/os.jam create mode 100644 v2/util/regex.jam diff --git a/new/assert.jam b/new/assert.jam new file mode 100644 index 000000000..2327c0e67 --- /dev/null +++ b/new/assert.jam @@ -0,0 +1,72 @@ +# (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. + +rule report-module ( prefix ? : suffix ? ) +{ + # We report some large line number so that emacs, etc., will at least locate the file. + ECHO $(prefix) [ modules.binding [ CALLER_MODULE 1 ] ] ":" line 99999 $(suffix) ; +} + +rule equal ( a * : b * ) +{ + if $(a) != $(b) + { + report-module ; + EXIT assertion failure: \"$(a)\" "!=" \"$(b)\" ; + } +} + +rule Rule ( rule-name args * : expected * ) +{ + + module [ CALLER_MODULE ] + { + result = [ $(rule-name) $(args) ] ; + } + + if $(result) != $(expected) + { + report-module ; + ECHO assertion failure: "[" $(rule-name) \"$(args)\" "]" ; + ECHO expected: \"$(expected)\" ; + EXIT got: \"$(result)\" ; + } +} + +rule nonempty-variable ( name ) +{ + local empty ; + if $($(variable)) = $(empty) + { + report-module ; + EXIT assertion failure, expecting non-empty variable $(variable) ; + } +} + +rule true ( rule-name args * ) +{ + local result caller-module = [ CALLER_MODULE ] ; + + module $(caller-module) + { + result = [ $(rule-name) $(args) ] ; + } + + if ! $(result) + { + report-module ; + EXIT assertion failure, expecting true result from + "[" $(rule-name) \"$(args)\" "]" ; + } +} + +# Get around the capitalized naming (required to avoid a clash with the rule +# keyword) by importing Rule into the global namespace as assert.rule +IMPORT : assert : Rule : assert.rule ; + +rule __test__ ( ) +{ + # no tests yet for assertions +} diff --git a/new/boost-build.jam b/new/boost-build.jam new file mode 100644 index 000000000..9cb84df72 --- /dev/null +++ b/new/boost-build.jam @@ -0,0 +1,14 @@ +# (C) Copyright David Abrahams and Carlos Pinto Coelho 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. + +# Bootstrap the module system +SEARCH on modules.jam = $(BOOST_BUILD_PATH) ; +module modules { include modules.jam ; } +# Bring the import rule into the global module +IMPORT : modules : import ; +import modules ; # The modules module can tolerate being included twice + +import build-system ; diff --git a/new/build-system.jam b/new/build-system.jam new file mode 100644 index 000000000..ffc64c694 --- /dev/null +++ b/new/build-system.jam @@ -0,0 +1,6 @@ +# (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. + +import os ; diff --git a/new/modules.jam b/new/modules.jam new file mode 100644 index 000000000..d5444c0a5 --- /dev/null +++ b/new/modules.jam @@ -0,0 +1,66 @@ +# (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 imported-modules ; + +# meant to be invoked from +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 * ) +{ + + if ! ( $(module-name) in $(imported-modules) ) + { + imported-modules += $(module-name) ; + + module $(module-name) + { + IMPORT $(module-name) : modules : no_test_defined : __test__ ; + + 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 $(BOOST_BUILD_TEST) + { + ECHO testing module $(module-name)... ; + local ignored = [ __test__ ] ; + } + } + } + if $(rules-opt) + { + if $(rules-opt) = * + { + rules-opt = ; + } + IMPORT [ CALLER_MODULE ] + : $(module-name) : $(rules-opt) : $(rename-opt) ; + } +} + +rule record-binding ( module-target : binding ) +{ + module local $(module-target:G=:S=).__binding__ = $(binding) ; +} + diff --git a/new/os.jam b/new/os.jam new file mode 100644 index 000000000..e52413ee2 --- /dev/null +++ b/new/os.jam @@ -0,0 +1,23 @@ +# (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. + +module local name = $(OS) ; +module local platform = $(OSPLAT) ; +module local version = $(OSVER) ; + +rule name { return $(name) ; } +rule platform { return $(platform) ; } +rule version { return $(version) ; } + +import regex ; + +rule __test__ +{ + rule identity ( args * ) { return $(args) ; } + + ECHO os: name= [ name ] ; + ECHO os: version= [ version ] ; + assert.true name ; +} diff --git a/new/os.path.jam b/new/os.path.jam new file mode 100644 index 000000000..172598282 --- /dev/null +++ b/new/os.path.jam @@ -0,0 +1,9 @@ +# (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. + +rule split ( path ) +{ + +} \ No newline at end of file diff --git a/new/regex.jam b/new/regex.jam new file mode 100644 index 000000000..fe6a726ca --- /dev/null +++ b/new/regex.jam @@ -0,0 +1,34 @@ +# (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. + +rule split ( string separator ) +{ + local result ; + local s = $(string) ; + + while $(s) + { + local match = [ SUBST $(s) ^(.*)$(separator)(.*) $1 $2 ] ; + + local tail = $(match[2]) ; + tail ?= $(s) ; + + result = $(tail) $(result) ; + s = $(match[1]) ; + } + return $(result) ; +} + +rule __test__ ( ) +{ + import assert ; + + assert.rule split "a/b/c" / : a b c ; + assert.rule split "/a/b/c" / : a b c ; + assert.rule split "//a/b/c" / : "" a b c ; + assert.rule split "/a//b/c" / : a "" b c ; + assert.rule split "/a//b/c/" / : a "" b c "" ; + assert.rule split "/a//b/c//" / : a "" b c "" "" ; +} \ No newline at end of file diff --git a/v2/doc/boost-build.jam b/v2/doc/boost-build.jam new file mode 100644 index 000000000..9cb84df72 --- /dev/null +++ b/v2/doc/boost-build.jam @@ -0,0 +1,14 @@ +# (C) Copyright David Abrahams and Carlos Pinto Coelho 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. + +# Bootstrap the module system +SEARCH on modules.jam = $(BOOST_BUILD_PATH) ; +module modules { include modules.jam ; } +# Bring the import rule into the global module +IMPORT : modules : import ; +import modules ; # The modules module can tolerate being included twice + +import build-system ; diff --git a/v2/modules.jam b/v2/modules.jam new file mode 100644 index 000000000..d5444c0a5 --- /dev/null +++ b/v2/modules.jam @@ -0,0 +1,66 @@ +# (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 imported-modules ; + +# meant to be invoked from +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 * ) +{ + + if ! ( $(module-name) in $(imported-modules) ) + { + imported-modules += $(module-name) ; + + module $(module-name) + { + IMPORT $(module-name) : modules : no_test_defined : __test__ ; + + 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 $(BOOST_BUILD_TEST) + { + ECHO testing module $(module-name)... ; + local ignored = [ __test__ ] ; + } + } + } + if $(rules-opt) + { + if $(rules-opt) = * + { + rules-opt = ; + } + IMPORT [ CALLER_MODULE ] + : $(module-name) : $(rules-opt) : $(rename-opt) ; + } +} + +rule record-binding ( module-target : binding ) +{ + module local $(module-target:G=:S=).__binding__ = $(binding) ; +} + diff --git a/v2/os.path.jam b/v2/os.path.jam new file mode 100644 index 000000000..172598282 --- /dev/null +++ b/v2/os.path.jam @@ -0,0 +1,9 @@ +# (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. + +rule split ( path ) +{ + +} \ No newline at end of file diff --git a/v2/util/assert.jam b/v2/util/assert.jam new file mode 100644 index 000000000..2327c0e67 --- /dev/null +++ b/v2/util/assert.jam @@ -0,0 +1,72 @@ +# (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. + +rule report-module ( prefix ? : suffix ? ) +{ + # We report some large line number so that emacs, etc., will at least locate the file. + ECHO $(prefix) [ modules.binding [ CALLER_MODULE 1 ] ] ":" line 99999 $(suffix) ; +} + +rule equal ( a * : b * ) +{ + if $(a) != $(b) + { + report-module ; + EXIT assertion failure: \"$(a)\" "!=" \"$(b)\" ; + } +} + +rule Rule ( rule-name args * : expected * ) +{ + + module [ CALLER_MODULE ] + { + result = [ $(rule-name) $(args) ] ; + } + + if $(result) != $(expected) + { + report-module ; + ECHO assertion failure: "[" $(rule-name) \"$(args)\" "]" ; + ECHO expected: \"$(expected)\" ; + EXIT got: \"$(result)\" ; + } +} + +rule nonempty-variable ( name ) +{ + local empty ; + if $($(variable)) = $(empty) + { + report-module ; + EXIT assertion failure, expecting non-empty variable $(variable) ; + } +} + +rule true ( rule-name args * ) +{ + local result caller-module = [ CALLER_MODULE ] ; + + module $(caller-module) + { + result = [ $(rule-name) $(args) ] ; + } + + if ! $(result) + { + report-module ; + EXIT assertion failure, expecting true result from + "[" $(rule-name) \"$(args)\" "]" ; + } +} + +# Get around the capitalized naming (required to avoid a clash with the rule +# keyword) by importing Rule into the global namespace as assert.rule +IMPORT : assert : Rule : assert.rule ; + +rule __test__ ( ) +{ + # no tests yet for assertions +} diff --git a/v2/util/os.jam b/v2/util/os.jam new file mode 100644 index 000000000..e52413ee2 --- /dev/null +++ b/v2/util/os.jam @@ -0,0 +1,23 @@ +# (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. + +module local name = $(OS) ; +module local platform = $(OSPLAT) ; +module local version = $(OSVER) ; + +rule name { return $(name) ; } +rule platform { return $(platform) ; } +rule version { return $(version) ; } + +import regex ; + +rule __test__ +{ + rule identity ( args * ) { return $(args) ; } + + ECHO os: name= [ name ] ; + ECHO os: version= [ version ] ; + assert.true name ; +} diff --git a/v2/util/regex.jam b/v2/util/regex.jam new file mode 100644 index 000000000..fe6a726ca --- /dev/null +++ b/v2/util/regex.jam @@ -0,0 +1,34 @@ +# (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. + +rule split ( string separator ) +{ + local result ; + local s = $(string) ; + + while $(s) + { + local match = [ SUBST $(s) ^(.*)$(separator)(.*) $1 $2 ] ; + + local tail = $(match[2]) ; + tail ?= $(s) ; + + result = $(tail) $(result) ; + s = $(match[1]) ; + } + return $(result) ; +} + +rule __test__ ( ) +{ + import assert ; + + assert.rule split "a/b/c" / : a b c ; + assert.rule split "/a/b/c" / : a b c ; + assert.rule split "//a/b/c" / : "" a b c ; + assert.rule split "/a//b/c" / : a "" b c ; + assert.rule split "/a//b/c/" / : a "" b c "" ; + assert.rule split "/a//b/c//" / : a "" b c "" "" ; +} \ No newline at end of file