File: core_dependencies.py

package info (click to toggle)
boost-build 2.0-m11-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,624 kB
  • ctags: 2,387
  • sloc: ansic: 12,978; python: 5,209; xml: 4,782; cpp: 555; yacc: 456; sh: 237; makefile: 71
file content (152 lines) | stat: -rwxr-xr-x 3,325 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/python

# This tests correct handling of dependencies, specifically, on
# generated sources, and from generated sources.

import BoostBuild
from string import find

t = BoostBuild.Tester(pass_toolset=0)

t.write("core-dependency-helpers", """
rule hdrrule
{
   INCLUDES $(1) : $(2) ;
}
actions copy
{
   cp $(>) $(<)
}
""")

code = """include core-dependency-helpers ;
DEPENDS all : a ;
DEPENDS a : b ;

actions create-b
{
   echo '#include <foo.h>' > $(<) 
}
copy a : b ;
create-b b ;
HDRRULE on b foo.h bar.h = hdrrule ;
HDRSCAN on b foo.h bar.h = \"#include <(.*)>\" ;
"""

# This creates 'a' which depends on 'b', which is generated.
# The generated 'b' contains '#include <foo.h>' and no rules for
# foo.h are given. The system should error out on the first invocation.
t.run_build_system("-f-", stdin=code)
t.fail_test(find(t.stdout(), "...skipped a for lack of foo.h...") == -1)

t.rm('b')
# Now test that if target 'c' also depends on 'b', then it won't be built, as well.
t.run_build_system("-f-", stdin=code + " copy c : b ; DEPENDS c : b ; DEPENDS all : c ; ")
t.fail_test(find(t.stdout(), "...skipped c for lack of foo.h...") == -1)


# Now add a rule for creating foo.h
t.rm('b')
code += """
actions create-foo
{
    echo // > $(<)
}
create-foo foo.h ;
"""
t.run_build_system("-f-", stdin=code)

# Run two times, adding explicit dependency from all to foo.h at
# the beginning and at the end, to make sure that foo.h is generated before
# 'a' in all cases.

def mk_right_order_func(s1, s2):
    def right_order(s):
        n1 = find(s, s1)
        n2 = find(s, s2)
        return n1 != -1 and n2 != -1 and n1 < n2
    return right_order

right_order = mk_right_order_func("create-foo", "copy a")

t.rm(["a", "b", "foo.h"])
t.run_build_system("-d+2 -f-", stdin=code + " DEPENDS all : foo.h ;")
t.fail_test(not right_order(t.stdout()))

t.rm(["a", "b", "foo.h"])
t.run_build_system("-d+2 -f-", stdin=" DEPENDS all : foo.h ; " + code)
t.fail_test(not right_order(t.stdout()))

# Now foo.h exists. Test include from b -> foo.h -> bar.h -> biz.h
# b and foo.h already have updating actions. 
t.rm(["a", "b"])
t.write("foo.h", "#include <bar.h>")
t.write("bar.h", "#include <biz.h>")
t.run_build_system("-d+2 -f-", stdin=code)
t.fail_test(find(t.stdout(), "...skipped a for lack of biz.h...") == -1)

# Add an action for biz.h
code += """
actions create-biz
{
   echo // > $(<)
}
create-biz biz.h ;
"""
t.rm(["b"])
right_order = mk_right_order_func("create-biz", "copy a")
t.run_build_system("-d+2 -f-", stdin=code + " DEPENDS all : biz.h ;")
t.fail_test(not right_order(t.stdout()))

t.rm(["a", "biz.h"])
t.run_build_system("-d+2 -f-", stdin=" DEPENDS all : biz.h ; " + code)
t.fail_test(not right_order(t.stdout()))           


t.write("a", "")

code="""
DEPENDS all : main d ;

actions copy 
{
    cp $(>) $(<) ;
}

DEPENDS main : a ;
copy main : a ;

INCLUDES a : <1>c ;

NOCARE <1>c ;
SEARCH on <1>c = . ;

actions create-c 
{
    echo d > $(<)    
}

actions create-d
{
    echo // > $(<)
}

create-c <2>c ;
LOCATE on <2>c = . ;
create-d d ;

HDRSCAN on <1>c = (.*) ;
HDRRULE on <1>c = hdrrule ;

rule hdrrule 
{
    INCLUDES $(1) : d ;
}
"""
right_order = mk_right_order_func("create-d", "copy main")
t.run_build_system("-d2 -f-", stdin=code)
t.fail_test(not right_order(t.stdout()))



t.cleanup()