-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_repository.py
122 lines (97 loc) · 2.63 KB
/
update_repository.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
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
# system imports
import argparse
import json
import os
# local imports
import devtools.build_system as build
from devtools.dependencies import ReleaseDependencies, Dependency
def main():
# parse input arguments
args = process_input()
# make the build system
make_build_system(args)
def process_input():
""" Use argparse for command line input processing.
"""
parser = argparse.ArgumentParser(
description='Update build system for a given repository '
'in the NJOY framework.'
)
# required input
parser.add_argument(
'path',
type=str,
help='path to repository'
)
# optional inputs
parser.add_argument(
'--name', '-n',
type=str,
help='repository name',
default=None
)
parser.add_argument(
'--dependencies', '-d',
type=str,
help='dependency file',
default='dependencies.json'
)
parser.add_argument(
'--build-dir', '-b',
type=str,
help='build directory (relative to path)',
default='bin'
)
parser.add_argument(
'--default-branch',
type=str,
help='default branch to use for live-at-head dependencies',
default='master'
)
# exclusive group
group = parser.add_mutually_exclusive_group(required=False)
group.add_argument(
'--develop',
action='store_false',
dest='release',
help='Create develop_dependencies.cmake file (default)',
default=False
)
group.add_argument(
'--release',
action='store_true',
dest='release',
help='Create release_dependencies.cmake file'
)
# parse and return
args = parser.parse_args()
return args
def make_build_system(args):
Dependency.default_branch = args.default_branch
b = build.BuildSystem(
args.path,
args.name
)
if args.release:
# Release dependencies are taken from examining the
# build/_deps folder
b.dependencies = ReleaseDependencies(
os.path.join(
args.path,
args.build_dir,
'_deps'
)
)
else:
# Develop dependencies are given in an input JSON file
with open(args.dependencies, 'r') as f:
dependencies = json.load(f)
deps = dependencies[b.name]
if deps:
b.dependencies = deps
b.write_dependencies()
if not args.release:
b.write_cmakelists()
b.write_test_list()
if __name__ == '__main__':
main()