]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/test/alias.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / tools / build / test / alias.py
CommitLineData
7c673cae
FG
1#!/usr/bin/python
2
3# Copyright 2003 Dave Abrahams
4# Copyright 2003 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
8import BoostBuild
9
10
11###############################################################################
12#
13# test_alias_rule()
14# -----------------
15#
16###############################################################################
17
18def test_alias_rule(t):
19 """Basic alias rule test."""
20
21 t.write("jamroot.jam", """\
22exe a : a.cpp ;
23exe b : b.cpp ;
24exe c : c.cpp ;
25
26alias bin1 : a ;
27alias bin2 : a b ;
28
29alias src : s.cpp ;
30exe hello : hello.cpp src ;
31""")
32
33 t.write("a.cpp", "int main() {}\n")
34 t.copy("a.cpp", "b.cpp")
35 t.copy("a.cpp", "c.cpp")
36 t.copy("a.cpp", "hello.cpp")
37 t.write("s.cpp", "")
38
39 # Check that targets to which "bin1" refers are updated, and only those.
40 t.run_build_system(["bin1"])
b32b8144 41 t.expect_addition(BoostBuild.List("bin/$toolset/debug*/") * "a.exe a.obj")
20effc67
TL
42 t.ignore_addition('bin/*/a.rsp')
43 t.ignore_addition('bin/*/a.*.rsp')
7c673cae
FG
44 t.expect_nothing_more()
45
46 # Try again with "bin2"
47 t.run_build_system(["bin2"])
b32b8144 48 t.expect_addition(BoostBuild.List("bin/$toolset/debug*/") * "b.exe b.obj")
20effc67
TL
49 t.ignore_addition('bin/*/b.rsp')
50 t.ignore_addition('bin/*/b.*.rsp')
7c673cae
FG
51 t.expect_nothing_more()
52
53 # Try building everything, making sure 'hello' target is created.
54 t.run_build_system()
b32b8144 55 t.expect_addition(BoostBuild.List("bin/$toolset/debug*/") * \
7c673cae 56 "hello.exe hello.obj")
20effc67
TL
57 t.ignore_addition('bin/*/hello.rsp')
58 t.ignore_addition('bin/*/hello.*.rsp')
b32b8144 59 t.expect_addition("bin/$toolset/debug*/s.obj")
20effc67 60 t.ignore_addition('bin/*/s.*.rsp')
b32b8144 61 t.expect_addition(BoostBuild.List("bin/$toolset/debug*/") * "c.exe c.obj")
20effc67
TL
62 t.ignore_addition('bin/*/c.rsp')
63 t.ignore_addition('bin/*/c.*.rsp')
7c673cae
FG
64 t.expect_nothing_more()
65
66
67###############################################################################
68#
69# test_alias_source_usage_requirements()
70# --------------------------------------
71#
72###############################################################################
73
74def test_alias_source_usage_requirements(t):
75 """
76 Check whether usage requirements are propagated via "alias". In case they
77 are not, linking will fail as there will be no main() function defined
78 anywhere in the source.
79
80 """
81 t.write("jamroot.jam", """\
82lib l : l.cpp : : : <define>WANT_MAIN ;
83alias la : l ;
84exe main : main.cpp la ;
85""")
86
87 t.write("l.cpp", """\
88void
89#if defined(_WIN32)
90__declspec(dllexport)
91#endif
92foo() {}
93""")
94
95 t.write("main.cpp", """\
96#ifdef WANT_MAIN
97int main() {}
98#endif
99""")
100
101 t.run_build_system()
102
103
104###############################################################################
105#
106# main()
107# ------
108#
109###############################################################################
110
11fdf7f2 111t = BoostBuild.Tester(use_test_config=False)
7c673cae
FG
112
113test_alias_rule(t)
114test_alias_source_usage_requirements(t)
115
116t.cleanup()