Small build script adjustments

This commit is contained in:
topjohnwu 2018-08-06 19:32:37 +08:00
parent 2fbfeacb87
commit e139f4fc13

View File

@ -49,6 +49,7 @@ cpu_count = multiprocessing.cpu_count()
gradlew = os.path.join('.', 'gradlew.bat' if os.name == 'nt' else 'gradlew') gradlew = os.path.join('.', 'gradlew.bat' if os.name == 'nt' else 'gradlew')
archs = ['armeabi-v7a', 'x86'] archs = ['armeabi-v7a', 'x86']
keystore = 'release-key.jks' keystore = 'release-key.jks'
config = {}
def mv(source, target): def mv(source, target):
try: try:
@ -426,34 +427,33 @@ def cleanup(args):
execv([gradlew, 'app:clean', 'snet:clean', 'utils:clean']) execv([gradlew, 'app:clean', 'snet:clean', 'utils:clean'])
def parse_config(): def parse_config():
c = {} global config
with open('config.prop', 'r') as f: with open('config.prop', 'r') as f:
for line in [l.strip(' \t\r\n') for l in f]: for line in [l.strip(' \t\r\n') for l in f]:
if line.startswith('#') or len(line) == 0: if line.startswith('#') or len(line) == 0:
continue continue
prop = line.split('=') prop = line.split('=')
c[prop[0].strip(' \t\r\n')] = prop[1].strip(' \t\r\n') config[prop[0].strip(' \t\r\n')] = prop[1].strip(' \t\r\n')
if 'version' not in c or 'versionCode' not in c: if 'version' not in config or 'versionCode' not in config:
error('"version" and "versionCode" is required in "config.prop"') error('"version" and "versionCode" is required in "config.prop"')
try: try:
c['versionCode'] = int(c['versionCode']) config['versionCode'] = int(config['versionCode'])
except ValueError: except ValueError:
error('"versionCode" is required to be an integer') error('"versionCode" is required to be an integer')
if 'prettyName' not in c: if 'prettyName' not in config:
c['prettyName'] = 'false' config['prettyName'] = 'false'
c['prettyName'] = c['prettyName'].lower() == 'true' config['prettyName'] = config['prettyName'].lower() == 'true'
if 'outdir' not in c: if 'outdir' not in config:
c['outdir'] = 'out' config['outdir'] = 'out'
mkdir_p(c['outdir']) mkdir_p(config['outdir'])
return c
config = parse_config() parse_config()
parser = argparse.ArgumentParser(description='Magisk build script') parser = argparse.ArgumentParser(description='Magisk build script')
parser.add_argument('-r', '--release', action='store_true', help='compile Magisk for release') parser.add_argument('-r', '--release', action='store_true', help='compile Magisk for release')