diff --git a/build.py b/build.py index 1f1f9605c..bc174d711 100755 --- a/build.py +++ b/build.py @@ -64,7 +64,7 @@ cpu_count = multiprocessing.cpu_count() archs = ['armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'] triples = ['armv7a-linux-androideabi', 'i686-linux-android', 'aarch64-linux-android', 'x86_64-linux-android'] default_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy', 'busybox'] -support_targets = default_targets + ['resetprop', 'test'] +support_targets = default_targets + ['resetprop'] rust_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy'] sdk_path = os.environ['ANDROID_SDK_ROOT'] @@ -220,6 +220,8 @@ def run_ndk_build(flags): def run_cargo_build(args): os.chdir(op.join('native', 'src')) targets = set(args.target) & set(rust_targets) + if 'resetprop' in args.target: + targets.add('magisk') env = os.environ.copy() env['CARGO_BUILD_RUSTC'] = op.join(rust_bin, 'rustc' + EXE_EXT) diff --git a/native/src/Android-rs.mk b/native/src/Android-rs.mk index c705e46c0..2a0027335 100644 --- a/native/src/Android-rs.mk +++ b/native/src/Android-rs.mk @@ -4,30 +4,34 @@ LOCAL_PATH := $(call my-dir) # Rust compilation outputs ########################### -ifdef B_MAGISK +LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagisk-rs.a +ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH))) include $(CLEAR_VARS) LOCAL_MODULE := magisk-rs -LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagisk-rs.a +LOCAL_SRC_FILES := $(LIBRARY_PATH) include $(PREBUILT_STATIC_LIBRARY) endif -ifdef B_BOOT +LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagiskboot-rs.a +ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH))) include $(CLEAR_VARS) LOCAL_MODULE := boot-rs -LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagiskboot-rs.a +LOCAL_SRC_FILES := $(LIBRARY_PATH) include $(PREBUILT_STATIC_LIBRARY) endif -ifdef B_INIT +LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagiskinit-rs.a +ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH))) include $(CLEAR_VARS) LOCAL_MODULE := init-rs -LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagiskinit-rs.a +LOCAL_SRC_FILES := $(LIBRARY_PATH) include $(PREBUILT_STATIC_LIBRARY) endif -ifdef B_POLICY +LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagiskpolicy-rs.a +ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH))) include $(CLEAR_VARS) LOCAL_MODULE := policy-rs -LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagiskpolicy-rs.a +LOCAL_SRC_FILES := $(LIBRARY_PATH) include $(PREBUILT_STATIC_LIBRARY) endif diff --git a/native/src/Android.mk b/native/src/Android.mk index eb8092306..d3ca742ff 100644 --- a/native/src/Android.mk +++ b/native/src/Android.mk @@ -150,29 +150,14 @@ LOCAL_STATIC_LIBRARIES := \ LOCAL_SRC_FILES := \ core/applet_stub.cpp \ - resetprop/persist_properties.cpp \ resetprop/resetprop.cpp \ + resetprop/persist.cpp \ LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=resetprop_main include $(BUILD_EXECUTABLE) endif -ifdef B_TEST -ifneq (,$(wildcard src/test.cpp)) - -include $(CLEAR_VARS) -LOCAL_MODULE := test -LOCAL_STATIC_LIBRARIES := \ - libbase \ - libphmap - -LOCAL_SRC_FILES := test.cpp -include $(BUILD_EXECUTABLE) - -endif -endif - ######################## # Libraries ######################## diff --git a/native/src/core/applet_stub.cpp b/native/src/core/applet_stub.cpp index 02556c8bd..1c2c7b936 100644 --- a/native/src/core/applet_stub.cpp +++ b/native/src/core/applet_stub.cpp @@ -1,10 +1,15 @@ #include #include +#include #include int main(int argc, char *argv[]) { - umask(0); + if (argc < 1) + return 1; + enable_selinux(); cmdline_logging(); + init_argv0(argc, argv); + umask(0); return APPLET_STUB_MAIN(argc, argv); } diff --git a/native/src/resetprop/resetprop.cpp b/native/src/resetprop/resetprop.cpp index 13ec5ebbf..1697f5805 100644 --- a/native/src/resetprop/resetprop.cpp +++ b/native/src/resetprop/resetprop.cpp @@ -6,6 +6,8 @@ #include #include +#undef __INTRODUCED_IN +#define __INTRODUCED_IN(...) #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ #include <_system_properties.h>