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 the 'glob' rule in Jamfile context. |
---|
9 | from BoostBuild import Tester, List |
---|
10 | import os |
---|
11 | import string |
---|
12 | |
---|
13 | # Create a temporary working directory |
---|
14 | t = Tester() |
---|
15 | |
---|
16 | t.write("project-root.jam", """ |
---|
17 | """) |
---|
18 | |
---|
19 | t.write("Jamfile", """ |
---|
20 | """) |
---|
21 | |
---|
22 | t.write("d1/a.cpp", """ |
---|
23 | int main() { return 0; } |
---|
24 | |
---|
25 | """) |
---|
26 | |
---|
27 | t.write("d1/Jamfile", """ |
---|
28 | exe a : [ glob *.cpp ] ../d2/d//l ; |
---|
29 | """) |
---|
30 | |
---|
31 | t.write("d2/d/l.cpp", """ |
---|
32 | #if defined(_WIN32) |
---|
33 | __declspec(dllexport) |
---|
34 | void force_import_lib_creation() {} |
---|
35 | #endif |
---|
36 | """) |
---|
37 | |
---|
38 | t.write("d2/d/Jamfile", """ |
---|
39 | lib l : [ glob *.cpp ] ; |
---|
40 | """) |
---|
41 | |
---|
42 | t.write("d3/d/Jamfile", """ |
---|
43 | exe a : [ glob ../*.cpp ] ; |
---|
44 | """) |
---|
45 | t.write("d3/a.cpp", """ |
---|
46 | int main() |
---|
47 | { |
---|
48 | return 0; |
---|
49 | } |
---|
50 | """) |
---|
51 | |
---|
52 | t.run_build_system(subdir="d1") |
---|
53 | t.expect_addition("d1/bin/$toolset/debug/a.exe") |
---|
54 | |
---|
55 | t.run_build_system(subdir="d3/d") |
---|
56 | t.expect_addition("d3/d/bin/$toolset/debug/a.exe") |
---|
57 | |
---|
58 | t.rm("d2/d/bin") |
---|
59 | t.run_build_system(subdir="d2/d") |
---|
60 | t.expect_addition("d2/d/bin/$toolset/debug/l.dll") |
---|
61 | |
---|
62 | # Test that when 'source-location' is explicitly-specified |
---|
63 | # glob works relatively to source location |
---|
64 | t.rm("d1") |
---|
65 | |
---|
66 | t.write("d1/src/a.cpp", """ |
---|
67 | int main() { return 0; } |
---|
68 | |
---|
69 | """) |
---|
70 | |
---|
71 | t.write("d1/Jamfile", """ |
---|
72 | project : source-location src ; |
---|
73 | exe a : [ glob *.cpp ] ../d2/d//l ; |
---|
74 | """) |
---|
75 | |
---|
76 | t.run_build_system(subdir="d1") |
---|
77 | t.expect_addition("d1/bin/$toolset/debug/a.exe") |
---|
78 | |
---|
79 | # Test that wildcards can include directories |
---|
80 | t.rm("d1") |
---|
81 | |
---|
82 | t.write("d1/src/foo/a.cpp", """ |
---|
83 | void bar(); |
---|
84 | int main() { bar(); return 0; } |
---|
85 | |
---|
86 | """) |
---|
87 | |
---|
88 | t.write("d1/src/bar/b.cpp", """ |
---|
89 | void bar() {} |
---|
90 | |
---|
91 | """) |
---|
92 | |
---|
93 | |
---|
94 | t.write("d1/Jamfile", """ |
---|
95 | project : source-location src ; |
---|
96 | exe a : [ glob foo/*.cpp bar/*.cpp ] ../d2/d//l ; |
---|
97 | """) |
---|
98 | |
---|
99 | t.run_build_system(subdir="d1") |
---|
100 | t.expect_addition("d1/bin/$toolset/debug/a.exe") |
---|
101 | |
---|
102 | # Test that 'glob' works with absolute names |
---|
103 | t.rm("d1/bin") |
---|
104 | |
---|
105 | # Note that to get current dir, we use bjam's PWD, |
---|
106 | # not Python's os.getcwd, because the former will |
---|
107 | # always return long path. The latter might return |
---|
108 | # short path, and that will confuse path.glob. |
---|
109 | t.write("d1/Jamfile", """ |
---|
110 | project : source-location src ; |
---|
111 | local pwd = [ PWD ] ; # Always absolute |
---|
112 | exe a : [ glob $(pwd)/src/foo/*.cpp $(pwd)/src/bar/*.cpp ] ../d2/d//l ; |
---|
113 | """) |
---|
114 | |
---|
115 | t.run_build_system(subdir="d1") |
---|
116 | t.expect_addition("d1/bin/$toolset/debug/a.exe") |
---|
117 | |
---|
118 | |
---|
119 | t.cleanup() |
---|