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 DIST_PATH = os.path.join(BASE_DIR, "adblockbrowser", |
17 "obj-arm-linux-androideabi", "dist") | 17 "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 devbuild|release standalone|store | 21 Usage: $name build devbuild|release |
22 $name sign APK_PATH | 22 $name sign APK_PATH |
23 $name build-and-sign devbuild|release standalone|store\ | 23 $name build-and-sign devbuild|release\ |
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): | 26 def check_mozconfig(path, distribution_mode): |
27 if not os.path.exists(path): | 27 if not os.path.exists(path): |
28 raise Exception("'%s' doesn't exist, please create it." % path) | 28 raise Exception("'%s' doesn't exist, please create it." % path) |
29 | 29 |
30 with open(path) as file: | 30 with open(path) as file: |
31 contents = file.read() | 31 contents = file.read() |
32 | 32 |
33 # This check can be removed once https://issues.adblockplus.org/ticket/2490 is | 33 # This check can be removed once https://issues.adblockplus.org/ticket/2490 is |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 do_sign = mode in ("sign", "build-and-sign") | 98 do_sign = mode in ("sign", "build-and-sign") |
99 if not do_build and not do_sign: | 99 if not do_build and not do_sign: |
100 print_usage() | 100 print_usage() |
101 sys.exit(2) | 101 sys.exit(2) |
102 | 102 |
103 if do_build: | 103 if do_build: |
104 build_mode = sys.argv[2] | 104 build_mode = sys.argv[2] |
105 if build_mode not in ("devbuild", "release"): | 105 if build_mode not in ("devbuild", "release"): |
106 print_usage() | 106 print_usage() |
107 sys.exit(3) | 107 sys.exit(3) |
108 distribution_mode = len(sys.argv) > 3 and sys.argv[3] or "" | |
109 if distribution_mode not in ("standalone", "store"): | |
110 print_usage() | |
111 sys.exit(4) | |
112 | 108 |
113 if do_sign: | 109 if do_sign: |
114 apk_path = sys.argv[2] | 110 apk_path = sys.argv[2] |
115 | 111 |
116 subprocess.check_call([ENSURE_DEPENDENCIES_PATH]) | 112 subprocess.check_call([ENSURE_DEPENDENCIES_PATH]) |
117 import config | 113 import config |
118 | 114 |
| 115 distribution_mode = config.DISTRIBUTION_MODE |
| 116 if distribution_mode not in ("standalone", "store"): |
| 117 print >>sys.stderr, "Invalid distribution mode, check config.py" |
| 118 sys.exit(4) |
| 119 |
119 if do_build: | 120 if do_build: |
120 apk_path = build(build_mode, distribution_mode, config.ANDROID_SDK_PATH, | 121 apk_path = build(build_mode, distribution_mode, config.ANDROID_SDK_PATH, |
121 config.ANDROID_NDK_PATH) | 122 config.ANDROID_NDK_PATH) |
122 if do_sign: | 123 if do_sign: |
123 sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) | 124 sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) |
124 else: | 125 else: |
125 print apk_path | 126 print apk_path |
OLD | NEW |