-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbru.py
executable file
·67 lines (56 loc) · 2.57 KB
/
bru.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
#!/usr/bin/env python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os
import argparse
import pdb # only if you want to add pdb.set_trace()
import brulib.jsonc
import brulib.library
import brulib.install
import brulib.make
import brulib.runtests
# http://stackoverflow.com/questions/4934806/python-how-to-find-scripts-directory
def get_script_path():
return os.path.dirname(os.path.realpath(__file__))
def get_library_dir():
""" assuming we execute bru.py from within its git clone the library
directory will be located in bru.py's base dir. This func here
returns the path to this library dir. """
return os.path.join(get_script_path(), 'library')
def get_library():
return brulib.library.Library(get_library_dir())
def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='command')
parser_install = subparsers.add_parser('install')
parser_install.add_argument("installables", default = [], nargs = '*',
help = 'e.g. googlemock@1.7.0')
parser_install.add_argument('--targetPlatform', default='Native', required=False,
help = 'targetPlatform Native | iOS | Android')
parser_test = subparsers.add_parser('test')
parser_test.add_argument("testables", default = [], nargs = '*',
help = 'e.g. googlemock')
# for 'bru make' let's default to config=Debug, it compiles faster
# (even though tests run slower, tests should run much faster than
# compilation for most modules)
parser_make = subparsers.add_parser('make')
parser_make.add_argument('--config', default='Debug', required=False,
help = 'config Debug | Release')
parser_make.add_argument('--verbose', '-v', default=0, action='count',
help = 'enables verbose output in underlying build toolchain (e.g. make)')
parser_make.add_argument('--targetPlatform', default='Native', required=False,
help = 'targetPlatform Native | iOS | Android ')
args = parser.parse_args()
library = get_library()
if args.command == 'install':
brulib.install.cmd_install(library, args.installables, args.targetPlatform)
elif args.command == 'make':
brulib.make.cmd_make(args.config, args.verbose, args.targetPlatform)
elif args.command == 'test':
brulib.runtests.cmd_test(args.testables)
else:
raise Exception("unknown command {}, chose install | test".format(args.command))
if __name__ == "__main__":
main()