diff --git a/src/build/alias.jam b/src/build/alias.jam index 35bcfea61..d7d68a376 100644 --- a/src/build/alias.jam +++ b/src/build/alias.jam @@ -63,7 +63,7 @@ rule alias ( name : sources * : requirements * : default-build * : usage-require targets.main-target-alternative [ new alias-target-class $(name) : $(project) - : [ targets.main-target-sources $(sources) : $(name) ] + : [ targets.main-target-sources $(sources) : $(name) : no-renaming ] : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ] diff --git a/src/build/targets.jam b/src/build/targets.jam index 94bfc6b28..8f9134f32 100644 --- a/src/build/targets.jam +++ b/src/build/targets.jam @@ -1369,18 +1369,27 @@ class typed-target : basic-target # Return the list of sources to use, if main target rule is invoked # with 'sources'. If there are any objects in 'sources', they are treated -# as main target instances, and WRITEME. -rule main-target-sources ( sources * : main-target-name ) +# as main target instances, and the name of such targets are adjusted to +# be '__'. Such renaming +# is disabled is non-empty value is passed for 'no-renaming' parameter. +# +rule main-target-sources ( sources * : main-target-name : no-renaming ? ) { local result ; for local t in $(sources) { if [ class.is-instance $(t) ] { - local name = [ $(t).name ] ; - local new-name = $(main-target-name)__$(name) ; - $(t).rename $(new-name) ; - result += $(new-name) ; + local name = [ $(t).name ] ; + if ! $(no-renaming) + { + name = $(main-target-name)__$(name) ; + $(t).rename $(name) ; + } + # Inline targets are not built by default. + local p = [ $(t).project ] ; + $(p).mark-target-as-explicit $(name) ; + result += $(name) ; } else { diff --git a/src/tools/builtin.jam b/src/tools/builtin.jam index e96fcc645..26019df41 100644 --- a/src/tools/builtin.jam +++ b/src/tools/builtin.jam @@ -499,6 +499,7 @@ generators.register [ new lib-generator builtin.lib-generator : : LIB ] ; rule lib ( names + : sources * : requirements * : default-build * : usage-requirements * ) { + local result ; local project = [ project.current ] ; # This is a circular module dependency, so it must be imported here diff --git a/src/tools/python.jam b/src/tools/python.jam index 9f1389fce..7791e71fb 100644 --- a/src/tools/python.jam +++ b/src/tools/python.jam @@ -530,7 +530,16 @@ class python-test-generator : generator { if [ $(s).type ] = PY { - python = $(s) ; + if ! $(python) + { + # First Python source ends up on command line. + python = $(s) ; + } + else + { + # Other Python sources become dependencies. + property-set = [ $(property-set).add-raw $(s) ] ; + } } } diff --git a/src/tools/testing.jam b/src/tools/testing.jam index 8bb2612f1..542c9f525 100644 --- a/src/tools/testing.jam +++ b/src/tools/testing.jam @@ -155,19 +155,11 @@ rule run-fail ( sources + : args * : input-files * : requirements * : target-nam return [ make-test run-fail : $(sources) : $(requirements) : $(target-name) ] ; } -# Rule for grouping tests in suites. -rule test-suite ( suite-name : tests + ) -{ - # In V2, if 'tests' are instances of 'abstract-target', they will be considered - # 'inline-targets' and will suffer some adjustments. This will not be compatible - # with V1 behaviour, so we get names of 'tests' and use them. - local names ; - for local t in $(tests) - { - names += [ $(t).name ] ; - } - modules.call-in [ CALLER_MODULE ] : alias $(suite-name) : $(names) ; -} + +# Use 'test-suite' as synonym for 'alias', for backward compatibility. +IMPORT : alias : : test-suite ; + + # For all main target in 'project-module', # which are typed target with type derived from 'TEST', @@ -442,8 +434,8 @@ actions unit-test $(LAUNCHER) $(>) && $(MAKE_FILE) $(<) } -IMPORT $(__name__) : compile compile-fail test-suite run run-fail link link-fail - : : compile compile-fail test-suite run run-fail link link-fail ; +IMPORT $(__name__) : compile compile-fail run run-fail link link-fail + : : compile compile-fail run run-fail link link-fail ; type.register TIME : time ; diff --git a/test/inline.py b/test/inline.py index c35865cfe..45f0a5b8c 100644 --- a/test/inline.py +++ b/test/inline.py @@ -9,12 +9,13 @@ from BoostBuild import Tester, List t = Tester() -t.write("project-root.jam", "") -t.write("Jamfile", """ -alias everything : [ exe a : a.cpp ] ; +t.write("Jamroot", """ +project : requirements static ; +exe a : a.cpp [ lib helper : helper.cpp ] ; """) -t.write("a.cpp", """ +t.write("a.cpp", """ +extern void helper(); int main() { return 0; @@ -22,29 +23,49 @@ int main() """) -t.run_build_system() -t.expect_addition("bin/$toolset/debug/everything__a.exe") -t.rm("bin/$toolset/debug/everything__a.exe") +t.write("helper.cpp", """ +void helper() +{ +} +""") -t.run_build_system("everything__a") -t.expect_addition("bin/$toolset/debug/everything__a.exe") +t.run_build_system() +t.expect_addition("bin/$toolset/debug/link-static/a__helper.lib") +t.rm("bin/$toolset/debug/link-static/a__helper.lib") + +t.run_build_system("a__helper") +t.expect_addition("bin/$toolset/debug/link-static/a__helper.lib") t.rm("bin") # Now check that inline targets with the same name but # present in different places are not confused between # each other, and with top-level targets. -t.write("Jamfile", """ -exe a : a.cpp ; -alias everything : [ exe a : a.cpp ] ; -alias everything2 : [ exe a : a.cpp ] ; +t.write("Jamroot", """ +project : requirements static ; +exe a : a.cpp [ lib helper : helper.cpp ] ; +exe a2 : a.cpp [ lib helper : helper.cpp ] ; """) t.run_build_system() -t.expect_addition("bin/$toolset/debug/a.exe") -t.expect_addition("bin/$toolset/debug/everything__a.exe") -t.expect_addition("bin/$toolset/debug/everything2__a.exe") +t.expect_addition("bin/$toolset/debug/link-static/a.exe") +t.expect_addition("bin/$toolset/debug/link-static/a__helper.lib") +t.expect_addition("bin/$toolset/debug/link-static/a2__helper.lib") +# Check that the 'alias' target does not change name of +# inline targets, and that inline targets are explicit. +t.write("Jamroot", """ +project : requirements static ; +alias a : [ lib helper : helper.cpp ] ; +explicit a ; +""") +t.rm("bin") + +t.run_build_system() +t.expect_nothing_more() + +t.run_build_system("a") +t.expect_addition("bin/$toolset/debug/link-static/helper.lib") t.cleanup()