Left: | ||
Right: |
OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 import glob | 3 import glob |
4 import json | 4 import json |
5 import os | 5 import os |
6 import shutil | 6 import shutil |
7 import string | 7 import string |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
11 | 11 |
12 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 12 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
13 ENSURE_DEPENDENCIES_PATH = os.path.join(BASE_DIR, "ensure_dependencies.py") | 13 ENSURE_DEPENDENCIES_PATH = os.path.join(BASE_DIR, "ensure_dependencies.py") |
14 MULTI_L10N_PATH = os.path.join(BASE_DIR, "mozharness", "scripts", | 14 MULTI_L10N_PATH = os.path.join(BASE_DIR, "mozharness", "scripts", |
15 "multil10n.py") | 15 "multil10n.py") |
16 DIST_PATH = os.path.join(BASE_DIR, "adblockbrowser", | 16 ABB_PATH = os.path.join(BASE_DIR, "adblockbrowser") |
17 "obj-arm-linux-androideabi", "dist") | 17 DIST_PATH = os.path.join(ABB_PATH, "obj-arm-linux-androideabi", "dist") |
18 | 18 |
19 def print_usage(): | 19 def print_usage(): |
20 print >>sys.stderr, string.Template("""\ | 20 print >>sys.stderr, string.Template("""\ |
21 Usage: $name build | 21 Usage: $name build |
22 $name sign APK_PATH | 22 $name sign APK_PATH |
23 $name build-and-sign\ | 23 $name build-and-sign\ |
24 """).substitute({"name": os.path.basename(sys.argv[0])}) | 24 """).substitute({"name": os.path.basename(sys.argv[0])}) |
25 | 25 |
26 def check_mozconfig(path, distribution_mode, build_mode): | 26 def check_mozconfig(path, distribution_mode, build_mode): |
27 if not os.path.exists(path): | 27 if not os.path.exists(path): |
(...skipping 25 matching lines...) Expand all Loading... | |
53 elif not release_build and build_mode == "release": | 53 elif not release_build and build_mode == "release": |
54 raise Exception("'%s' should export ABB_RELEASE_BUILD=1." % path) | 54 raise Exception("'%s' should export ABB_RELEASE_BUILD=1." % path) |
55 | 55 |
56 def find_mozconfig(distribution_mode, build_mode): | 56 def find_mozconfig(distribution_mode, build_mode): |
57 mozconfig_path = os.path.join(BASE_DIR, "mozconfig-" + distribution_mode + | 57 mozconfig_path = os.path.join(BASE_DIR, "mozconfig-" + distribution_mode + |
58 "-" + build_mode) | 58 "-" + build_mode) |
59 check_mozconfig(mozconfig_path, distribution_mode, build_mode) | 59 check_mozconfig(mozconfig_path, distribution_mode, build_mode) |
60 return mozconfig_path | 60 return mozconfig_path |
61 | 61 |
62 def build(distribution_mode, build_mode, sdk_path, ndk_path): | 62 def build(distribution_mode, build_mode, sdk_path, ndk_path): |
63 mozharness_environment = os.environ.copy() | 63 build_environment = os.environ.copy() |
64 mozharness_environment["MOZCONFIG"] = find_mozconfig(distribution_mode, | 64 build_environment["MOZCONFIG"] = find_mozconfig(distribution_mode, build_mode) |
65 build_mode) | 65 build_environment["ANDROID_SDK_PATH"] = sdk_path |
66 mozharness_environment["ANDROID_SDK_PATH"] = sdk_path | 66 build_environment["ANDROID_NDK_PATH"] = ndk_path |
67 mozharness_environment["ANDROID_NDK_PATH"] = ndk_path | 67 subprocess.check_call([os.path.join(ABB_PATH, "mach"), "clobber"], |
René Jeschke
2015/09/29 15:19:41
Nit: there has been an empty line here, now it's g
Felix Dahlke
2015/09/29 15:20:32
Intended, but no strong opinion :P
| |
68 | 68 env=build_environment) |
69 subprocess.check_call([MULTI_L10N_PATH, "--cfg", "adblockbrowser-cfg.py"], | 69 subprocess.check_call([MULTI_L10N_PATH, "--cfg", "adblockbrowser-cfg.py"], |
70 env=mozharness_environment) | 70 env=build_environment) |
71 | 71 |
72 [manifest_path] = glob.glob(os.path.join( | 72 [manifest_path] = glob.glob(os.path.join( |
73 DIST_PATH, "fennec-*.multi.android-arm.json")) | 73 DIST_PATH, "fennec-*.multi.android-arm.json")) |
74 with open(manifest_path) as manifest_file: | 74 with open(manifest_path) as manifest_file: |
75 manifest = json.load(manifest_file) | 75 manifest = json.load(manifest_file) |
76 | 76 |
77 apk_path = os.path.join(DIST_PATH, "gecko-unsigned-unaligned.apk") | 77 apk_path = os.path.join(DIST_PATH, "gecko-unsigned-unaligned.apk") |
78 if build_mode == "release": | 78 if build_mode == "release": |
79 target_apk_name = "adblockbrowser-%s-arm.apk" % manifest["moz_app_version"] | 79 target_apk_name = "adblockbrowser-%s-arm.apk" % manifest["moz_app_version"] |
80 else: | 80 else: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 print >>sys.stderr, "Invalid build mode, check config.py" | 127 print >>sys.stderr, "Invalid build mode, check config.py" |
128 sys.exit(5) | 128 sys.exit(5) |
129 | 129 |
130 if do_build: | 130 if do_build: |
131 apk_path = build(distribution_mode, build_mode, config.ANDROID_SDK_PATH, | 131 apk_path = build(distribution_mode, build_mode, config.ANDROID_SDK_PATH, |
132 config.ANDROID_NDK_PATH) | 132 config.ANDROID_NDK_PATH) |
133 if do_sign: | 133 if do_sign: |
134 sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) | 134 sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) |
135 else: | 135 else: |
136 print apk_path | 136 print apk_path |
OLD | NEW |