forked from steinwurf/cpuid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildbot.py
More file actions
131 lines (91 loc) · 3.21 KB
/
Copy pathbuildbot.py
File metadata and controls
131 lines (91 loc) · 3.21 KB
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
#!/usr/bin/env python
# encoding: utf-8
import os
import sys
import json
import shutil
import subprocess
project_name = 'cpuid'
def run_command(args, env_ext={}):
print("Running: {}".format(args))
sys.stdout.flush()
subprocess.check_call(args, env=dict(os.environ.copy(), **env_ext))
def get_tool_options(properties):
options = []
if 'tool_options' in properties:
# Make sure that the values are correctly comma separated
for key, value in properties['tool_options'].items():
if value is None:
options += ['--{0}'.format(key)]
else:
options += ['--{0}={1}'.format(key, value)]
return options
def configure(properties):
command = [sys.executable, 'waf']
if properties.get('build_distclean'):
command += ['distclean']
command += ['configure', '--git_protocol=git@']
if 'waf_resolve_path' in properties:
command += ['--resolve_path=' + properties['waf_resolve_path']]
if 'dependency_project' in properties:
command += ['--{0}_checkout={1}'.format(
properties['dependency_project'],
properties['dependency_checkout'])]
command += ["--cxx_mkspec={}".format(properties['cxx_mkspec'])]
command += get_tool_options(properties)
run_command(command)
def build(properties):
command = [sys.executable, 'waf', 'build', '-v']
run_command(command)
def run_tests(properties):
command = [sys.executable, 'waf', '-v', '--run_tests']
run_cmd = '%s'
if properties.get('valgrind_run'):
run_cmd = 'valgrind --error-exitcode=1 %s --no_fail'
if 'cpu_capabilities' in properties:
for cpu_capability in properties['cpu_capabilities'].items():
run_cmd += ' --has_{0}={1}'.format(*cpu_capability)
if run_cmd:
command += ["--run_cmd={}".format(run_cmd)]
command += get_tool_options(properties)
run_command(command)
def install(properties):
command = [sys.executable, 'waf', '-v', 'install']
if 'install_path' in properties:
command += ['--destdir={0}'.format(properties['install_path'])]
run_command(command)
def cmake(properties):
build_path = 'build'
if os.path.exists(build_path):
print("Path '{}' already exists - removing".format(build_path))
shutil.rmtree(build_path)
os.mkdir(build_path)
old_cwd = os.getcwd()
os.chdir(build_path)
run_command(['cmake', '../'], env_ext={'VERBOSE': '1'})
run_command(['cmake', '--build', '.'], env_ext={'VERBOSE': '1'})
os.chdir(old_cwd)
def coverage_settings(options):
options['required_line_coverage'] = 100.0
options['run_cmd'] = '%s --no_fail'
def main():
argv = sys.argv
if len(argv) != 3:
print("Usage: {} <command> <properties>".format(argv[0]))
sys.exit(0)
cmd = argv[1]
properties = json.loads(argv[2])
if cmd == 'configure':
configure(properties)
elif cmd == 'build':
build(properties)
elif cmd == 'run_tests':
run_tests(properties)
elif cmd == 'install':
install(properties)
elif cmd == 'cmake':
cmake(properties)
else:
print("Unknown command: {}".format(cmd))
if __name__ == '__main__':
main()