1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and |
---|
4 | # distribute this software is granted provided this copyright notice appears in |
---|
5 | # all copies. This software is provided "as is" without express or implied |
---|
6 | # warranty, and with no claim as to its suitability for any purpose. |
---|
7 | |
---|
8 | # Test that the <dll-path> property is correctly set when using |
---|
9 | # <hardcode-dll-paths>true. |
---|
10 | from BoostBuild import Tester, List |
---|
11 | from string import find |
---|
12 | |
---|
13 | |
---|
14 | t = Tester() |
---|
15 | |
---|
16 | # The point of this test is to have exe "main" which uses library "b", |
---|
17 | # which uses library "a". When "main" is built with <hardcode-dll-paths>true, |
---|
18 | # paths to both libraries should be present as values of <dll-path> feature. |
---|
19 | # We create a special target type which reports <dll-path> values on its sources |
---|
20 | # and compare the list of found values with out expectations. |
---|
21 | |
---|
22 | t.write("Jamfile", """ |
---|
23 | exe main : main.cpp b//b ; |
---|
24 | explicit main ; |
---|
25 | |
---|
26 | path-list mp : main ; |
---|
27 | """) |
---|
28 | |
---|
29 | t.write("main.cpp", """ |
---|
30 | int main() { return 0; } |
---|
31 | |
---|
32 | """) |
---|
33 | |
---|
34 | t.write("project-root.jam", """ |
---|
35 | using dll-paths ; |
---|
36 | """) |
---|
37 | |
---|
38 | t.write("dll-paths.jam", """ |
---|
39 | import type ; |
---|
40 | import generators ; |
---|
41 | import feature ; |
---|
42 | import sequence ; |
---|
43 | import print ; |
---|
44 | import "class" : new ; |
---|
45 | |
---|
46 | rule init ( ) |
---|
47 | { |
---|
48 | type.register PATH_LIST : pathlist ; |
---|
49 | |
---|
50 | class dll-paths-list-generator : generator |
---|
51 | { |
---|
52 | rule __init__ ( ) |
---|
53 | { |
---|
54 | generator.__init__ dll-paths.list : EXE : PATH_LIST ; |
---|
55 | } |
---|
56 | |
---|
57 | rule generated-targets ( sources + : property-set : project name ? ) |
---|
58 | { |
---|
59 | local dll-paths ; |
---|
60 | for local s in $(sources) |
---|
61 | { |
---|
62 | local a = [ $(s).action ] ; |
---|
63 | if $(a) |
---|
64 | { |
---|
65 | local p = [ $(a).properties ] ; |
---|
66 | dll-paths += [ $(p).get <dll-path> ] ; |
---|
67 | } |
---|
68 | } |
---|
69 | return [ generator.generated-targets $(sources) |
---|
70 | : [ $(property-set).add-raw $(dll-paths:G=<dll-path>) ] : $(project) $(name) ] ; |
---|
71 | |
---|
72 | } |
---|
73 | } |
---|
74 | generators.register [ new dll-paths-list-generator ] ; |
---|
75 | |
---|
76 | } |
---|
77 | |
---|
78 | rule list ( target : sources * : properties * ) |
---|
79 | { |
---|
80 | local paths = [ feature.get-values <dll-path> : $(properties) ] ; |
---|
81 | paths = [ sequence.insertion-sort $(paths) ] ; |
---|
82 | print.output $(target) ; |
---|
83 | print.text $(paths) ; |
---|
84 | } |
---|
85 | |
---|
86 | """) |
---|
87 | |
---|
88 | t.write("a/a.cpp", """ |
---|
89 | void |
---|
90 | #if defined(_WIN32) |
---|
91 | __declspec(dllexport) |
---|
92 | #endif |
---|
93 | foo() {} |
---|
94 | |
---|
95 | |
---|
96 | """) |
---|
97 | |
---|
98 | t.write("a/Jamfile", """ |
---|
99 | lib a : a.cpp ; |
---|
100 | """) |
---|
101 | |
---|
102 | t.write("b/b.cpp", """ |
---|
103 | void |
---|
104 | #if defined(_WIN32) |
---|
105 | __declspec(dllexport) |
---|
106 | #endif |
---|
107 | bar() {} |
---|
108 | |
---|
109 | |
---|
110 | """) |
---|
111 | |
---|
112 | t.write("b/Jamfile", """ |
---|
113 | lib b : b.cpp ../a//a ; |
---|
114 | """) |
---|
115 | |
---|
116 | t.run_build_system("hardcode-dll-paths=true") |
---|
117 | |
---|
118 | t.expect_addition("bin/$toolset/debug/mp.pathlist") |
---|
119 | |
---|
120 | es1 = t.adjust_names(["a/bin/$toolset/debug"])[0] |
---|
121 | es2 = t.adjust_names(["b/bin/$toolset/debug"])[0] |
---|
122 | content = t.read("bin/$toolset/debug/mp.pathlist") |
---|
123 | |
---|
124 | t.fail_test(find(content, es1) == -1) |
---|
125 | t.fail_test(find(content, es2) == -1) |
---|
126 | |
---|
127 | t.cleanup() |
---|
128 | |
---|