Index: build.py |
=================================================================== |
--- a/build.py |
+++ b/build.py |
@@ -18,12 +18,12 @@ |
def print_usage(): |
print >>sys.stderr, string.Template("""\ |
-Usage: $name build devbuild|release |
+Usage: $name build |
$name sign APK_PATH |
- $name build-and-sign devbuild|release\ |
+ $name build-and-sign\ |
""").substitute({"name": os.path.basename(sys.argv[0])}) |
-def check_mozconfig(path, distribution_mode): |
+def check_mozconfig(path, distribution_mode, build_mode): |
if not os.path.exists(path): |
raise Exception("'%s' doesn't exist, please create it." % path) |
@@ -47,14 +47,22 @@ |
raise Exception( |
"'%s' doesn't seem to set --disable-updater, please do." % path) |
-def find_mozconfig(mode): |
- mozconfig_path = os.path.join(BASE_DIR, "mozconfig-" + mode) |
- check_mozconfig(mozconfig_path, mode) |
+ release_build = "export ABB_RELEASE_BUILD=1" in contents |
+ if release_build and build_mode != "release": |
+ raise Exception("'%s' shouldn't export ABB_RELEASE_BUILD=1." % path) |
+ elif not release_build and build_mode == "release": |
+ raise Exception("'%s' should export ABB_RELEASE_BUILD=1." % path) |
+ |
+def find_mozconfig(distribution_mode, build_mode): |
+ mozconfig_path = os.path.join(BASE_DIR, "mozconfig-" + distribution_mode + |
+ "-" + build_mode) |
+ check_mozconfig(mozconfig_path, distribution_mode, build_mode) |
return mozconfig_path |
-def build(build_mode, distribution_mode, sdk_path, ndk_path): |
+def build(distribution_mode, build_mode, sdk_path, ndk_path): |
mozharness_environment = os.environ.copy() |
- mozharness_environment["MOZCONFIG"] = find_mozconfig(distribution_mode) |
+ mozharness_environment["MOZCONFIG"] = find_mozconfig(distribution_mode, |
+ build_mode) |
mozharness_environment["ANDROID_SDK_PATH"] = sdk_path |
mozharness_environment["ANDROID_NDK_PATH"] = ndk_path |
@@ -89,7 +97,7 @@ |
os.remove(temp_apk_path) |
if __name__ == "__main__": |
- if len(sys.argv) < 3: |
+ if len(sys.argv) < 2: |
print_usage() |
sys.exit(1) |
@@ -100,13 +108,10 @@ |
print_usage() |
sys.exit(2) |
- if do_build: |
- build_mode = sys.argv[2] |
- if build_mode not in ("devbuild", "release"): |
+ if do_sign: |
+ if len(sys.argv) < 3: |
print_usage() |
sys.exit(3) |
- |
- if do_sign: |
apk_path = sys.argv[2] |
subprocess.check_call([ENSURE_DEPENDENCIES_PATH]) |
@@ -117,8 +122,13 @@ |
print >>sys.stderr, "Invalid distribution mode, check config.py" |
sys.exit(4) |
+ build_mode = config.BUILD_MODE |
+ if build_mode not in ("devbuild", "release"): |
+ print >>sys.stderr, "Invalid build mode, check config.py" |
+ sys.exit(5) |
+ |
if do_build: |
- apk_path = build(build_mode, distribution_mode, config.ANDROID_SDK_PATH, |
+ apk_path = build(distribution_mode, build_mode, config.ANDROID_SDK_PATH, |
config.ANDROID_NDK_PATH) |
if do_sign: |
sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) |