Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: build.py

Issue 29325999: Issue 2995 - Set ABB_RELEASE_BUILD properly (Closed)
Patch Set: Created Sept. 5, 2015, 3:39 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | config.py.sample » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 Usage: $name build
22 $name sign APK_PATH 22 $name sign APK_PATH
23 $name build-and-sign devbuild|release\ 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): 26 def check_mozconfig(path, distribution_mode, build_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
34 # done. 34 # done.
35 if "--disable-crashreporter" not in contents: 35 if "--disable-crashreporter" not in contents:
36 raise Exception( 36 raise Exception(
37 "'%s' doesn't seem to set --disable-crashreporter, please do." % path) 37 "'%s' doesn't seem to set --disable-crashreporter, please do." % path)
38 38
39 if "export MOZILLA_OFFICIAL=1" not in contents: 39 if "export MOZILLA_OFFICIAL=1" not in contents:
40 raise Exception( 40 raise Exception(
41 "'%s' doesn't seem to export MOZILLA_OFFICIAL=1, please do." % path) 41 "'%s' doesn't seem to export MOZILLA_OFFICIAL=1, please do." % path)
42 42
43 updater_disabled = "--disable-updater" in contents 43 updater_disabled = "--disable-updater" in contents
44 if updater_disabled and distribution_mode == "standalone": 44 if updater_disabled and distribution_mode == "standalone":
45 raise Exception("'%s' seems to set --disable-updater, please don't." % path) 45 raise Exception("'%s' seems to set --disable-updater, please don't." % path)
46 elif not updater_disabled and distribution_mode == "store": 46 elif not updater_disabled and distribution_mode == "store":
47 raise Exception( 47 raise Exception(
48 "'%s' doesn't seem to set --disable-updater, please do." % path) 48 "'%s' doesn't seem to set --disable-updater, please do." % path)
49 49
50 def find_mozconfig(mode): 50 release_build = "export ABB_RELEASE_BUILD=1" in contents
51 mozconfig_path = os.path.join(BASE_DIR, "mozconfig-" + mode) 51 if release_build and build_mode != "release":
52 check_mozconfig(mozconfig_path, mode) 52 raise Exception("'%s' shouldn't export ABB_RELEASE_BUILD=1." % path)
53 elif not release_build and build_mode == "release":
54 raise Exception("'%s' should export ABB_RELEASE_BUILD=1." % path)
55
56 def find_mozconfig(distribution_mode, build_mode):
57 mozconfig_path = os.path.join(BASE_DIR, "mozconfig-" + distribution_mode +
58 "-" + build_mode)
59 check_mozconfig(mozconfig_path, distribution_mode, build_mode)
53 return mozconfig_path 60 return mozconfig_path
54 61
55 def build(build_mode, distribution_mode, sdk_path, ndk_path): 62 def build(distribution_mode, build_mode, sdk_path, ndk_path):
56 mozharness_environment = os.environ.copy() 63 mozharness_environment = os.environ.copy()
57 mozharness_environment["MOZCONFIG"] = find_mozconfig(distribution_mode) 64 mozharness_environment["MOZCONFIG"] = find_mozconfig(distribution_mode,
65 build_mode)
58 mozharness_environment["ANDROID_SDK_PATH"] = sdk_path 66 mozharness_environment["ANDROID_SDK_PATH"] = sdk_path
59 mozharness_environment["ANDROID_NDK_PATH"] = ndk_path 67 mozharness_environment["ANDROID_NDK_PATH"] = ndk_path
60 68
61 subprocess.check_call([MULTI_L10N_PATH, "--cfg", "adblockbrowser-cfg.py"], 69 subprocess.check_call([MULTI_L10N_PATH, "--cfg", "adblockbrowser-cfg.py"],
62 env=mozharness_environment) 70 env=mozharness_environment)
63 71
64 [manifest_path] = glob.glob(os.path.join( 72 [manifest_path] = glob.glob(os.path.join(
65 DIST_PATH, "fennec-*.multi.android-arm.json")) 73 DIST_PATH, "fennec-*.multi.android-arm.json"))
66 with open(manifest_path) as manifest_file: 74 with open(manifest_path) as manifest_file:
67 manifest = json.load(manifest_file) 75 manifest = json.load(manifest_file)
(...skipping 14 matching lines...) Expand all
82 try: 90 try:
83 subprocess.check_call(["jarsigner", "-verbose", "-sigalg", "SHA1withRSA", 91 subprocess.check_call(["jarsigner", "-verbose", "-sigalg", "SHA1withRSA",
84 "-digestalg", "SHA1", "-keystore", key_store, 92 "-digestalg", "SHA1", "-keystore", key_store,
85 temp_apk_path, key_name]) 93 temp_apk_path, key_name])
86 os.remove(apk_path) 94 os.remove(apk_path)
87 subprocess.check_call(["zipalign", "-v", "4", temp_apk_path, apk_path]) 95 subprocess.check_call(["zipalign", "-v", "4", temp_apk_path, apk_path])
88 finally: 96 finally:
89 os.remove(temp_apk_path) 97 os.remove(temp_apk_path)
90 98
91 if __name__ == "__main__": 99 if __name__ == "__main__":
92 if len(sys.argv) < 3: 100 if len(sys.argv) < 2:
93 print_usage() 101 print_usage()
94 sys.exit(1) 102 sys.exit(1)
95 103
96 mode = sys.argv[1] 104 mode = sys.argv[1]
97 do_build = mode in ("build", "build-and-sign") 105 do_build = mode in ("build", "build-and-sign")
98 do_sign = mode in ("sign", "build-and-sign") 106 do_sign = mode in ("sign", "build-and-sign")
99 if not do_build and not do_sign: 107 if not do_build and not do_sign:
100 print_usage() 108 print_usage()
101 sys.exit(2) 109 sys.exit(2)
102 110
103 if do_build: 111 if do_sign:
104 build_mode = sys.argv[2] 112 if len(sys.argv) < 3:
105 if build_mode not in ("devbuild", "release"):
106 print_usage() 113 print_usage()
107 sys.exit(3) 114 sys.exit(3)
108
109 if do_sign:
110 apk_path = sys.argv[2] 115 apk_path = sys.argv[2]
111 116
112 subprocess.check_call([ENSURE_DEPENDENCIES_PATH]) 117 subprocess.check_call([ENSURE_DEPENDENCIES_PATH])
113 import config 118 import config
114 119
115 distribution_mode = config.DISTRIBUTION_MODE 120 distribution_mode = config.DISTRIBUTION_MODE
116 if distribution_mode not in ("standalone", "store"): 121 if distribution_mode not in ("standalone", "store"):
117 print >>sys.stderr, "Invalid distribution mode, check config.py" 122 print >>sys.stderr, "Invalid distribution mode, check config.py"
118 sys.exit(4) 123 sys.exit(4)
119 124
125 build_mode = config.BUILD_MODE
126 if build_mode not in ("devbuild", "release"):
127 print >>sys.stderr, "Invalid build mode, check config.py"
128 sys.exit(5)
129
120 if do_build: 130 if do_build:
121 apk_path = build(build_mode, distribution_mode, config.ANDROID_SDK_PATH, 131 apk_path = build(distribution_mode, build_mode, config.ANDROID_SDK_PATH,
122 config.ANDROID_NDK_PATH) 132 config.ANDROID_NDK_PATH)
123 if do_sign: 133 if do_sign:
124 sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) 134 sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME)
125 else: 135 else:
126 print apk_path 136 print apk_path
OLDNEW
« no previous file with comments | « no previous file | config.py.sample » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld