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 re | 6 import re |
7 import shutil | 7 import shutil |
8 import string | 8 import string |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
11 import tempfile | 11 import tempfile |
12 | 12 |
13 _BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 13 _BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
14 _ENSURE_DEPENDENCIES_PATH = os.path.join(_BASE_DIR, "ensure_dependencies.py") | 14 _ENSURE_DEPENDENCIES_PATH = os.path.join(_BASE_DIR, "ensure_dependencies.py") |
15 _GENERATED_MOZCONFIG_PATH = os.path.join(_BASE_DIR, "generated", "mozconfig") | 15 _GENERATED_PATH = os.path.join(_BASE_DIR, "generated") |
| 16 _GENERATED_MOZCONFIG_PATH = os.path.join(_GENERATED_PATH, "mozconfig") |
16 _MOZCONFIG_COMMON_PATH = os.path.join(_BASE_DIR, "mozconfig-common") | 17 _MOZCONFIG_COMMON_PATH = os.path.join(_BASE_DIR, "mozconfig-common") |
17 _MOZCONFIG_ARM_PATH = os.path.join(_BASE_DIR, "mozconfig-arm") | 18 _MOZCONFIG_ARM_PATH = os.path.join(_BASE_DIR, "mozconfig-arm") |
18 _MOZCONFIG_X86_PATH = os.path.join(_BASE_DIR, "mozconfig-x86") | 19 _MOZCONFIG_X86_PATH = os.path.join(_BASE_DIR, "mozconfig-x86") |
19 _MOZCONFIG_STORE_PATH = os.path.join(_BASE_DIR, "mozconfig-store") | 20 _MOZCONFIG_STORE_PATH = os.path.join(_BASE_DIR, "mozconfig-store") |
20 _MOZCONFIG_RELEASE_PATH = os.path.join(_BASE_DIR, "mozconfig-release") | 21 _MOZCONFIG_RELEASE_PATH = os.path.join(_BASE_DIR, "mozconfig-release") |
21 _MOZCONFIG_CUSTOM_PATH = os.path.join(_BASE_DIR, "mozconfig-custom") | 22 _MOZCONFIG_CUSTOM_PATH = os.path.join(_BASE_DIR, "mozconfig-custom") |
22 _MULTI_L10N_PATH = os.path.join(_BASE_DIR, "mozharness", "scripts", | 23 _MULTI_L10N_PATH = os.path.join(_BASE_DIR, "mozharness", "scripts", |
23 "multil10n.py") | 24 "multil10n.py") |
24 _ABB_PATH = os.path.join(_BASE_DIR, "adblockbrowser") | 25 _ABB_PATH = os.path.join(_BASE_DIR, "adblockbrowser") |
25 _CMD_BUILD = "build" | 26 _CMD_BUILD = "build" |
(...skipping 16 matching lines...) Expand all Loading... |
42 def print_usage(): | 43 def print_usage(): |
43 print >>sys.stderr, string.Template("""\ | 44 print >>sys.stderr, string.Template("""\ |
44 Usage: $name %s | 45 Usage: $name %s |
45 $name %s APK_PATH | 46 $name %s APK_PATH |
46 $name %s\ | 47 $name %s\ |
47 """ % (_CMD_BUILD, _CMD_SIGN, | 48 """ % (_CMD_BUILD, _CMD_SIGN, |
48 _CMD_BUILD_SIGN)).substitute({"name": os.path.basename(sys.argv[0])}) | 49 _CMD_BUILD_SIGN)).substitute({"name": os.path.basename(sys.argv[0])}) |
49 | 50 |
50 | 51 |
51 def _generate_mozconfig(architecture, distribution_mode, build_mode): | 52 def _generate_mozconfig(architecture, distribution_mode, build_mode): |
52 mozconfig_path = _GENERATED_MOZCONFIG_PATH | 53 if not os.path.exists(_GENERATED_PATH): |
53 with open(mozconfig_path, "w+") as mozconfig: | 54 os.makedirs(_GENERATED_PATH) |
| 55 with open(_GENERATED_MOZCONFIG_PATH, "w+") as mozconfig: |
54 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_COMMON_PATH) | 56 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_COMMON_PATH) |
55 if architecture == _ARCH_X86: | 57 if architecture == _ARCH_X86: |
56 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_X86_PATH) | 58 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_X86_PATH) |
57 else: | 59 else: |
58 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_ARM_PATH) | 60 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_ARM_PATH) |
59 if distribution_mode == _DIST_STORE: | 61 if distribution_mode == _DIST_STORE: |
60 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_STORE_PATH) | 62 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_STORE_PATH) |
61 if build_mode == _BUILD_RELEASE: | 63 if build_mode == _BUILD_RELEASE: |
62 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_RELEASE_PATH) | 64 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_RELEASE_PATH) |
63 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_CUSTOM_PATH) | 65 mozconfig.write(". \"%s\"\n" % _MOZCONFIG_CUSTOM_PATH) |
64 return mozconfig_path | 66 return _GENERATED_MOZCONFIG_PATH |
65 | 67 |
66 | 68 |
67 def _build(architecture, distribution_mode, build_mode, sdk_path, ndk_path): | 69 def _build(architecture, distribution_mode, build_mode, sdk_path, ndk_path): |
68 build_environment = os.environ.copy() | 70 build_environment = os.environ.copy() |
69 build_environment["ANDROID_SDK_PATH"] = sdk_path | 71 build_environment["ANDROID_SDK_PATH"] = sdk_path |
70 build_environment["ANDROID_NDK_PATH"] = ndk_path | 72 build_environment["ANDROID_NDK_PATH"] = ndk_path |
71 build_environment["MOZCONFIG"] = _generate_mozconfig( | 73 build_environment["MOZCONFIG"] = _generate_mozconfig( |
72 architecture, distribution_mode, build_mode) | 74 architecture, distribution_mode, build_mode) |
73 obj_dir = _OBJDIR_X86 if architecture == _ARCH_X86 else _OBJDIR_ARM | 75 obj_dir = _OBJDIR_X86 if architecture == _ARCH_X86 else _OBJDIR_ARM |
74 build_environment["OBJDIR"] = obj_dir | 76 build_environment["OBJDIR"] = obj_dir |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 "architecture", "architectures", _ARCHS
) | 156 "architecture", "architectures", _ARCHS
) |
155 sys.exit(6) | 157 sys.exit(6) |
156 | 158 |
157 if do_build: | 159 if do_build: |
158 apk_path = _build(architecture, distribution_mode, build_mode, | 160 apk_path = _build(architecture, distribution_mode, build_mode, |
159 config.ANDROID_SDK_PATH, config.ANDROID_NDK_PATH) | 161 config.ANDROID_SDK_PATH, config.ANDROID_NDK_PATH) |
160 if do_sign: | 162 if do_sign: |
161 _sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) | 163 _sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) |
162 else: | 164 else: |
163 print apk_path | 165 print apk_path |
OLD | NEW |