mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 12:35:26 +00:00
Support custom config paths
This commit is contained in:
parent
0543239cca
commit
ad7ec79903
50
build.py
50
build.py
@ -397,34 +397,10 @@ def build_all(args):
|
|||||||
zip_uninstaller(args)
|
zip_uninstaller(args)
|
||||||
build_snet(args)
|
build_snet(args)
|
||||||
|
|
||||||
with open('config.prop', 'r') as f:
|
|
||||||
for line in [l.strip(' \t\r\n') for l in f]:
|
|
||||||
if line.startswith('#') or len(line) == 0:
|
|
||||||
continue
|
|
||||||
prop = line.split('=')
|
|
||||||
config[prop[0].strip(' \t\r\n')] = prop[1].strip(' \t\r\n')
|
|
||||||
|
|
||||||
if 'version' not in config or 'versionCode' not in config:
|
|
||||||
error('"version" and "versionCode" is required in "config.prop"')
|
|
||||||
|
|
||||||
try:
|
|
||||||
config['versionCode'] = int(config['versionCode'])
|
|
||||||
except ValueError:
|
|
||||||
error('"versionCode" is required to be an integer')
|
|
||||||
|
|
||||||
if 'prettyName' not in config:
|
|
||||||
config['prettyName'] = 'false'
|
|
||||||
|
|
||||||
config['prettyName'] = config['prettyName'].lower() == 'true'
|
|
||||||
|
|
||||||
if 'outdir' not in config:
|
|
||||||
config['outdir'] = 'out'
|
|
||||||
|
|
||||||
mkdir_p(config['outdir'])
|
|
||||||
|
|
||||||
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')
|
||||||
parser.add_argument('-v', '--verbose', action='store_true', help='verbose output')
|
parser.add_argument('-v', '--verbose', action='store_true', help='verbose output')
|
||||||
|
parser.add_argument('-c', '--config', default='config.prop', help='config file location')
|
||||||
subparsers = parser.add_subparsers(title='actions')
|
subparsers = parser.add_subparsers(title='actions')
|
||||||
|
|
||||||
all_parser = subparsers.add_parser('all', help='build everything (binaries/apks/zips)')
|
all_parser = subparsers.add_parser('all', help='build everything (binaries/apks/zips)')
|
||||||
@ -458,6 +434,30 @@ if len(sys.argv) == 1:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Some default values
|
||||||
|
config['outdir'] = 'out'
|
||||||
|
config['prettyName'] = 'false'
|
||||||
|
|
||||||
|
with open(args.config, 'r') as f:
|
||||||
|
for line in [l.strip(' \t\r\n') for l in f]:
|
||||||
|
if line.startswith('#') or len(line) == 0:
|
||||||
|
continue
|
||||||
|
prop = line.split('=')
|
||||||
|
config[prop[0].strip(' \t\r\n')] = prop[1].strip(' \t\r\n')
|
||||||
|
|
||||||
|
if 'version' not in config or 'versionCode' not in config:
|
||||||
|
error('"version" and "versionCode" is required in "config.prop"')
|
||||||
|
|
||||||
|
try:
|
||||||
|
config['versionCode'] = int(config['versionCode'])
|
||||||
|
except ValueError:
|
||||||
|
error('"versionCode" is required to be an integer')
|
||||||
|
|
||||||
|
config['prettyName'] = config['prettyName'].lower() == 'true'
|
||||||
|
|
||||||
|
mkdir_p(config['outdir'])
|
||||||
|
|
||||||
if args.release and not os.path.exists(keystore):
|
if args.release and not os.path.exists(keystore):
|
||||||
error('Please generate a java keystore and place it in \'{}\''.format(keystore))
|
error('Please generate a java keystore and place it in \'{}\''.format(keystore))
|
||||||
STDOUT = None if args.verbose else subprocess.DEVNULL
|
STDOUT = None if args.verbose else subprocess.DEVNULL
|
||||||
|
Loading…
Reference in New Issue
Block a user