diff --git a/v2/build/targets.jam b/v2/build/targets.jam index 3d491100b..779f43146 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -1008,9 +1008,9 @@ class basic-target : abstract-target $(usage-requirements) ] ; usage-requirements = [ property-set.create $(usage-requirements) ] ; - local libs = [ $(rproperties).get ] ; - libs += [ $(rproperties).get ] ; - source-targets += $(libs:G=) ; + local extra = [ $(rproperties).get ] ; + extra += [ extra-sources $(rproperties) ] ; + source-targets += $(extra:G=) ; # We might get duplicate sources, for example if # we link to two library which have the same in # usage requirements. @@ -1125,6 +1125,13 @@ class basic-target : abstract-target { errors.error "method should be defined in derived classes" ; } + + # Returns extra targets which must be added to the list of sources + # used for building. Mainly, a hook for property. + rule extra-sources ( property-set ) + { + } + } class typed-target : basic-target diff --git a/v2/test/library_property.py b/v2/test/library_property.py new file mode 100644 index 000000000..1b95f7415 --- /dev/null +++ b/v2/test/library_property.py @@ -0,0 +1,63 @@ +#!/usr/bin/python + +# Copyright (C) Vladimir Prus 2004. 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. + +# Test that the property has no effect on "obj" targets. +# Previously, it affected all targets, so +# +# project : requirements foo ; +# exe a : a.cpp helper ; +# obj helper : helper.cpp : off ; +# +# caused 'foo' to be built with with and without optimization. +from BoostBuild import Tester, List + +# Create a temporary working directory +t = Tester() + +t.write("Jamfile", """ +project + : requirements lib//x + ; +exe a : a.cpp foo ; +obj foo : foo.cpp : release ; +""") + +t.write("a.cpp", """ +void aux(); +int main() { aux(); } +""") + +t.write("foo.cpp", """ +void gee(); +void aux() { gee(); } +""") + +t.write("project-root.jam", """ +""") + +t.write("lib/x.cpp", """ +void +#if defined(_WIN32) +__declspec(dllexport) +#endif +gee() {} +""") + +t.write("lib/Jamfile", """ +lib x : x.cpp ; +""") + +t.write("lib/project-root.jam", """ +""") + + +t.run_build_system() +t.expect_addition("bin/$toolset/debug/a.exe") +t.expect_nothing("lib/bin/$toolset/release/x.obj") +t.cleanup() + + diff --git a/v2/test/test_all.py b/v2/test/test_all.py index aad17e491..5b33e56f8 100644 --- a/v2/test/test_all.py +++ b/v2/test/test_all.py @@ -123,6 +123,7 @@ tests = [ "project_test1", "expansion", "wrapper", "duplicate", + "library_property", #"ordered_properties", ] diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index d6f47e0ed..a88263a79 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -429,6 +429,12 @@ class lib-target-class : basic-target return $(result) ; } + + rule extra-sources ( property-set ) + { + return [ $(property-set).get ] ; + } + } rule lib ( names + : sources * : requirements * : default-build * @@ -521,7 +527,10 @@ class exe-target-class : typed-target basic-target.check-for-unused-sources $(result) : $(sources-to-check) ; } - + rule extra-sources ( property-set ) + { + return [ $(property-set).get ] ; + } } rule exe ( name : sources * : requirements * : default-build *