From c2e673f978f7b9e9e7e7ddc946c62cfa8346be96 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 16 Jul 2018 06:52:18 +0800 Subject: [PATCH] Less boilerplate in build script --- build.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build.py b/build.py index f154a10c8..5d4534995 100755 --- a/build.py +++ b/build.py @@ -42,6 +42,7 @@ else: ndk_build = os.path.join(os.environ['ANDROID_HOME'], 'ndk-bundle', 'ndk-build') cpu_count = multiprocessing.cpu_count() +gradlew = os.path.join('.', 'gradlew.bat' if os.name == 'nt' else 'gradlew') archs = ['armeabi-v7a', 'x86'] def mv(source, target): @@ -203,7 +204,7 @@ def build_apk(args): if not os.path.exists('release-key.jks'): error('Please generate a java keystore and place it in \'release-key.jks\'') - proc = subprocess.run('{} app:assembleRelease'.format(os.path.join('.', 'gradlew.bat' if os.name == 'nt' else 'gradlew')), shell=True, stdout=STDOUT) + proc = subprocess.run('{} app:assembleRelease'.format(gradlew), shell=True, stdout=STDOUT) if proc.returncode != 0: error('Build Magisk Manager failed!') @@ -219,7 +220,7 @@ def build_apk(args): header('Output: ' + release) rm(unsigned) else: - proc = subprocess.run('{} app:assembleDebug'.format(os.path.join('.', 'gradlew.bat' if os.name == 'nt' else 'gradlew')), shell=True, stdout=STDOUT) + proc = subprocess.run('{} app:assembleDebug'.format(gradlew), shell=True, stdout=STDOUT) if proc.returncode != 0: error('Build Magisk Manager failed!') @@ -234,7 +235,7 @@ def build_apk(args): header('Output: ' + target) def build_snet(args): - proc = subprocess.run('{} snet:assembleRelease'.format(os.path.join('.', 'gradlew.bat' if os.name == 'nt' else 'gradlew')), shell=True, stdout=STDOUT) + proc = subprocess.run('{} snet:assembleRelease'.format(gradlew), shell=True, stdout=STDOUT) if proc.returncode != 0: error('Build snet extention failed!') source = os.path.join('snet', 'build', 'outputs', 'apk', 'release', 'snet-release-unsigned.apk') @@ -390,7 +391,7 @@ def sign_adjust_zip(unsigned, output): if not os.path.exists(jarsigner): header('* Building ' + signer_name) - proc = subprocess.run('{} utils:shadowJar'.format(os.path.join('.', 'gradlew.bat' if os.name == 'nt' else 'gradlew')), shell=True, stdout=STDOUT) + proc = subprocess.run('{} utils:shadowJar'.format(gradlew), shell=True, stdout=STDOUT) if proc.returncode != 0: error('Build {} failed!'.format(signer_name))