]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/python |
2 | ||
3 | # Copyright 2003 Dave Abrahams | |
4 | # Copyright 2002, 2003, 2004 Vladimir Prus | |
5 | # Distributed under the Boost Software License, Version 1.0. | |
6 | # (See accompanying file LICENSE_1_0.txt or copy at | |
7 | # http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | import BoostBuild | |
10 | ||
11 | def test_basic(): | |
12 | t = BoostBuild.Tester(use_test_config=False) | |
13 | ||
14 | t.write("jamroot.jam", "lib a : a.cpp : <include>. ;") | |
15 | t.write("a.cpp", """\ | |
16 | #include <a.h> | |
17 | void | |
18 | # ifdef _WIN32 | |
19 | __declspec(dllexport) | |
20 | # endif | |
21 | foo() {} | |
22 | """) | |
23 | t.write("a.h", "//empty file\n") | |
24 | t.write("d/jamfile.jam", "exe b : b.cpp ..//a ;") | |
25 | t.write("d/b.cpp", """\ | |
26 | void foo(); | |
27 | int main() { foo(); } | |
28 | """) | |
29 | t.run_build_system(subdir="d") | |
30 | ||
31 | # Path features with condition. | |
32 | t.write("jamroot.jam", "lib a : a.cpp : <variant>debug:<include>. ;") | |
33 | t.rm("bin") | |
34 | t.run_build_system(subdir="d") | |
35 | ||
36 | ||
37 | # Path features with condition in usage requirements. | |
38 | t.write("jamroot.jam", """\ | |
39 | lib a : a.cpp : <include>. : : <variant>debug:<include>. ; | |
40 | """) | |
41 | t.write("d/b.cpp", """\ | |
42 | #include <a.h> | |
43 | void foo(); | |
44 | int main() { foo(); } | |
45 | """) | |
46 | t.rm("d/bin") | |
47 | t.run_build_system(subdir="d") | |
48 | ||
49 | t.cleanup() | |
50 | ||
51 | ||
52 | def test_absolute_paths(): | |
53 | """ | |
54 | Test that absolute paths inside requirements are ok. The problems | |
55 | appeared only when building targets in subprojects. | |
56 | ||
57 | """ | |
58 | t = BoostBuild.Tester(use_test_config=False) | |
59 | ||
60 | t.write("jamroot.jam", "build-project x ;") | |
61 | t.write("x/jamfile.jam", """\ | |
62 | local pwd = [ PWD ] ; | |
63 | project : requirements <include>$(pwd)/x/include ; | |
64 | exe m : m.cpp : <include>$(pwd)/x/include2 ; | |
65 | """) | |
66 | t.write("x/m.cpp", """\ | |
67 | #include <h1.hpp> | |
68 | #include <h2.hpp> | |
69 | int main() {} | |
70 | """) | |
71 | t.write("x/include/h1.hpp", "\n") | |
72 | t.write("x/include2/h2.hpp", "\n") | |
73 | ||
74 | t.run_build_system() | |
75 | t.expect_addition("x/bin/$toolset/debug/m.exe") | |
76 | ||
77 | t.cleanup() | |
78 | ||
79 | ||
80 | def test_ordered_paths(): | |
81 | """Test that "&&" in path features is handled correctly.""" | |
82 | ||
83 | t = BoostBuild.Tester(use_test_config=False) | |
84 | ||
85 | t.write("jamroot.jam", "build-project sub ;") | |
86 | t.write("sub/jamfile.jam", "exe a : a.cpp : <include>../h1&&../h2 ;") | |
87 | t.write("sub/a.cpp", """\ | |
88 | #include <header.h> | |
89 | int main() { return OK; } | |
90 | """) | |
91 | t.write("h2/header.h", "int const OK = 0;\n") | |
92 | t.run_build_system() | |
93 | t.expect_addition("sub/bin/$toolset/debug/a.exe") | |
94 | ||
95 | t.cleanup() | |
96 | ||
97 | ||
98 | def test_paths_set_by_indirect_conditionals(): | |
99 | t = BoostBuild.Tester(pass_d0=False, use_test_config=False) | |
100 | ||
101 | header = "child_dir/folder_to_include/some_header.h" | |
102 | ||
103 | t.write("jamroot.jam", "build-project child_dir ;") | |
104 | t.write("child_dir/jamfile.jam", """\ | |
105 | import remote/remote ; | |
106 | ||
107 | # If we set the <include>folder_to_include property directly, it will work | |
108 | obj x1 : x.cpp : <conditional>@attach-include-local ; | |
109 | obj x2 : x.cpp : <conditional>@remote.attach-include-remote ; | |
110 | ||
111 | rule attach-include-local ( properties * ) | |
112 | { | |
113 | return <include>folder_to_include ; | |
114 | } | |
115 | """) | |
116 | t.write("child_dir/remote/remote.jam", """\ | |
117 | rule attach-include-remote ( properties * ) | |
118 | { | |
119 | return <include>folder_to_include ; | |
120 | } | |
121 | """) | |
122 | t.write("child_dir/x.cpp", """\ | |
123 | #include <some_header.h> | |
124 | int main() {} | |
125 | """) | |
126 | t.write(header, "int some_func();\n") | |
127 | t.write("child_dir/folder_to_include/jamfile.jam", "") | |
128 | ||
129 | expected_x1 = "child_dir/bin/$toolset/debug/x1.obj" | |
130 | expected_x2 = "child_dir/bin/$toolset/debug/x2.obj" | |
131 | ||
132 | t.run_build_system() | |
133 | t.expect_addition(expected_x1) | |
134 | t.expect_addition(expected_x2) | |
135 | ||
136 | t.touch(header) | |
137 | t.run_build_system(subdir="child_dir") | |
138 | t.expect_touch(expected_x1) | |
139 | t.expect_touch(expected_x2) | |
140 | ||
141 | t.touch(header) | |
142 | t.run_build_system(["..", "-d2"], subdir="child_dir/folder_to_include") | |
143 | t.expect_touch(expected_x1) | |
144 | t.expect_touch(expected_x2) | |
145 | ||
146 | t.cleanup() | |
147 | ||
148 | ||
149 | test_basic() | |
150 | test_absolute_paths() | |
151 | test_ordered_paths() | |
152 | test_paths_set_by_indirect_conditionals() |