diff --git a/build.py b/build.py index bf5c917ec..20d0dd953 100755 --- a/build.py +++ b/build.py @@ -104,17 +104,35 @@ def build_binary(args): os.utime(os.path.join('native', 'jni', 'include', 'logging.h')) # Basic flags - flags = 'MAGISK_VERSION=\"{}\" MAGISK_VER_CODE={} MAGISK_DEBUG={}'.format(config['version'], config['versionCode'], + base_flags = 'MAGISK_VERSION=\"{}\" MAGISK_VER_CODE={} MAGISK_DEBUG={}'.format(config['version'], config['versionCode'], '' if args.release else '-DMAGISK_DEBUG') if 'magisk' in args.target: # Magisk is special case as it is a dependency of magiskinit - proc = subprocess.run('{} -C native {} B_MAGISK=true -j{}'.format(ndk_build, flags, cpu_count), shell=True) + proc = subprocess.run('{} -C native {} B_MAGISK=1 -j{}'.format(ndk_build, base_flags, cpu_count), shell=True) if proc.returncode != 0: error('Build Magisk binary failed!') collect_binary() - non_magisk = False + old_platform = False + flags = base_flags + + if 'busybox' in args.target: + flags += ' B_BB=1' + old_platform = True + + if 'b64xz' in args.target: + flags += ' B_BXZ=1' + old_platform = True + + if old_platform: + proc = subprocess.run('{} -C native OLD_PLAT=1 {} -j{}'.format(ndk_build, flags, cpu_count), shell=True) + if proc.returncode != 0: + error('Build binaries failed!') + collect_binary() + + other = False + flags = base_flags if 'magiskinit' in args.target: # We need to create dump.h beforehand @@ -127,22 +145,14 @@ def build_binary(args): dump.write('const uint8_t magisk_dump[] = "') dump.write(''.join("\\x{:02X}".format(c) for c in lzma.compress(bin.read(), preset=9))) dump.write('";\n') - flags += ' B_INIT=true' - non_magisk = True + flags += ' B_INIT=1' + other = True if 'magiskboot' in args.target: - flags += ' B_BOOT=true' - non_magisk = True + flags += ' B_BOOT=1' + other = True - if 'busybox' in args.target: - flags += ' B_BB=true' - non_magisk = True - - if 'b64xz' in args.target: - flags += ' B_BXZ=true' - non_magisk = True - - if non_magisk: + if other: proc = subprocess.run('{} -C native {} -j{}'.format(ndk_build, flags, cpu_count), shell=True) if proc.returncode != 0: error('Build binaries failed!') @@ -369,7 +379,7 @@ def cleanup(args): if 'binary' in args.target: header('* Cleaning binaries') - subprocess.run(ndk_build + ' -C native B_MAGISK=true B_INIT=true B_BOOT=true B_BXZ=true B_BB=true clean', shell=True) + subprocess.run(ndk_build + ' -C native B_MAGISK=1 B_INIT=1 B_BOOT=1 B_BXZ=1 B_BB=1 clean', shell=True) shutil.rmtree(os.path.join('native', 'out'), ignore_errors=True) if 'java' in args.target: diff --git a/native/build.gradle b/native/build.gradle index e0f3c8eb5..95b2a51da 100644 --- a/native/build.gradle +++ b/native/build.gradle @@ -14,7 +14,7 @@ android { externalNativeBuild { ndkBuild { // Pass arguments to ndk-build. - arguments('B_MAGISK=true', 'B_INIT=true', 'B_BOOT=true', 'MAGISK_VERSION=debug', + arguments('B_MAGISK=1', 'B_INIT=1', 'B_BOOT=1', 'MAGISK_VERSION=debug', 'MAGISK_VER_CODE=99999', 'MAGISK_DEBUG=-DMAGISK_DEBUG') } } diff --git a/native/jni/Android.mk b/native/jni/Android.mk index 2532efa2c..90d7bc63e 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -57,8 +57,7 @@ LOCAL_SRC_FILES := \ su/su_socket.c \ $(UTIL_SRC) -LOCAL_CFLAGS := -DIS_DAEMON -DSELINUX ${MAGISK_DEBUG} \ - -DMAGISK_VERSION="${MAGISK_VERSION}" -DMAGISK_VER_CODE=${MAGISK_VER_CODE} +LOCAL_CFLAGS := -DIS_DAEMON -DSELINUX LOCAL_LDLIBS := -llog include $(BUILD_EXECUTABLE) diff --git a/native/jni/Application.mk b/native/jni/Application.mk index 6969fbdf7..df3c77e35 100644 --- a/native/jni/Application.mk +++ b/native/jni/Application.mk @@ -1,5 +1,10 @@ APP_ABI := x86 armeabi-v7a -APP_PLATFORM := android-21 -APP_CFLAGS := -std=gnu99 +APP_CFLAGS := -std=gnu99 ${MAGISK_DEBUG} \ + -DMAGISK_VERSION="${MAGISK_VERSION}" -DMAGISK_VER_CODE=${MAGISK_VER_CODE} APP_CPPFLAGS := -std=c++11 APP_SHORT_COMMANDS := true +ifdef OLD_PLAT +APP_PLATFORM := android-9 +else +APP_PLATFORM := android-21 +endif diff --git a/native/jni/external/Android.mk b/native/jni/external/Android.mk index daefac0cd..ccd03f54e 100644 --- a/native/jni/external/Android.mk +++ b/native/jni/external/Android.mk @@ -175,7 +175,7 @@ LOCAL_SRC_FILES := \ xz/src/liblzma/simple/simple_encoder.c \ xz/src/liblzma/simple/sparc.c \ xz/src/liblzma/simple/x86.c -LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=c99 +LOCAL_CFLAGS += -DHAVE_CONFIG_H -Wno-implicit-function-declaration include $(BUILD_STATIC_LIBRARY) # libsepol.a diff --git a/native/jni/external/busybox b/native/jni/external/busybox index 4f5bf4ad8..869ebbfa9 160000 --- a/native/jni/external/busybox +++ b/native/jni/external/busybox @@ -1 +1 @@ -Subproject commit 4f5bf4ad8361c46441db19bd61605d0de324f19e +Subproject commit 869ebbfa97d9b47b2707adb10a01d1bfacd52191