From b127e01845093f5404f524485ad86ef53611d5b1 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 28 Sep 2018 02:05:55 -0400 Subject: [PATCH] Simplify debug flag propagation --- build.py | 5 +++-- native/build.gradle | 3 +-- native/jni/Application.mk | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build.py b/build.py index 698a6dfee..131291f1f 100755 --- a/build.py +++ b/build.py @@ -173,8 +173,9 @@ def build_binary(args): os.utime(os.path.join('native', 'jni', 'include', 'flags.h')) # Basic flags - base_flags = 'MAGISK_VERSION=\"{}\" MAGISK_VER_CODE={} MAGISK_DEBUG={}'.format(config['version'], config['versionCode'], - '' if args.release else '-DMAGISK_DEBUG') + base_flags = 'MAGISK_VERSION=\"{}\" MAGISK_VER_CODE={}'.format(config['version'], config['versionCode']) + if not args.release: + base_flags += ' MAGISK_DEBUG=1' if 'magisk' in args.target: # Magisk is special case as it is a dependency of magiskinit diff --git a/native/build.gradle b/native/build.gradle index 63c5d4e72..1bc8cafa4 100644 --- a/native/build.gradle +++ b/native/build.gradle @@ -14,8 +14,7 @@ android { externalNativeBuild { ndkBuild { // Pass arguments to ndk-build. - arguments('B_MAGISK=1', 'B_INIT=1', 'B_BOOT=1', 'B_BXZ=1', - 'MAGISK_DEBUG=-DMAGISK_DEBUG') + arguments('B_MAGISK=1', 'B_INIT=1', 'B_BOOT=1', 'B_BXZ=1', 'MAGISK_DEBUG=1') } } } diff --git a/native/jni/Application.mk b/native/jni/Application.mk index 3853dce4f..338821cd6 100644 --- a/native/jni/Application.mk +++ b/native/jni/Application.mk @@ -1,10 +1,13 @@ APP_ABI := armeabi-v7a x86 -APP_CFLAGS := -std=gnu11 ${MAGISK_DEBUG} \ - -DMAGISK_VERSION="${MAGISK_VERSION}" -DMAGISK_VER_CODE=${MAGISK_VER_CODE} +APP_CFLAGS := -std=gnu11 -DMAGISK_VERSION="${MAGISK_VERSION}" -DMAGISK_VER_CODE=${MAGISK_VER_CODE} APP_CPPFLAGS := -std=c++14 APP_STL := system APP_PLATFORM := android-16 +ifdef MAGISK_DEBUG +APP_CFLAGS += -DMAGISK_DEBUG +endif + # Busybox require some additional settings ifdef B_BB APP_SHORT_COMMANDS := true