Imported Upstream version 1.51.0
[platform/upstream/boost.git] / tools / build / v2 / test / implicit_dependency.py
1 #!/usr/bin/python
2
3 # Copyright (C) Vladimir Prus 2006.
4 # Distributed under the Boost Software License, Version 1.0. (See
5 # accompanying file LICENSE_1_0.txt or copy at
6 # http://www.boost.org/LICENSE_1_0.txt)
7
8 # Test the <implicit-dependency> is respected even if the target referred to is
9 # not built itself, but only referred to by <implicit-dependency>.
10
11 import BoostBuild
12
13 t = BoostBuild.Tester()
14
15 t.write("jamroot.jam", """
16 make a.h : : gen-header ;
17 explicit a.h ;
18
19 exe hello : hello.cpp : <implicit-dependency>a.h ;
20
21 import os ;
22 if [ os.name ] = NT
23 {
24     actions gen-header
25     {
26        echo int i; > $(<)
27     }
28 }
29 else
30 {
31     actions gen-header
32     {
33         echo "int i;" > $(<)
34     }
35 }
36 """)
37
38 t.write("hello.cpp", """
39 #include "a.h"
40 int main() { return i; }
41 """)
42
43
44 t.run_build_system()
45
46 t.expect_addition("bin/$toolset/debug/hello.exe")
47
48 t.rm("bin")
49
50 t.write("jamroot.jam", """
51 make dir/a.h : : gen-header ;
52 explicit dir/a.h ;
53
54 exe hello : hello.cpp : <implicit-dependency>dir/a.h ;
55
56 import os ;
57 if [ os.name ] = NT
58 {
59     actions gen-header
60     {
61        echo int i; > $(<)
62     }
63 }
64 else
65 {
66     actions gen-header
67     {
68         echo "int i;" > $(<)
69     }
70 }
71 """)
72
73 t.write("hello.cpp", """
74 #include "dir/a.h"
75 int main() { return i; }
76 """)
77 t.run_build_system()
78
79 t.expect_addition("bin/$toolset/debug/hello.exe")
80
81 t.cleanup()