Add support to build with NDK r10e

This commit is contained in:
topjohnwu 2017-11-23 23:55:33 +08:00
parent bc592c1d13
commit 8c6bb383b7
10 changed files with 29 additions and 20 deletions

View File

@ -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

View File

@ -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:

View File

@ -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)

View File

@ -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

@ -1 +1 @@
Subproject commit 90c9c4fd96f77e26e3550df310adbe39369d8057
Subproject commit e3a1a4d91f5606833a83a0cba13b13ef6635ef5e

View File

@ -6,6 +6,7 @@
#include <stdio.h>
#include <dirent.h>
#include <pthread.h>
#include <sys/socket.h>
#include <sys/stat.h>

@ -1 +1 @@
Subproject commit b7e717ee8c49d3f2ae153b8ea8de6c932032c20a
Subproject commit e5b6121d176ee75cbfce58c471cd5d9dc1eb7caa

View File

@ -30,11 +30,13 @@
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <stdio.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <new>
@ -48,6 +50,9 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>
#undef XATTR_CREATE
#undef XATTR_REPLACE
#include <sys/xattr.h>
#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<atomic_uint_least32_t*>(&pi->serial), serial, nullptr);
serial = load_const_atomic(&pi->serial, memory_order_acquire);
}
return serial;

View File

@ -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

2
jni/su

@ -1 +1 @@
Subproject commit 4335c588fec05f0abefbd930ae39ea96e3b7e6fe
Subproject commit a9d966dc7ab97006445315ef3c13f2d2e020fffc