diff --git a/README.MD b/README.MD index b2e03cf02..0cbcde049 100644 --- a/README.MD +++ b/README.MD @@ -10,15 +10,15 @@ 2. Python 3.5+: run `build.py` script 3. Java Development Kit (JDK) 8: Compile Magisk Manager and sign zips 4. Latest Android SDK: `ANDROID_HOME` environment variable should point to the Android SDK folder -5. Latest Android NDK: Install NDK via `sdkmanager`, or via Android SDK Manager in Android Studio +5. Android NDK: Install NDK along with SDK (`$ANDROID_HOME/ndk-bundle`), or specify custom path `ANDROID_NDK` 6. (Windows Only) Colorama: Install Colorama with `pip install colorama`, used for ANSI color codes 7. (Unix only) C compiler: Build `zipadjust`. Windows users can use the pre-built `zipadjust.exe` ### Instructions and Notes - -1. The easiest way to setup a working environment is to open Magisk Manager with Android Studio. The IDE will download required components and construct the environment for you. Don't forget to set `ANDROID_HOME` environment variable to the SDK path. -2. Run the script with `-h` as an argument to see the built-in help message. The `-h` option also works for each supported actions, e.g. `./build.py binary -h` -3. By default, the script will build binaries and Magisk Manager in debug mode. If you want to build Magisk Manager in release mode (through the flag `--release`), you will need to place your Java Keystore file at `release_signature.jks` to sign Magisk Manager's APK. For more information, check out [Google's Official Documentation](https://developer.android.com/studio/publish/app-signing.html#signing-manually). +1. Magisk can be built with the latest NDK (r16 as of writing), however official released binaries will be built with NDK r10e due to ELF incompatibilities with the binaries built from newer NDKs. +2. The easiest way to setup a working environment is to open Magisk Manager with Android Studio. The IDE will download required components and construct the environment for you. Don't forget to set `ANDROID_HOME` environment variable to the SDK path. +3. Run the script with `-h` as an argument to see the built-in help message. The `-h` option also works for each supported actions, e.g. `./build.py binary -h` +4. By default, the script will build binaries and Magisk Manager in debug mode. If you want to build Magisk Manager in release mode (through the flag `--release`), you will need to place your Java Keystore file at `release_signature.jks` to sign Magisk Manager's APK. For more information, check out [Google's Official Documentation](https://developer.android.com/studio/publish/app-signing.html#signing-manually). ## License diff --git a/build.py b/build.py index eb8dc0ebc..cc82e1bd1 100755 --- a/build.py +++ b/build.py @@ -87,9 +87,13 @@ def build_binary(args): os.utime(os.path.join('jni', 'Android.mk')) debug_flag = '' if args.release else '-DMAGISK_DEBUG' - cflag = 'APP_CFLAGS=\"-DMAGISK_VERSION=\\\"{}\\\" -DMAGISK_VER_CODE={} {}\"'.format(args.versionString, args.versionCode, debug_flag) + cflag = 'MAGISK_FLAGS=\"-DMAGISK_VERSION=\\\"{}\\\" -DMAGISK_VER_CODE={} {}\"'.format(args.versionString, args.versionCode, debug_flag) + + if 'ANDROID_NDK' in os.environ: + ndk_build = os.path.join(os.environ['ANDROID_NDK'], 'ndk-build') + else: + ndk_build = os.path.join(os.environ['ANDROID_HOME'], 'ndk-bundle', 'ndk-build') - ndk_build = os.path.join(os.environ['ANDROID_HOME'], 'ndk-bundle', 'ndk-build') # Prebuild proc = subprocess.run('{} PRECOMPILE=true {} -j{}'.format(ndk_build, cflag, multiprocessing.cpu_count()), shell=True) if proc.returncode != 0: diff --git a/jni/Android.mk b/jni/Android.mk index feadacf4d..c9dadda23 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -49,8 +49,7 @@ LOCAL_SRC_FILES := \ su/su_daemon.c \ su/su_socket.c -LOCAL_CFLAGS := -Wno-implicit-exception-spec-mismatch -DIS_DAEMON -LOCAL_CPPFLAGS := -std=c++11 +LOCAL_CFLAGS := -DIS_DAEMON LOCAL_LDLIBS := -llog include $(BUILD_EXECUTABLE) diff --git a/jni/Application.mk b/jni/Application.mk index 29ed9d379..b28b7ef04 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -1,2 +1,4 @@ APP_ABI := x86 x86_64 armeabi-v7a arm64-v8a APP_PLATFORM := android-21 +APP_CFLAGS := $(MAGISK_FLAGS) -std=gnu99 +APP_CPPFLAGS := -std=c++11 diff --git a/jni/external/busybox b/jni/external/busybox index 90c9c4fd9..e3a1a4d91 160000 --- a/jni/external/busybox +++ b/jni/external/busybox @@ -1 +1 @@ -Subproject commit 90c9c4fd96f77e26e3550df310adbe39369d8057 +Subproject commit e3a1a4d91f5606833a83a0cba13b13ef6635ef5e diff --git a/jni/include/utils.h b/jni/include/utils.h index 176a27271..62368539b 100644 --- a/jni/include/utils.h +++ b/jni/include/utils.h @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/jni/magiskpolicy b/jni/magiskpolicy index b7e717ee8..e5b6121d1 160000 --- a/jni/magiskpolicy +++ b/jni/magiskpolicy @@ -1 +1 @@ -Subproject commit b7e717ee8c49d3f2ae153b8ea8de6c932032c20a +Subproject commit e5b6121d176ee75cbfce58c471cd5d9dc1eb7caa diff --git a/jni/resetprop/system_properties.cpp b/jni/resetprop/system_properties.cpp index f629bab60..c439c48a3 100644 --- a/jni/resetprop/system_properties.cpp +++ b/jni/resetprop/system_properties.cpp @@ -30,11 +30,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -48,6 +50,9 @@ #include #include #include + +#undef XATTR_CREATE +#undef XATTR_REPLACE #include #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ @@ -1319,7 +1324,7 @@ int __system_property_get2(const char* name, char* value) { static constexpr uint32_t kProtocolVersion1 = 1; static constexpr uint32_t kProtocolVersion2 = 2; // current -static atomic_uint_least32_t g_propservice_protocol_version = 0; +static uint32_t g_propservice_protocol_version = 0; static void detect_protocol_version() { char value[PROP_VALUE_MAX]; @@ -1486,7 +1491,7 @@ int __system_property_add2(const char* name, unsigned int namelen, const char* v uint32_t __system_property_serial2(const prop_info* pi) { uint32_t serial = load_const_atomic(&pi->serial, memory_order_acquire); while (SERIAL_DIRTY(serial)) { - __futex_wait(const_cast<_Atomic(uint_least32_t)*>(&pi->serial), serial, nullptr); + __futex_wait(const_cast(&pi->serial), serial, nullptr); serial = load_const_atomic(&pi->serial, memory_order_acquire); } return serial; diff --git a/jni/resetprop/system_properties.h b/jni/resetprop/system_properties.h index 9108ddb94..fb1db0630 100644 --- a/jni/resetprop/system_properties.h +++ b/jni/resetprop/system_properties.h @@ -43,7 +43,7 @@ typedef struct prop_info prop_info; /* * Sets system property `key` to `value`, creating the system property if it doesn't already exist. */ -int __system_property_set2(const char* key, const char* value) __INTRODUCED_IN(12); +int __system_property_set2(const char* key, const char* value); /* * Returns a `prop_info` corresponding system property `name`, or nullptr if it doesn't exist. @@ -58,7 +58,7 @@ const prop_info* __system_property_find2(const char* name); */ void __system_property_read_callback2(const prop_info *pi, void (*callback)(void* cookie, const char *name, const char *value, uint32_t serial), - void* cookie) __INTRODUCED_IN(26); + void* cookie); /* * Passes a `prop_info` for each system property to the provided @@ -66,8 +66,7 @@ void __system_property_read_callback2(const prop_info *pi, * * This method is for inspecting and debugging the property system, and not generally useful. */ -int __system_property_foreach2(void (*propfn)(const prop_info* pi, void* cookie), void* cookie) - __INTRODUCED_IN(19); +int __system_property_foreach2(void (*propfn)(const prop_info* pi, void* cookie), void* cookie); /* * Waits for the specific system property identified by `pi` to be updated @@ -85,8 +84,7 @@ struct timespec; bool __system_property_wait2(const prop_info* pi, uint32_t old_serial, uint32_t* new_serial_ptr, - const struct timespec* relative_timeout) - __INTRODUCED_IN(26); + const struct timespec* relative_timeout); /* Deprecated. In Android O and above, there's no limit on property name length. */ #define PROP_NAME_MAX 32 diff --git a/jni/su b/jni/su index 4335c588f..a9d966dc7 160000 --- a/jni/su +++ b/jni/su @@ -1 +1 @@ -Subproject commit 4335c588fec05f0abefbd930ae39ea96e3b7e6fe +Subproject commit a9d966dc7ab97006445315ef3c13f2d2e020fffc