-
Notifications
You must be signed in to change notification settings - Fork 3
/
drakefile
181 lines (157 loc) · 4.53 KB
/
drakefile
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
'''Drake bootstrap drakefile'''
import os
import shutil
import sys
import drake
# Put ourselves in the path.
PYTHONPATH = ''
if 'PYTHONPATH' in os.environ:
PYTHONPATH = os.environ['PYTHONPATH']
SOURCE = '%s/%s' % (os.getcwd(), drake.path_source('src'))
PYTHONPATH = '%s:%s' % (SOURCE, PYTHONPATH)
os.environ['PYTHONPATH'] = PYTHONPATH
def configure(prefix='.', coverage: bool = False):
"""Configure drake.
prefix -- The prefix where to install.
coverage -- Whether to collect test suite coverage.
"""
prefix = drake.Path(prefix)
# Sources
sources = drake.nodes(
'src/drake/__init__.py',
'src/drake/command.py',
'src/drake/enumeration.py',
'src/drake/deprecation.py',
'src/drake/docker.py',
'src/drake/cxx/__init__.py',
'src/drake/cxx/bison.py',
'src/drake/cxx/boost.py',
'src/drake/cxx/curl.py',
'src/drake/cxx/flex.py',
'src/drake/cxx/ipp.py',
'src/drake/cxx/opengl.py',
'src/drake/cxx/qt.py',
'src/drake/cxx/qt5.py',
'src/drake/cxx/sdl.py',
'src/drake/cxx/sofia_sip.py',
'src/drake/debug.py',
'src/drake/git.py',
'src/drake/gnu.py',
'src/drake/go/__init__.py',
'src/drake/log.py',
'src/drake/ocaml/__init__.py',
'src/drake/ocaml/menhir.py',
'src/drake/ocaml/ocamllex.py',
'src/drake/python/__init__.py',
'src/drake/sched.py',
'src/drake/templating.py',
'src/drake/threadpool.py',
'src/drake/utils.py',
'src/drake/valgrind.py',
'src/drake/which.py',
)
command = drake.node('src/bin/drake')
# Install
lib = drake.Path('lib/python%s.%s/site-packages' % \
(sys.version_info[0], sys.version_info[1]))
install = drake.Rule('install')
install << drake.copy(sources, prefix / lib, 'src')
install << drake.copy(command, prefix/'bin', 'src/bin')
## ----- ##
## Tests ##
## ----- ##
check = drake.Rule('check')
tests = [
'base/change-dynamic-dependency',
'base/command-line',
'base/cyclic-dependencies',
'base/dependency',
'base/dynamic-termination',
'base/failure',
'base/failure-cmd',
'base/interrupt-dynamic-dependency',
'base/mtime',
'base/obsolete-path-cache',
'base/range',
'base/runner-env',
'base/symlink',
'base/termination',
'base/termination-keep-successful',
'base/version',
'cxx/copied-libraries',
'cxx/chained-static-libraries',
'doctest',
'git/base',
'sched',
'threadpool',
'HTTPDownload',
]
if coverage:
coverage = ['coverage', 'run', '--source', str(drake.path_source('src')), '--append']
else:
coverage = None
for test in tests:
test = drake.node('tests/%s' % test)
test.dependencies_add(sources)
runner = drake.Runner(
test,
env={'PYTHONPATH': '{}:{}'.format(PYTHONPATH, drake.path_source('tests'))},
prefix=coverage,
)
runner.reporting = drake.Runner.Reporting.on_failure
check << runner.status
# Old style tests
tests = [
'base/copy',
'base/deps-dyn',
'base/no-builder-to-make',
'base/path',
'base/runner',
'cxx/boost',
'cxx/cyclic-dependencies',
'cxx/dependency-directory-clash',
'cxx/find_library',
'cxx/headers-deps',
'cxx/generated-headers-deps',
# FIXME: not CI friendly
# 'cxx/pkg-config',
# 'cxx/qt/moc',
]
class Tester(drake.Builder):
'''Copy the whole test tree and run test script there.'''
def __init__(self, name):
self.__name = name
path = drake.Path('tests') / drake.Path(name)
self.__exe = drake.node(path / 'test')
self.__target = drake.node(path.with_extension('tst'))
drake.Builder.__init__(self, [self.__exe] + sources, [self.__target])
def execute(self):
source = str(self.__exe.path().dirname())
dest = str(self.__exe.name().dirname())
try:
shutil.rmtree(dest)
except OSError as error:
if error.errno == 2:
pass
else:
raise
shutil.copytree(source, dest)
cmd = [str(drake.Path(os.getcwd()) / self.__exe.path())]
if coverage is not None:
cmd = coverage + cmd
res = self.cmd('Test %s' % self.__name,
# Use an absolute path, because we chdir, and
# "./test" isn't very helpful in backtraces.
cmd,
cwd=dest)
if res:
self.__target.path().touch()
return res
def target(self):
'''Test status output node'''
return self.__target
for test in tests:
check << Tester(test).target()
# Local Variables:
# mode: python
# End: