Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/build/v2/test/build_dir.py @ 32

Last change on this file since 32 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.7 KB
Line 
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_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
7
8# Test that we can change build directory using
9# the 'build-dir' project attribute.
10
11from BoostBuild import Tester
12import string
13import os
14
15t = Tester()
16
17
18# Test that top-level project can affect build dir
19t.write("project-root.jam", "import gcc ; ")
20t.write("Jamfile", """
21project
22    : build-dir build
23    ;
24   
25exe a : a.cpp ;
26build-project src ;   
27""")
28t.write("a.cpp", "int main() { return 0; }\n")
29
30t.write("src/Jamfile", "exe b : b.cpp ; ")
31t.write("src/b.cpp", "int main() { return 0; }\n")
32
33t.run_build_system()
34
35t.expect_addition(["build/$toolset/debug/a.exe",
36                   "build/src/$toolset/debug/b.exe"])
37           
38# Test that building from child projects work
39t.run_build_system(subdir='src')
40t.expect_nothing_more()       
41           
42# Test that project can override build dir
43t.write("Jamfile", """
44exe a : a.cpp ;
45build-project src ;
46""")           
47
48t.write("src/Jamfile", """
49project
50    : build-dir build
51    ;
52exe b : b.cpp ;   
53""")
54
55t.run_build_system()
56t.expect_addition(["bin/$toolset/debug/a.exe",
57                   "src/build/$toolset/debug/b.exe"])
58
59# Now test the '--build-dir' option.
60t.rm(".")
61t.write("Jamroot", "")
62
63# Test that we get an error when no project id is specified.
64t.run_build_system("--build-dir=foo")
65t.fail_test(string.find(t.stdout(),
66                   "warning: the --build-dir option will be ignored") == -1)
67
68t.write("Jamroot", """
69project foo ;
70exe a : a.cpp ;
71build-project sub ;
72""")
73t.write("a.cpp", "int main() { return 0; }\n")
74t.write("sub/Jamfile", "exe b : b.cpp ;\n")
75t.write("sub/b.cpp", "int main() { return 0; }\n")
76
77t.run_build_system("--build-dir=build")
78t.expect_addition(["build/foo/$toolset/debug/a.exe",
79                   "build/foo/sub/$toolset/debug/b.exe"])
80
81t.write("Jamroot", """
82project foo : build-dir bin.v2 ;
83exe a : a.cpp ;
84build-project sub ;
85""")
86
87t.run_build_system("--build-dir=build")
88t.expect_addition(["build/foo/bin.v2/$toolset/debug/a.exe",                   
89                   "build/foo/bin.v2/sub/$toolset/debug/b.exe"])
90
91# Try building in subdir
92t.rm('build')
93t.run_build_system("--build-dir=build", subdir="sub")
94t.expect_addition(["sub/build/foo/bin.v2/sub/$toolset/debug/b.exe"])
95
96
97
98t.write("Jamroot", """
99project foo : build-dir %s ;
100exe a : a.cpp ;
101build-project sub ;
102""" % string.replace(os.getcwd(), '\\', '\\\\'))
103
104t.run_build_system("--build-dir=build", status=1)
105t.fail_test(string.find(t.stdout(),
106                   "Absolute directory specified via 'build-dir' project attribute") == -1)
107
108
109
110
111t.cleanup()       
Note: See TracBrowser for help on using the repository browser.