Make versionCode unconfigurable
This commit is contained in:
parent
12aa6d86e4
commit
8a2a6d9232
@ -22,7 +22,6 @@ android {
|
|||||||
multiDexEnabled = true
|
multiDexEnabled = true
|
||||||
versionName = Config.appVersion
|
versionName = Config.appVersion
|
||||||
versionCode = Config.appVersionCode
|
versionCode = Config.appVersionCode
|
||||||
buildConfigField("int", "LATEST_MAGISK", Config.magiskVersionCode.toString())
|
|
||||||
|
|
||||||
javaCompileOptions.annotationProcessorOptions.arguments(
|
javaCompileOptions.annotationProcessorOptions.arguments(
|
||||||
mapOf("room.incremental" to "true")
|
mapOf("room.incremental" to "true")
|
||||||
|
36
build.py
36
build.py
@ -55,9 +55,6 @@ arch64 = ['arm64-v8a', 'x86_64']
|
|||||||
support_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy', 'resetprop', 'busybox', 'test']
|
support_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy', 'resetprop', 'busybox', 'test']
|
||||||
default_targets = ['magisk', 'magiskinit', 'magiskboot', 'busybox']
|
default_targets = ['magisk', 'magiskinit', 'magiskboot', 'busybox']
|
||||||
|
|
||||||
ndk_ver = '21d'
|
|
||||||
ndk_ver_full = '21.3.6528147'
|
|
||||||
|
|
||||||
ndk_root = op.join(os.environ['ANDROID_SDK_ROOT'], 'ndk')
|
ndk_root = op.join(os.environ['ANDROID_SDK_ROOT'], 'ndk')
|
||||||
ndk_path = op.join(ndk_root, 'magisk')
|
ndk_path = op.join(ndk_root, 'magisk')
|
||||||
ndk_build = op.join(ndk_path, 'ndk-build')
|
ndk_build = op.join(ndk_path, 'ndk-build')
|
||||||
@ -141,23 +138,20 @@ def parse_props(file):
|
|||||||
|
|
||||||
|
|
||||||
def load_config(args):
|
def load_config(args):
|
||||||
commit_hash = cmd_out(['git', 'rev-parse', '--short=8', 'refs/heads/master'])
|
commit_hash = cmd_out(['git', 'rev-parse', '--short=8', 'HEAD'])
|
||||||
commit_count = cmd_out(['git', 'rev-list', '--count', 'refs/heads/master'])
|
|
||||||
|
|
||||||
# Some default values
|
# Default values
|
||||||
config['version'] = commit_hash
|
config['version'] = commit_hash
|
||||||
config['versionCode'] = 2147483647
|
|
||||||
config['appVersion'] = commit_hash
|
|
||||||
config['appVersionCode'] = commit_count
|
|
||||||
config['outdir'] = 'out'
|
config['outdir'] = 'out'
|
||||||
config['prettyName'] = 'false'
|
config['prettyName'] = 'false'
|
||||||
config['keyStore'] = 'release-key.jks'
|
|
||||||
|
|
||||||
# Load prop file
|
# Load prop files
|
||||||
if op.exists(args.config):
|
if op.exists(args.config):
|
||||||
config.update(parse_props(args.config))
|
config.update(parse_props(args.config))
|
||||||
|
|
||||||
# Sanitize configs
|
for key, value in parse_props('gradle.properties').items():
|
||||||
|
if key.startswith('magisk.'):
|
||||||
|
config[key[7:]] = value
|
||||||
|
|
||||||
config['prettyName'] = config['prettyName'].lower() == 'true'
|
config['prettyName'] = config['prettyName'].lower() == 'true'
|
||||||
|
|
||||||
@ -201,7 +195,7 @@ def clean_elf():
|
|||||||
|
|
||||||
|
|
||||||
def sign_zip(unsigned, output, release):
|
def sign_zip(unsigned, output, release):
|
||||||
if not release:
|
if not release or 'keyStore' not in config:
|
||||||
mv(unsigned, output)
|
mv(unsigned, output)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -289,7 +283,7 @@ def dump_bin_headers():
|
|||||||
def build_binary(args):
|
def build_binary(args):
|
||||||
# Verify NDK install
|
# Verify NDK install
|
||||||
props = parse_props(op.join(ndk_path, 'source.properties'))
|
props = parse_props(op.join(ndk_path, 'source.properties'))
|
||||||
if props['Pkg.Revision'] != ndk_ver_full:
|
if props['Pkg.Revision'] != config['fullNdkVersion']:
|
||||||
error('Incorrect NDK. Please install/upgrade NDK with "build.py ndk"')
|
error('Incorrect NDK. Please install/upgrade NDK with "build.py ndk"')
|
||||||
|
|
||||||
if args.target:
|
if args.target:
|
||||||
@ -301,12 +295,17 @@ def build_binary(args):
|
|||||||
|
|
||||||
header('* Building binaries: ' + ' '.join(args.target))
|
header('* Building binaries: ' + ' '.join(args.target))
|
||||||
|
|
||||||
update_flags = True
|
update_flags = False
|
||||||
flags = op.join('native', 'jni', 'include', 'flags.hpp')
|
flags = op.join('native', 'jni', 'include', 'flags.hpp')
|
||||||
|
flags_stat = os.stat(flags)
|
||||||
|
|
||||||
if op.exists(args.config):
|
if op.exists(args.config):
|
||||||
config_stat = os.stat(args.config)
|
if os.stat(args.config).st_mtime_ns > flags_stat.st_mtime_ns:
|
||||||
update_flags = config_stat.st_mtime_ns > os.stat(flags).st_mtime_ns
|
update_flags = True
|
||||||
|
|
||||||
|
last_commit = int(cmd_out(['git', 'log', '-1', r'--format=%at', 'HEAD']))
|
||||||
|
if last_commit > flags_stat.st_mtime:
|
||||||
|
update_flags = True
|
||||||
|
|
||||||
if update_flags:
|
if update_flags:
|
||||||
os.utime(flags)
|
os.utime(flags)
|
||||||
@ -522,6 +521,7 @@ def cleanup(args):
|
|||||||
|
|
||||||
def setup_ndk(args):
|
def setup_ndk(args):
|
||||||
os_name = platform.system().lower()
|
os_name = platform.system().lower()
|
||||||
|
ndk_ver = config['ndkVersion']
|
||||||
url = f'https://dl.google.com/android/repository/android-ndk-r{ndk_ver}-{os_name}-x86_64.zip'
|
url = f'https://dl.google.com/android/repository/android-ndk-r{ndk_ver}-{os_name}-x86_64.zip'
|
||||||
ndk_zip = url.split('/')[-1]
|
ndk_zip = url.split('/')[-1]
|
||||||
|
|
||||||
@ -578,7 +578,7 @@ parser.add_argument('-r', '--release', action='store_true',
|
|||||||
parser.add_argument('-v', '--verbose', action='store_true',
|
parser.add_argument('-v', '--verbose', action='store_true',
|
||||||
help='verbose output')
|
help='verbose output')
|
||||||
parser.add_argument('-c', '--config', default='config.prop',
|
parser.add_argument('-c', '--config', default='config.prop',
|
||||||
help='set config file (default: config.prop)')
|
help='custom config file (default: config.prop)')
|
||||||
subparsers = parser.add_subparsers(title='actions')
|
subparsers = parser.add_subparsers(title='actions')
|
||||||
|
|
||||||
all_parser = subparsers.add_parser(
|
all_parser = subparsers.add_parser(
|
||||||
|
@ -19,22 +19,21 @@ object Config {
|
|||||||
fun contains(key: String) = get(key) != null
|
fun contains(key: String) = get(key) != null
|
||||||
|
|
||||||
val appVersion: String get() = get("appVersion") ?: commitHash
|
val appVersion: String get() = get("appVersion") ?: commitHash
|
||||||
val appVersionCode: Int get() = get("appVersionCode")?.toInt() ?: commitCount
|
val appVersionCode: Int get() = commitCount
|
||||||
val magiskVersionCode: Int get() = get("versionCode")?.toInt() ?: Int.MAX_VALUE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MagiskPlugin : Plugin<Project> {
|
class MagiskPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
val configPath: String? by project
|
val configPath: String? by project
|
||||||
val config = configPath?.let { File(it) } ?: project.file("config.prop")
|
configPath?.let {
|
||||||
|
val config = File(it)
|
||||||
if (config.exists())
|
if (config.exists())
|
||||||
config.inputStream().use { props.load(it) }
|
config.inputStream().use { s -> props.load(s) }
|
||||||
|
}
|
||||||
|
|
||||||
if (!Config.contains("appVersion") || !Config.contains("appVersionCode")) {
|
|
||||||
val repo = FileRepository(project.rootProject.file(".git"))
|
val repo = FileRepository(project.rootProject.file(".git"))
|
||||||
val refId = repo.refDatabase.exactRef("refs/heads/master").objectId
|
val refId = repo.refDatabase.exactRef("HEAD").objectId
|
||||||
commitHash = repo.newObjectReader().abbreviate(refId, 8).name()
|
commitHash = repo.newObjectReader().abbreviate(refId, 8).name()
|
||||||
commitCount = Git(repo).log().add(refId).call().count()
|
commitCount = Git(repo).log().add(refId).call().count()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,14 @@
|
|||||||
# Removing or leaving them blank will keep default values
|
# Removing or leaving them blank will keep default values
|
||||||
##########################################################
|
##########################################################
|
||||||
|
|
||||||
# The version name and version code of Magisk
|
# The version name of Magisk. Default: git HEAD short SHA1
|
||||||
version=
|
version=string
|
||||||
versionCode=
|
|
||||||
|
|
||||||
# The version name and version code of Magisk Manager
|
# The version name of Magisk Manager. Default: git HEAD short SHA1
|
||||||
appVersion=
|
appVersion=string
|
||||||
appVersionCode=
|
|
||||||
|
|
||||||
# Output path
|
# Output path. Default: out
|
||||||
outdir=
|
outdir=string
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Whether to use pretty names for zips
|
# Whether to use pretty names for zips
|
||||||
@ -20,8 +18,8 @@ outdir=
|
|||||||
# Default names are magisk-${release/debug/uninstaller}.zip
|
# Default names are magisk-${release/debug/uninstaller}.zip
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
# The value is either true or false
|
# Default: false
|
||||||
prettyName=
|
prettyName=bool
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
# Signing configs for signing zips and APKs
|
# Signing configs for signing zips and APKs
|
||||||
@ -29,10 +27,10 @@ prettyName=
|
|||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
# Path to keystore file
|
# Path to keystore file
|
||||||
keyStore=
|
keyStore=string
|
||||||
# Keystore password
|
# Keystore password
|
||||||
keyStorePass=
|
keyStorePass=string
|
||||||
# The desired key alias in the keystore
|
# The desired key alias in the keystore
|
||||||
keyAlias=
|
keyAlias=string
|
||||||
# Password of specified key alias
|
# Password of specified key alias
|
||||||
keyPass=
|
keyPass=string
|
||||||
|
@ -21,7 +21,7 @@ org.gradle.parallel=true
|
|||||||
# The developer environment is optimized for speed and feedback so we nearly always run Gradle jobs with the daemon.
|
# The developer environment is optimized for speed and feedback so we nearly always run Gradle jobs with the daemon.
|
||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
|
|
||||||
#AndroidX
|
# Android
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=false
|
android.enableJetifier=false
|
||||||
android.enableR8.fullMode=true
|
android.enableR8.fullMode=true
|
||||||
@ -29,3 +29,8 @@ android.databinding.incremental=true
|
|||||||
|
|
||||||
android.injected.testOnly=false
|
android.injected.testOnly=false
|
||||||
kapt.incremental.apt=true
|
kapt.incremental.apt=true
|
||||||
|
|
||||||
|
# Magisk
|
||||||
|
magisk.versionCode=21102
|
||||||
|
magisk.ndkVersion=21d
|
||||||
|
magisk.fullNdkVersion=21.3.6528147
|
||||||
|
Loading…
Reference in New Issue
Block a user