diff --git a/v2/test/dll_path.py b/v2/test/dll_path.py new file mode 100644 index 000000000..0d979f17f --- /dev/null +++ b/v2/test/dll_path.py @@ -0,0 +1,128 @@ +#!/usr/bin/python + +# Copyright (C) Vladimir Prus 2003. 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 is correctly set when using +# true. +from BoostBuild import Tester, List +from string import find + + +t = Tester() + +# The point of this test is to have exe "main" which uses library "b", +# which uses library "a". When "main" is built with true, +# paths to both libraries should be present as values of feature. +# We create a special target type which reports values on its sources +# and compare the list of found values with out expectations. + +t.write("Jamfile", """ +exe main : main.cpp b//b ; +explicit main ; + +path-list mp : main ; +""") + +t.write("main.cpp", """ +int main() { return 0; } + +""") + +t.write("project-root.jam", """ +using dll-paths ; +""") + +t.write("dll-paths.jam", """ +import type ; +import generators ; +import feature ; +import sequence ; +import print ; +import "class" : new ; + +rule init ( ) +{ + type.register PATH_LIST : pathlist : : main ; + + class dll-paths-list-generator : generator + { + rule __init__ ( ) + { + generator.__init__ dll-paths.list : EXE : PATH_LIST ; + } + + rule generated-targets ( sources + : property-set : project name ? ) + { + local dll-paths ; + for local s in $(sources) + { + local a = [ $(s).action ] ; + if $(a) + { + local p = [ $(a).properties ] ; + dll-paths += [ $(p).get ] ; + } + } + return [ generator.generated-targets $(sources) + : [ $(property-set).add-raw $(dll-paths:G=) ] : $(project) $(name) ] ; + + } + } + generators.register [ new dll-paths-list-generator ] ; + +} + +rule list ( target : sources * : properties * ) +{ + local paths = [ feature.get-values : $(properties) ] ; + paths = [ sequence.insertion-sort $(paths) ] ; + print.output $(target) ; + print.text $(paths) ; +} + +""") + +t.write("a/a.cpp", """ +void +#if defined(_WIN32) +__declspec(dllexport) +#endif +foo() {} + + +""") + +t.write("a/Jamfile", """ +lib a : a.cpp ; +""") + +t.write("b/b.cpp", """ +void +#if defined(_WIN32) +__declspec(dllexport) +#endif +bar() {} + + +""") + +t.write("b/Jamfile", """ +lib b : b.cpp ../a//a ; +""") + +t.run_build_system("hardcode-dll-paths=true") + +t.expect_addition("bin/$toolset/debug/mp.pathlist") + +es1 = t.adjust_names(["a/bin/$toolset/debug"])[0] +es2 = t.adjust_names(["b/bin/$toolset/debug"])[0] +content = t.read("bin/$toolset/debug/mp.pathlist") + +t.fail_test(find(content, es1) == -1) +t.fail_test(find(content, es2) == -1) + +t.cleanup() + diff --git a/v2/test/test_all.py b/v2/test/test_all.py index 5fd20e80c..6cc9ef6fe 100644 --- a/v2/test/test_all.py +++ b/v2/test/test_all.py @@ -108,6 +108,7 @@ tests = [ "project_test1", "glob", "project_root_constants", "double_loading", + "dll_path", ] if os.name == 'posix': diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 4b900659b..2ac9854de 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -460,9 +460,17 @@ class lib-target-class : basic-target { result = [ $(result).add [ property-set.create $(paths:G=) ] ] ; - } + } } - + + # Pass features that we've got from sources. + if true in $(raw) + { + local u = [ $(subvariant).sources-usage-requirements ] ; + local values = [ $(u).get ] ; + result = [ $(result).add-raw $(values:G=) ] ; + } + return $(result) ; }