diff --git a/native/jni/Android.mk b/native/jni/Android.mk index fe4867c0c..ede6ca28b 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -8,7 +8,12 @@ ifdef B_MAGISK include $(CLEAR_VARS) LOCAL_MODULE := magisk -LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils-shared libphmap libxhook +LOCAL_STATIC_LIBRARIES := \ + libutils \ + libnanopb \ + libsystemproperties \ + libphmap \ + libxhook LOCAL_SRC_FILES := \ core/applets.cpp \ @@ -47,7 +52,10 @@ ifdef B_INIT include $(CLEAR_VARS) LOCAL_MODULE := magiskinit -LOCAL_STATIC_LIBRARIES := libsepol libxz libutils +LOCAL_STATIC_LIBRARIES := \ + libutilx \ + libsepol \ + libxz LOCAL_SRC_FILES := \ init/init.cpp \ @@ -72,7 +80,15 @@ ifdef B_BOOT include $(CLEAR_VARS) LOCAL_MODULE := magiskboot -LOCAL_STATIC_LIBRARIES := libmincrypt liblzma liblz4 libbz2 libfdt libutils libz libzopfli +LOCAL_STATIC_LIBRARIES := \ + libutilx \ + libmincrypt \ + liblzma \ + liblz4 \ + libbz2 \ + libfdt \ + libz \ + libzopfli LOCAL_SRC_FILES := \ magiskboot/main.cpp \ @@ -94,7 +110,9 @@ ifdef B_POLICY include $(CLEAR_VARS) LOCAL_MODULE := magiskpolicy -LOCAL_STATIC_LIBRARIES := libsepol libutils +LOCAL_STATIC_LIBRARIES := \ + libutilx \ + libsepol LOCAL_SRC_FILES := \ core/applet_stub.cpp \ @@ -114,7 +132,10 @@ ifdef B_PROP include $(CLEAR_VARS) LOCAL_MODULE := resetprop -LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils +LOCAL_STATIC_LIBRARIES := \ + libutilx \ + libnanopb \ + libsystemproperties LOCAL_SRC_FILES := \ core/applet_stub.cpp \ @@ -132,7 +153,10 @@ ifneq (,$(wildcard jni/test.cpp)) include $(CLEAR_VARS) LOCAL_MODULE := test -LOCAL_STATIC_LIBRARIES := libutils-shared libphmap +LOCAL_STATIC_LIBRARIES := \ + libutils \ + libphmap + LOCAL_SRC_FILES := test.cpp include $(BUILD_EXECUTABLE) diff --git a/native/jni/utils/Android.mk b/native/jni/utils/Android.mk index 1d5e083dc..3a0fc902e 100644 --- a/native/jni/utils/Android.mk +++ b/native/jni/utils/Android.mk @@ -1,15 +1,6 @@ LOCAL_PATH := $(call my-dir) -# All Magisk common code lives here - -UTILS_SRC_FILES := \ - new.cpp \ - files.cpp \ - misc.cpp \ - selinux.cpp \ - logging.cpp \ - xwrap.cpp \ - stream.cpp +# Magisk project-wide common code include $(CLEAR_VARS) LOCAL_MODULE:= libutils @@ -17,14 +8,25 @@ LOCAL_C_INCLUDES := jni/include $(LOCAL_PATH)/include out/generated LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) LOCAL_EXPORT_STATIC_LIBRARIES := libcxx LOCAL_STATIC_LIBRARIES := libcxx -LOCAL_SRC_FILES := $(UTILS_SRC_FILES) missing.cpp +LOCAL_SRC_FILES := \ + new.cpp \ + files.cpp \ + misc.cpp \ + selinux.cpp \ + logging.cpp \ + xwrap.cpp \ + stream.cpp include $(BUILD_STATIC_LIBRARY) +# libutils + "hacky" libc.a missing symbols + +# To build Magisk with vanilla NDK, simply +# remove compat.cpp from sources, or replace +# all usage of libutilx to libutils + include $(CLEAR_VARS) -LOCAL_MODULE:= libutils-shared -LOCAL_C_INCLUDES := jni/include $(LOCAL_PATH)/include out/generated -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) -LOCAL_EXPORT_STATIC_LIBRARIES := libcxx -LOCAL_STATIC_LIBRARIES := libcxx -LOCAL_SRC_FILES := $(UTILS_SRC_FILES) +LOCAL_MODULE:= libutilx +LOCAL_EXPORT_STATIC_LIBRARIES := libutils +LOCAL_STATIC_LIBRARIES := libutils +LOCAL_SRC_FILES := compat/compat.cpp include $(BUILD_STATIC_LIBRARY) diff --git a/native/jni/utils/missing.cpp b/native/jni/utils/compat/compat.cpp similarity index 100% rename from native/jni/utils/missing.cpp rename to native/jni/utils/compat/compat.cpp diff --git a/native/jni/utils/fortify.hpp b/native/jni/utils/compat/fortify.hpp similarity index 99% rename from native/jni/utils/fortify.hpp rename to native/jni/utils/compat/fortify.hpp index 7ef944d4d..839fd4929 100644 --- a/native/jni/utils/fortify.hpp +++ b/native/jni/utils/compat/fortify.hpp @@ -4,7 +4,7 @@ #include #include -#include "logging.hpp" +#include #undef _FORTIFY_SOURCE