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

Side by Side Diff: build.py

Issue 29399743: Issue 3768 - Check (and fix, if needed) multilocale builds (Closed)
Patch Set: Created March 31, 2017, 9:34 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
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 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
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)
anton 2017/04/03 06:28:11 i had to figure this out when trying to build it a
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 146
145 build_mode = config.BUILD_MODE 147 build_mode = config.BUILD_MODE
146 if build_mode not in _BUILD_MODES: 148 if build_mode not in _BUILD_MODES:
147 print >>sys.stderr, error_msg % ( 149 print >>sys.stderr, error_msg % (
148 "build mode", "build modes", _BUILD_MODES) 150 "build mode", "build modes", _BUILD_MODES)
149 sys.exit(5) 151 sys.exit(5)
150 152
151 architecture = config.ARCHITECTURE 153 architecture = config.ARCHITECTURE
152 if architecture not in _ARCHS: 154 if architecture not in _ARCHS:
153 print >>sys.stderr, error_msg % ( 155 print >>sys.stderr, error_msg % (
154 "architecture", "architectures", _ARCHS ) 156 "architecture", "architectures", _ARCHS)
Felix Dahlke 2017/03/31 09:53:54 Seems unrelated, could you do this in a separate n
diegocarloslima 2017/03/31 10:07:23 Acknowledged.
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
OLDNEW

Powered by Google App Engine
This is Rietveld