From b13a35057ab836fe4282b0b4b902cba131a44a3d Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 21 Jan 2020 00:48:52 +0800 Subject: [PATCH] Support building standalone resetprop --- build.py | 5 ++- native/jni/Android.mk | 74 ++++++++++++++++++++++++++++--------------- 2 files changed, 53 insertions(+), 26 deletions(-) diff --git a/build.py b/build.py index 595eb2e81..18a24c24a 100755 --- a/build.py +++ b/build.py @@ -56,7 +56,7 @@ cpu_count = multiprocessing.cpu_count() gradlew = os.path.join('.', 'gradlew' + ('.bat' if is_windows else '')) archs = ['armeabi-v7a', 'x86'] arch64 = ['arm64-v8a', 'x86_64'] -support_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy', 'busybox', 'test'] +support_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy', 'resetprop', 'busybox', 'test'] default_targets = ['magisk', 'magiskinit', 'magiskboot', 'busybox'] build_tools = os.path.join(os.environ['ANDROID_HOME'], 'build-tools', '29.0.2') @@ -286,6 +286,9 @@ def build_binary(args): if 'magiskpolicy' in args.target: run_ndk_build('B_POLICY=1') + if 'resetprop' in args.target: + run_ndk_build('B_PROP=1') + if 'magiskboot' in args.target: run_ndk_build('B_BOOT=1') diff --git a/native/jni/Android.mk b/native/jni/Android.mk index d61c06a85..06ee01240 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -57,31 +57,6 @@ include $(BUILD_EXECUTABLE) endif -ifdef B_POLICY - -include $(CLEAR_VARS) -LOCAL_MODULE := magiskpolicy -LOCAL_STATIC_LIBRARIES := libsepol libutils -LOCAL_C_INCLUDES := \ - jni/include \ - $(LIBSEPOL) \ - $(LIBUTILS) - -LOCAL_SRC_FILES := \ - core/applet_stub.cpp \ - magiskpolicy/api.cpp \ - magiskpolicy/magiskpolicy.cpp \ - magiskpolicy/rules.cpp \ - magiskpolicy/policydb.cpp \ - magiskpolicy/statement.cpp \ - magiskpolicy/sepolicy.c - -LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=magiskpolicy_main -LOCAL_LDFLAGS := -static -include $(BUILD_EXECUTABLE) - -endif - include $(CLEAR_VARS) ifdef B_INIT @@ -152,6 +127,55 @@ include $(BUILD_EXECUTABLE) endif +ifdef B_POLICY + +include $(CLEAR_VARS) +LOCAL_MODULE := magiskpolicy +LOCAL_STATIC_LIBRARIES := libsepol libutils +LOCAL_C_INCLUDES := \ + jni/include \ + $(LIBSEPOL) \ + $(LIBUTILS) + +LOCAL_SRC_FILES := \ + core/applet_stub.cpp \ + magiskpolicy/api.cpp \ + magiskpolicy/magiskpolicy.cpp \ + magiskpolicy/rules.cpp \ + magiskpolicy/policydb.cpp \ + magiskpolicy/statement.cpp \ + magiskpolicy/sepolicy.c + +LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=magiskpolicy_main +LOCAL_LDFLAGS := -static +include $(BUILD_EXECUTABLE) + +endif + +ifdef B_PROP + +include $(CLEAR_VARS) +LOCAL_MODULE := resetprop +LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils +LOCAL_C_INCLUDES := \ + jni/include \ + $(LIBNANOPB) \ + $(LIBSYSTEMPROPERTIES) \ + $(LIBUTILS) + +LOCAL_SRC_FILES := \ + core/applet_stub.cpp \ + resetprop/persist_properties.cpp \ + resetprop/resetprop.cpp \ + resetprop/system_property_api.cpp \ + resetprop/system_property_set.cpp + +LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=resetprop_main +LOCAL_LDFLAGS := -static +include $(BUILD_EXECUTABLE) + +endif + ifdef B_TEST include $(CLEAR_VARS)