]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/python | |
2 | ||
3 | # Copyright 2003 Dave Abrahams | |
4 | # Copyright 2002, 2003, 2005 Vladimir Prus | |
5 | # Distributed under the Boost Software License, Version 1.0. | |
6 | # (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) | |
7 | ||
8 | # Test that we can change build directory using the 'build-dir' project | |
9 | # attribute. | |
10 | ||
11 | import BoostBuild | |
12 | import string | |
13 | import os | |
14 | ||
15 | t = BoostBuild.Tester(use_test_config=False) | |
16 | ||
17 | ||
18 | # Test that top-level project can affect build dir. | |
19 | t.write("jamroot.jam", "import gcc ;") | |
20 | t.write("jamfile.jam", """\ | |
21 | project : build-dir build ; | |
22 | exe a : a.cpp ; | |
23 | build-project src ; | |
24 | """) | |
25 | ||
26 | t.write("a.cpp", "int main() {}\n") | |
27 | ||
28 | t.write("src/jamfile.jam", "exe b : b.cpp ; ") | |
29 | ||
30 | t.write("src/b.cpp", "int main() {}\n") | |
31 | ||
32 | t.run_build_system() | |
33 | ||
34 | t.expect_addition(["build/$toolset/debug*/a.exe", | |
35 | "build/src/$toolset/debug*/b.exe"]) | |
36 | ||
37 | # Test that building from child projects work. | |
38 | t.run_build_system(subdir='src') | |
39 | t.ignore("build/config.log") | |
40 | t.ignore("build/project-cache.jam") | |
41 | t.expect_nothing_more() | |
42 | ||
43 | # Test that project can override build dir. | |
44 | t.write("jamfile.jam", """\ | |
45 | exe a : a.cpp ; | |
46 | build-project src ; | |
47 | """) | |
48 | ||
49 | t.write("src/jamfile.jam", """\ | |
50 | project : build-dir build ; | |
51 | exe b : b.cpp ; | |
52 | """) | |
53 | ||
54 | t.run_build_system() | |
55 | t.expect_addition(["bin/$toolset/debug*/a.exe", | |
56 | "src/build/$toolset/debug*/b.exe"]) | |
57 | ||
58 | # Now test the '--build-dir' option. | |
59 | t.rm(".") | |
60 | t.write("jamroot.jam", "") | |
61 | ||
62 | # Test that we get an error when no project id is specified. | |
63 | t.run_build_system(["--build-dir=foo"]) | |
64 | t.fail_test(t.stdout().find( | |
65 | "warning: the --build-dir option will be ignored") == -1) | |
66 | ||
67 | t.write("jamroot.jam", """\ | |
68 | project foo ; | |
69 | exe a : a.cpp ; | |
70 | build-project sub ; | |
71 | """) | |
72 | t.write("a.cpp", "int main() {}\n") | |
73 | t.write("sub/jamfile.jam", "exe b : b.cpp ;\n") | |
74 | t.write("sub/b.cpp", "int main() {}\n") | |
75 | ||
76 | t.run_build_system(["--build-dir=build"]) | |
77 | t.expect_addition(["build/foo/$toolset/debug*/a.exe", | |
78 | "build/foo/sub/$toolset/debug*/b.exe"]) | |
79 | ||
80 | t.write("jamroot.jam", """\ | |
81 | project foo : build-dir bin.v2 ; | |
82 | exe a : a.cpp ; | |
83 | build-project sub ; | |
84 | """) | |
85 | ||
86 | t.run_build_system(["--build-dir=build"]) | |
87 | t.expect_addition(["build/foo/bin.v2/$toolset/debug*/a.exe", | |
88 | "build/foo/bin.v2/sub/$toolset/debug*/b.exe"]) | |
89 | ||
90 | # Try building in subdir. We expect that the entire build tree with be in | |
91 | # 'sub/build'. Today, I am not sure if this is what the user expects, but let | |
92 | # it be. | |
93 | t.rm('build') | |
94 | t.run_build_system(["--build-dir=build"], subdir="sub") | |
95 | t.expect_addition(["sub/build/foo/bin.v2/sub/$toolset/debug*/b.exe"]) | |
96 | ||
97 | t.write("jamroot.jam", """\ | |
98 | project foo : build-dir %s ; | |
99 | exe a : a.cpp ; | |
100 | build-project sub ; | |
101 | """ % os.getcwd().replace('\\', '\\\\')) | |
102 | ||
103 | t.run_build_system(["--build-dir=build"], status=1) | |
104 | t.fail_test(t.stdout().find( | |
105 | "Absolute directory specified via 'build-dir' project attribute") == -1) | |
106 | ||
107 | t.cleanup() |