]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/alias.py
ef89df96e60a9a89b635fd8e9ed177a9e02b492e
[ceph.git] / ceph / src / boost / tools / build / test / alias.py
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.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
7
8 import BoostBuild
9
10
11 ###############################################################################
12 #
13 # test_alias_rule()
14 # -----------------
15 #
16 ###############################################################################
17
18 def test_alias_rule(t):
19 """Basic alias rule test."""
20
21 t.write("jamroot.jam", """\
22 exe a : a.cpp ;
23 exe b : b.cpp ;
24 exe c : c.cpp ;
25
26 alias bin1 : a ;
27 alias bin2 : a b ;
28
29 alias src : s.cpp ;
30 exe 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"])
41 t.expect_addition(BoostBuild.List("bin/$toolset/debug*/") * "a.exe a.obj")
42 t.ignore_addition('bin/*/a.rsp')
43 t.ignore_addition('bin/*/a.*.rsp')
44 t.expect_nothing_more()
45
46 # Try again with "bin2"
47 t.run_build_system(["bin2"])
48 t.expect_addition(BoostBuild.List("bin/$toolset/debug*/") * "b.exe b.obj")
49 t.ignore_addition('bin/*/b.rsp')
50 t.ignore_addition('bin/*/b.*.rsp')
51 t.expect_nothing_more()
52
53 # Try building everything, making sure 'hello' target is created.
54 t.run_build_system()
55 t.expect_addition(BoostBuild.List("bin/$toolset/debug*/") * \
56 "hello.exe hello.obj")
57 t.ignore_addition('bin/*/hello.rsp')
58 t.ignore_addition('bin/*/hello.*.rsp')
59 t.expect_addition("bin/$toolset/debug*/s.obj")
60 t.ignore_addition('bin/*/s.*.rsp')
61 t.expect_addition(BoostBuild.List("bin/$toolset/debug*/") * "c.exe c.obj")
62 t.ignore_addition('bin/*/c.rsp')
63 t.ignore_addition('bin/*/c.*.rsp')
64 t.expect_nothing_more()
65
66
67 ###############################################################################
68 #
69 # test_alias_source_usage_requirements()
70 # --------------------------------------
71 #
72 ###############################################################################
73
74 def 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", """\
82 lib l : l.cpp : : : <define>WANT_MAIN ;
83 alias la : l ;
84 exe main : main.cpp la ;
85 """)
86
87 t.write("l.cpp", """\
88 void
89 #if defined(_WIN32)
90 __declspec(dllexport)
91 #endif
92 foo() {}
93 """)
94
95 t.write("main.cpp", """\
96 #ifdef WANT_MAIN
97 int main() {}
98 #endif
99 """)
100
101 t.run_build_system()
102
103
104 ###############################################################################
105 #
106 # main()
107 # ------
108 #
109 ###############################################################################
110
111 t = BoostBuild.Tester(use_test_config=False)
112
113 test_alias_rule(t)
114 test_alias_source_usage_requirements(t)
115
116 t.cleanup()