-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-repos.py
executable file
·62 lines (51 loc) · 1.84 KB
/
build-repos.py
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
#!/usr/bin/env python
import argparse
import os
import sys
import build_tools
def parse_args(args):
"""
Most of the parsing logic actually lives in build_tools.builders
where it can be close to the things that consume what it produces.
See build_tools.builders.argument_parsers for more info.
"""
parser = argparse.ArgumentParser(
description=' '.join([
'Builds each repository. Checks repositories_settings.py'
' for repo-specific build arguments.']),
parents=(
[build_tools.get_parent_parser()] +
build_tools.builders.argument_parsers),
epilog=' '.join([
"To specify args for individual repos,",
"use repositories_settings.py",
"(see docs/repositories_settings.md)"]))
parser.add_argument(
'-k',
'--keep-going',
action='store_true',
help='Keep going even if errors are encountered.')
return parser.parse_args(args)
def build_repos(args):
"""Builds each repo in the toolchain"""
# this looks at the parsed args and gives us a dict of
# kwargs to pass to each build
build_args = build_tools.builders.extract_build_args(args)
for repo in build_tools.get_toolchain(args):
rv = repo.build(**build_args)
if rv is build_tools.builders.FAILURE:
print('Building ' + repo.name + ' failed')
if not args.keep_going:
return rv
if rv is build_tools.builders.FAILED_TESTS:
print(repo.name + ' failed while running tests')
if not args.keep_going:
return rv
return build_tools.builders.SUCCESS
if '__main__' == __name__:
parsed_args = parse_args(sys.argv[1:])
rv = build_repos(parsed_args)
if rv is build_tools.builders.SUCCESS:
sys.exit(0)
else:
sys.exit(1)