diff --git a/v2/build/project.jam b/v2/build/project.jam index 3e62546be..2f1b60034 100644 --- a/v2/build/project.jam +++ b/v2/build/project.jam @@ -876,7 +876,11 @@ module project-rules rule explicit ( target-names * ) { import project ; - local t = [ project.target $(__name__) ] ; + # If 'explicit' is used in a helper rule defined in Jamroot, + # and inherited by children, then most of the time + # we want 'explicit' to operate on the Jamfile where + # the helper rule is invoked. + local t = [ project.current ] ; for local n in $(target-names) { $(t).mark-target-as-explicit $(n) ; diff --git a/v2/test/explicit.py b/v2/test/explicit.py index 23d4f3cba..616ce9248 100644 --- a/v2/test/explicit.py +++ b/v2/test/explicit.py @@ -36,5 +36,40 @@ t.expect_nothing_more() t.run_build_system("hello2") t.expect_addition("bin/$toolset/debug/hello2.exe") +t.rm(".") + + +# Test that 'explicit' used in a helper rule applies to the current project, +# and not to the Jamfile where the helper rule is defined. +t.write("Jamroot", """ +rule myinstall ( name : target ) +{ + install $(name)-bin : $(target) ; + explicit $(name)-bin ; + alias $(name) : $(name)-bin ; +} +""") + +t.write("sub/a.cpp", """ +""") + +t.write("sub/Jamfile", """ +myinstall dist : a.cpp ; +""") + +t.run_build_system(subdir="sub") +t.expect_addition("sub/dist-bin/a.cpp") + +t.rm("sub/dist-bin") + +t.write("sub/Jamfile", """ +myinstall dist : a.cpp ; +explicit dist ; + +""") + +t.run_build_system(subdir="sub") +t.expect_nothing_more() + t.cleanup()