Copy stub APK into output directory

This commit is contained in:
topjohnwu 2022-12-26 15:23:06 -08:00 committed by John Wu
parent ad0e6511e1
commit 7ce4bd3330
2 changed files with 24 additions and 8 deletions

View File

@ -425,6 +425,19 @@ def build_app(args):
header('* Building the Magisk app')
build_apk(args, 'app')
# Stub building is directly integrated into the main app
# build process. Copy the stub APK into output directory.
build_type = 'release' if args.release else 'debug'
apk = f'stub-{build_type}.apk'
source = op.join('app', 'src', 'main', 'assets', 'stub.apk')
target = op.join(config['outdir'], apk)
cp(source, target)
def build_stub(args):
header('* Building the stub app')
build_apk(args, 'stub')
def cleanup(args):
support_targets = {'native', 'java'}
@ -444,6 +457,7 @@ def cleanup(args):
if 'java' in args.target:
header('* Cleaning java')
execv([gradlew, 'app:clean', 'app:shared:clean', 'stub:clean'])
rm_rf(op.join('app', 'src', 'main', 'assets'))
def setup_ndk(args):
@ -570,6 +584,9 @@ binary_parser.set_defaults(func=build_binary)
app_parser = subparsers.add_parser('app', help='build the Magisk app')
app_parser.set_defaults(func=build_app)
stub_parser = subparsers.add_parser('stub', help='build the stub app')
stub_parser.set_defaults(func=build_stub)
avd_parser = subparsers.add_parser(
'emulator', help='setup AVD for development')
avd_parser.add_argument('-s', '--skip', action='store_true',

View File

@ -192,10 +192,14 @@ fun Project.setupApp() {
android.applicationVariants.all {
val variantCapped = name.capitalize(Locale.ROOT)
val variantLowered = name.toLowerCase(Locale.ROOT)
val stubTask = tasks.getByPath(":stub:package$variantCapped")
val stubApk = stubTask.outputs.files.asFileTree.filter {
it.name.endsWith(".apk")
}
val syncAssets = tasks.register("sync${variantCapped}Assets", Sync::class) {
dependsOn(syncResources)
dependsOn(syncResources, stubTask)
inputs.property("version", Config.version)
inputs.property("versionCode", Config.versionCode)
into("src/main/assets")
@ -210,12 +214,7 @@ fun Project.setupApp() {
include("kernel_data_key.vbprivk", "kernel.keyblock")
}
}
val task = tasks.getByPath(":stub:package$variantCapped")
dependsOn(task)
val apk = task.outputs.files.asFileTree.filter {
it.name.endsWith(".apk")
}
from(apk) {
from(stubApk) {
rename { "stub.apk" }
}
filesMatching("**/util_functions.sh") {