Separate libc.a hacks into its own component

This commit is contained in:
topjohnwu 2022-01-31 02:09:08 -08:00
parent 9fa096c6f4
commit 7f65f7d3ca
4 changed files with 50 additions and 24 deletions

View File

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

View File

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

View File

@ -4,7 +4,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.hpp"
#include <logging.hpp>
#undef _FORTIFY_SOURCE