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

Side by Side Diff: build.py

Issue 29323547: Issue 2751 - Separate build and sign steps (Closed)
Patch Set: Created Aug. 13, 2015, 7:15 a.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 | no next file » | 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 subprocess 8 import subprocess
8 import sys 9 import sys
9 import tempfile 10 import tempfile
10 11
11 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 12 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
12 ENSURE_DEPENDENCIES_PATH = os.path.join(BASE_DIR, "ensure_dependencies.py") 13 ENSURE_DEPENDENCIES_PATH = os.path.join(BASE_DIR, "ensure_dependencies.py")
13 MULTI_L10N_PATH = os.path.join(BASE_DIR, "mozharness", "scripts", 14 MULTI_L10N_PATH = os.path.join(BASE_DIR, "mozharness", "scripts",
14 "multil10n.py") 15 "multil10n.py")
15 DIST_PATH = os.path.join(BASE_DIR, "adblockbrowser", 16 DIST_PATH = os.path.join(BASE_DIR, "adblockbrowser",
16 "obj-arm-linux-androideabi", "dist") 17 "obj-arm-linux-androideabi", "dist")
17 18
18 def print_usage(): 19 def print_usage():
19 print >>sys.stderr, "Usage: %s devbuild|release" % \ 20 print >>sys.stderr, string.Template("""\
20 os.path.basename(sys.argv[0]) 21 Usage: $name build devbuild|release
22 $name sign APK_PATH
23 $name build-and-sign devbuild|release\
24 """).substitute({"name": os.path.basename(sys.argv[0])})
21 25
22 def check_mozconfig(path, mode): 26 def check_mozconfig(path, mode):
23 if not os.path.exists(path): 27 if not os.path.exists(path):
24 raise Exception("'%s' doesn't exist, please create it." % path) 28 raise Exception("'%s' doesn't exist, please create it." % path)
25 29
26 with open(path) as file: 30 with open(path) as file:
27 contents = file.read() 31 contents = file.read()
28 32
29 # 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
30 # done. 34 # done.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 try: 82 try:
79 subprocess.check_call(["jarsigner", "-verbose", "-sigalg", "SHA1withRSA", 83 subprocess.check_call(["jarsigner", "-verbose", "-sigalg", "SHA1withRSA",
80 "-digestalg", "SHA1", "-keystore", key_store, 84 "-digestalg", "SHA1", "-keystore", key_store,
81 temp_apk_path, key_name]) 85 temp_apk_path, key_name])
82 os.remove(apk_path) 86 os.remove(apk_path)
83 subprocess.check_call(["zipalign", "-v", "4", temp_apk_path, apk_path]) 87 subprocess.check_call(["zipalign", "-v", "4", temp_apk_path, apk_path])
84 finally: 88 finally:
85 os.remove(temp_apk_path) 89 os.remove(temp_apk_path)
86 90
87 if __name__ == "__main__": 91 if __name__ == "__main__":
88 if len(sys.argv) < 2: 92 if len(sys.argv) < 3:
89 print_usage() 93 print_usage()
90 sys.exit(1) 94 sys.exit(1)
91 95
92 mode = sys.argv[1] 96 mode = sys.argv[1]
93 if mode not in ("devbuild", "release"): 97 do_build = mode in ("build", "build-and-sign")
98 do_sign = mode in ("sign", "build-and-sign")
99 if not do_build and not do_sign:
94 print_usage() 100 print_usage()
95 sys.exit(2) 101 sys.exit(2)
96 102
103 if do_build:
104 build_mode = sys.argv[2]
105 if build_mode not in ("devbuild", "release"):
106 print_usage()
107 sys.exit(3)
108
109 if do_sign:
110 apk_path = sys.argv[2]
111
97 subprocess.check_call([ENSURE_DEPENDENCIES_PATH]) 112 subprocess.check_call([ENSURE_DEPENDENCIES_PATH])
98 import config 113 import config
99 apk_path = build(mode, config.ANDROID_SDK_PATH, config.ANDROID_NDK_PATH) 114
100 sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) 115 if do_build:
116 apk_path = build(build_mode, config.ANDROID_SDK_PATH,
117 config.ANDROID_NDK_PATH)
118 if do_sign:
119 sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME)
120 else:
René Jeschke 2015/08/13 08:01:52 Nit: this (and the next line) could be removed, as
121 print apk_path
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld