From 41446ec9badaeebf9f46548866eb87b0c6e43278 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 27 Sep 2018 03:30:16 -0400 Subject: [PATCH] Separate libutils and libsystemproperties --- build.py | 2 +- native/jni/Android.mk | 40 ++++++++----------- .../Android.mk | 0 .../context_node.cpp | 0 .../contexts_serialized.cpp | 0 .../contexts_split.cpp | 0 .../include/async_safe/log.h | 0 .../include/hacks.h | 0 .../include/private/ErrnoRestorer.h | 0 .../include/private/bionic_futex.h | 0 .../include/private/bionic_lock.h | 0 .../include/private/bionic_macros.h | 0 .../property_info_parser.h | 0 .../include/system_properties/context_node.h | 0 .../include/system_properties/contexts.h | 0 .../system_properties/contexts_pre_split.h | 0 .../system_properties/contexts_serialized.h | 0 .../system_properties/contexts_split.h | 0 .../include/system_properties/prop_area.h | 0 .../include/system_properties/prop_info.h | 0 .../system_properties/system_properties.h | 0 .../prop_area.cpp | 0 .../prop_info.cpp | 0 .../property_info_parser.cpp | 0 .../system_properties.cpp | 0 native/jni/utils/Android.mk | 15 +++++++ native/jni/{ => utils}/include/list.h | 0 native/jni/{ => utils}/include/logging.h | 0 native/jni/{ => utils}/include/selinux.h | 0 native/jni/{ => utils}/include/utils.h | 0 native/jni/{ => utils}/include/vector.h | 0 31 files changed, 32 insertions(+), 25 deletions(-) rename native/jni/{resetprop/libsystemproperties => systemproperties}/Android.mk (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/context_node.cpp (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/contexts_serialized.cpp (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/contexts_split.cpp (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/async_safe/log.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/hacks.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/private/ErrnoRestorer.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/private/bionic_futex.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/private/bionic_lock.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/private/bionic_macros.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/property_info_parser/property_info_parser.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/system_properties/context_node.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/system_properties/contexts.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/system_properties/contexts_pre_split.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/system_properties/contexts_serialized.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/system_properties/contexts_split.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/system_properties/prop_area.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/system_properties/prop_info.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/include/system_properties/system_properties.h (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/prop_area.cpp (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/prop_info.cpp (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/property_info_parser.cpp (100%) rename native/jni/{resetprop/libsystemproperties => systemproperties}/system_properties.cpp (100%) create mode 100644 native/jni/utils/Android.mk rename native/jni/{ => utils}/include/list.h (100%) rename native/jni/{ => utils}/include/logging.h (100%) rename native/jni/{ => utils}/include/selinux.h (100%) rename native/jni/{ => utils}/include/utils.h (100%) rename native/jni/{ => utils}/include/vector.h (100%) diff --git a/build.py b/build.py index b106f0cb8..e837dd5c8 100755 --- a/build.py +++ b/build.py @@ -171,7 +171,7 @@ def build_binary(args): header('* Building binaries: ' + ' '.join(args.target)) # Force update logging.h timestamp to trigger recompilation for the flags to make a difference - os.utime(os.path.join('native', 'jni', 'include', 'logging.h')) + os.utime(os.path.join('native', 'jni', 'utils', 'include', 'logging.h')) # Basic flags base_flags = 'MAGISK_VERSION=\"{}\" MAGISK_VER_CODE={} MAGISK_DEBUG={}'.format(config['version'], config['versionCode'], diff --git a/native/jni/Android.mk b/native/jni/Android.mk index 11dd5a60e..0c5a962e5 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -10,15 +10,8 @@ LIBLZ4 := $(EXT_PATH)/lz4/lib LIBBZ2 := $(EXT_PATH)/bzip2 LIBFDT := $(EXT_PATH)/dtc/libfdt LIBNANOPB := $(EXT_PATH)/nanopb -LIBSYSTEMPROPERTIES := jni/resetprop/libsystemproperties/include -COMMON_UTILS := \ - utils/file.c \ - utils/list.c \ - utils/misc.c \ - utils/vector.c \ - utils/selinux.c \ - utils/logging.c \ - utils/xwrap.c +LIBSYSTEMPROPERTIES := jni/systemproperties/include +LIBUTILS := jni/utils/include ######################## # Binaries @@ -30,12 +23,13 @@ ifdef B_MAGISK include $(CLEAR_VARS) LOCAL_MODULE := magisk LOCAL_SHARED_LIBRARIES := libsqlite -LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties +LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils LOCAL_C_INCLUDES := \ jni/include \ $(EXT_PATH)/include \ $(LIBNANOPB) \ - $(LIBSYSTEMPROPERTIES) + $(LIBSYSTEMPROPERTIES) \ + $(LIBUTILS) LOCAL_SRC_FILES := \ core/magisk.c \ @@ -55,10 +49,8 @@ LOCAL_SRC_FILES := \ su/connect.c \ su/pts.c \ su/su_daemon.c \ - utils/img.c \ - $(COMMON_UTILS) + utils/img.c -LOCAL_CFLAGS := -DIS_DAEMON LOCAL_LDLIBS := -llog include $(BUILD_EXECUTABLE) @@ -69,22 +61,22 @@ ifdef B_INIT # magiskinit include $(CLEAR_VARS) LOCAL_MODULE := magiskinit -LOCAL_STATIC_LIBRARIES := libsepol libxz +LOCAL_STATIC_LIBRARIES := libsepol libxz libutils LOCAL_C_INCLUDES := \ jni/include \ jni/magiskpolicy \ $(EXT_PATH)/include \ out \ out/$(TARGET_ARCH_ABI) \ - $(LIBSEPOL) + $(LIBSEPOL) \ + $(LIBUTILS) LOCAL_SRC_FILES := \ core/magiskinit.c \ magiskpolicy/api.c \ magiskpolicy/magiskpolicy.c \ magiskpolicy/rules.c \ - magiskpolicy/sepolicy.c \ - $(COMMON_UTILS) + magiskpolicy/sepolicy.c LOCAL_LDFLAGS := -static include $(BUILD_EXECUTABLE) @@ -96,14 +88,15 @@ ifdef B_BOOT # magiskboot include $(CLEAR_VARS) LOCAL_MODULE := magiskboot -LOCAL_STATIC_LIBRARIES := libmincrypt liblzma liblz4 libbz2 libfdt +LOCAL_STATIC_LIBRARIES := libmincrypt liblzma liblz4 libbz2 libfdt libutils LOCAL_C_INCLUDES := \ jni/include \ $(EXT_PATH)/include \ $(LIBLZMA) \ $(LIBLZ4) \ $(LIBBZ2) \ - $(LIBFDT) + $(LIBFDT) \ + $(LIBUTILS) LOCAL_SRC_FILES := \ magiskboot/cpio.c \ @@ -114,10 +107,8 @@ LOCAL_SRC_FILES := \ magiskboot/format.c \ magiskboot/dtb.c \ magiskboot/ramdisk.c \ - magiskboot/pattern.c \ - $(COMMON_UTILS) + magiskboot/pattern.c -LOCAL_CFLAGS := -DXWRAP_EXIT LOCAL_LDLIBS := -lz include $(BUILD_EXECUTABLE) @@ -146,5 +137,6 @@ endif ######################## # Libraries ######################## +include jni/utils/Android.mk +include jni/systemproperties/Android.mk include jni/external/Android.mk -include jni/resetprop/libsystemproperties/Android.mk diff --git a/native/jni/resetprop/libsystemproperties/Android.mk b/native/jni/systemproperties/Android.mk similarity index 100% rename from native/jni/resetprop/libsystemproperties/Android.mk rename to native/jni/systemproperties/Android.mk diff --git a/native/jni/resetprop/libsystemproperties/context_node.cpp b/native/jni/systemproperties/context_node.cpp similarity index 100% rename from native/jni/resetprop/libsystemproperties/context_node.cpp rename to native/jni/systemproperties/context_node.cpp diff --git a/native/jni/resetprop/libsystemproperties/contexts_serialized.cpp b/native/jni/systemproperties/contexts_serialized.cpp similarity index 100% rename from native/jni/resetprop/libsystemproperties/contexts_serialized.cpp rename to native/jni/systemproperties/contexts_serialized.cpp diff --git a/native/jni/resetprop/libsystemproperties/contexts_split.cpp b/native/jni/systemproperties/contexts_split.cpp similarity index 100% rename from native/jni/resetprop/libsystemproperties/contexts_split.cpp rename to native/jni/systemproperties/contexts_split.cpp diff --git a/native/jni/resetprop/libsystemproperties/include/async_safe/log.h b/native/jni/systemproperties/include/async_safe/log.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/async_safe/log.h rename to native/jni/systemproperties/include/async_safe/log.h diff --git a/native/jni/resetprop/libsystemproperties/include/hacks.h b/native/jni/systemproperties/include/hacks.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/hacks.h rename to native/jni/systemproperties/include/hacks.h diff --git a/native/jni/resetprop/libsystemproperties/include/private/ErrnoRestorer.h b/native/jni/systemproperties/include/private/ErrnoRestorer.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/private/ErrnoRestorer.h rename to native/jni/systemproperties/include/private/ErrnoRestorer.h diff --git a/native/jni/resetprop/libsystemproperties/include/private/bionic_futex.h b/native/jni/systemproperties/include/private/bionic_futex.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/private/bionic_futex.h rename to native/jni/systemproperties/include/private/bionic_futex.h diff --git a/native/jni/resetprop/libsystemproperties/include/private/bionic_lock.h b/native/jni/systemproperties/include/private/bionic_lock.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/private/bionic_lock.h rename to native/jni/systemproperties/include/private/bionic_lock.h diff --git a/native/jni/resetprop/libsystemproperties/include/private/bionic_macros.h b/native/jni/systemproperties/include/private/bionic_macros.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/private/bionic_macros.h rename to native/jni/systemproperties/include/private/bionic_macros.h diff --git a/native/jni/resetprop/libsystemproperties/include/property_info_parser/property_info_parser.h b/native/jni/systemproperties/include/property_info_parser/property_info_parser.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/property_info_parser/property_info_parser.h rename to native/jni/systemproperties/include/property_info_parser/property_info_parser.h diff --git a/native/jni/resetprop/libsystemproperties/include/system_properties/context_node.h b/native/jni/systemproperties/include/system_properties/context_node.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/system_properties/context_node.h rename to native/jni/systemproperties/include/system_properties/context_node.h diff --git a/native/jni/resetprop/libsystemproperties/include/system_properties/contexts.h b/native/jni/systemproperties/include/system_properties/contexts.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/system_properties/contexts.h rename to native/jni/systemproperties/include/system_properties/contexts.h diff --git a/native/jni/resetprop/libsystemproperties/include/system_properties/contexts_pre_split.h b/native/jni/systemproperties/include/system_properties/contexts_pre_split.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/system_properties/contexts_pre_split.h rename to native/jni/systemproperties/include/system_properties/contexts_pre_split.h diff --git a/native/jni/resetprop/libsystemproperties/include/system_properties/contexts_serialized.h b/native/jni/systemproperties/include/system_properties/contexts_serialized.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/system_properties/contexts_serialized.h rename to native/jni/systemproperties/include/system_properties/contexts_serialized.h diff --git a/native/jni/resetprop/libsystemproperties/include/system_properties/contexts_split.h b/native/jni/systemproperties/include/system_properties/contexts_split.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/system_properties/contexts_split.h rename to native/jni/systemproperties/include/system_properties/contexts_split.h diff --git a/native/jni/resetprop/libsystemproperties/include/system_properties/prop_area.h b/native/jni/systemproperties/include/system_properties/prop_area.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/system_properties/prop_area.h rename to native/jni/systemproperties/include/system_properties/prop_area.h diff --git a/native/jni/resetprop/libsystemproperties/include/system_properties/prop_info.h b/native/jni/systemproperties/include/system_properties/prop_info.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/system_properties/prop_info.h rename to native/jni/systemproperties/include/system_properties/prop_info.h diff --git a/native/jni/resetprop/libsystemproperties/include/system_properties/system_properties.h b/native/jni/systemproperties/include/system_properties/system_properties.h similarity index 100% rename from native/jni/resetprop/libsystemproperties/include/system_properties/system_properties.h rename to native/jni/systemproperties/include/system_properties/system_properties.h diff --git a/native/jni/resetprop/libsystemproperties/prop_area.cpp b/native/jni/systemproperties/prop_area.cpp similarity index 100% rename from native/jni/resetprop/libsystemproperties/prop_area.cpp rename to native/jni/systemproperties/prop_area.cpp diff --git a/native/jni/resetprop/libsystemproperties/prop_info.cpp b/native/jni/systemproperties/prop_info.cpp similarity index 100% rename from native/jni/resetprop/libsystemproperties/prop_info.cpp rename to native/jni/systemproperties/prop_info.cpp diff --git a/native/jni/resetprop/libsystemproperties/property_info_parser.cpp b/native/jni/systemproperties/property_info_parser.cpp similarity index 100% rename from native/jni/resetprop/libsystemproperties/property_info_parser.cpp rename to native/jni/systemproperties/property_info_parser.cpp diff --git a/native/jni/resetprop/libsystemproperties/system_properties.cpp b/native/jni/systemproperties/system_properties.cpp similarity index 100% rename from native/jni/resetprop/libsystemproperties/system_properties.cpp rename to native/jni/systemproperties/system_properties.cpp diff --git a/native/jni/utils/Android.mk b/native/jni/utils/Android.mk new file mode 100644 index 000000000..a243ff984 --- /dev/null +++ b/native/jni/utils/Android.mk @@ -0,0 +1,15 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE:= libutils +LOCAL_C_INCLUDES := jni/include $(LIBUTILS) +LOCAL_SRC_FILES := \ + file.c \ + list.c \ + misc.c \ + vector.c \ + selinux.c \ + logging.c \ + xwrap.c + +include $(BUILD_STATIC_LIBRARY) diff --git a/native/jni/include/list.h b/native/jni/utils/include/list.h similarity index 100% rename from native/jni/include/list.h rename to native/jni/utils/include/list.h diff --git a/native/jni/include/logging.h b/native/jni/utils/include/logging.h similarity index 100% rename from native/jni/include/logging.h rename to native/jni/utils/include/logging.h diff --git a/native/jni/include/selinux.h b/native/jni/utils/include/selinux.h similarity index 100% rename from native/jni/include/selinux.h rename to native/jni/utils/include/selinux.h diff --git a/native/jni/include/utils.h b/native/jni/utils/include/utils.h similarity index 100% rename from native/jni/include/utils.h rename to native/jni/utils/include/utils.h diff --git a/native/jni/include/vector.h b/native/jni/utils/include/vector.h similarity index 100% rename from native/jni/include/vector.h rename to native/jni/utils/include/vector.h