-
Notifications
You must be signed in to change notification settings - Fork 7
/
android.py
executable file
·67 lines (47 loc) · 1.8 KB
/
android.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 python2.7
import sys
sys.path.insert(0, 'buildlib/jinja2.egg')
sys.path.insert(0, 'buildlib')
import os
import argparse
import subprocess
import interface
import install_sdk
import configure
import build
import plat
def main():
# Change into our root directory.
ROOT = os.path.abspath(os.path.dirname(sys.argv[0]))
os.chdir(ROOT)
# Parse the arguments.
ap = argparse.ArgumentParser(description="Build an android package.")
ap.add_argument("command", help="The command to run. One of install_sdk, configure, or build.")
ap.add_argument("argument", nargs='*', help="The arguments to the selected command.")
args = ap.parse_args()
iface = interface.Interface()
def check_args(n):
if len(args.argument) != n:
iface.fail("The {} command expects {} arguments.".format(args.command, n))
return args.argument
if args.command == "installsdk":
check_args(0)
install_sdk.install_sdk(iface)
elif args.command == "configure":
directory, = check_args(1)
configure.configure(iface, directory)
elif args.command == "setconfig":
directory, var, value = check_args(3)
configure.set_config(iface, directory, var, value)
elif args.command == "build":
if len(args.argument) < 2:
iface.fail("The build command expects at least 2 arguments.")
build.build(iface, args.argument[0], args.argument[1:])
elif args.command == "logcat":
subprocess.call([ plat.adb, "logcat", "-s", "python:*"] + args.argument)
elif args.command == "test":
iface.success("All systems go!")
else:
ap.error("Unknown command: " + args.command)
if __name__ == "__main__":
main()