From 4066e5bf1408133939d617426a7a3d3f6851a082 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 6 Apr 2020 22:45:08 -0700 Subject: [PATCH] Update Makefiles --- build.py | 4 +- native/jni/Android.mk | 52 ++-------- native/jni/external/Android.mk | 128 ++++++++++++++----------- native/jni/external/mincrypt | 2 +- native/jni/systemproperties/Android.mk | 3 +- native/jni/utils/Android.mk | 3 +- 6 files changed, 85 insertions(+), 107 deletions(-) diff --git a/build.py b/build.py index db2098475..139271184 100755 --- a/build.py +++ b/build.py @@ -253,9 +253,11 @@ def gen_update_binary(): def run_ndk_build(flags): - proc = system(f'{ndk_build} -C native {base_flags} {flags} -j{cpu_count}') + os.chdir('native') + proc = system(f'{ndk_build} {base_flags} {flags} -j{cpu_count}') if proc.returncode != 0: error('Build binary failed!') + os.chdir('..') collect_binary() diff --git a/native/jni/Android.mk b/native/jni/Android.mk index 8428b3ccf..89b65aaf3 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -1,21 +1,5 @@ LOCAL_PATH := $(call my-dir) -# Some handy paths -EXT_PATH := jni/external -SE_PATH := $(EXT_PATH)/selinux -LIBSELINUX := $(SE_PATH)/libselinux/include -LIBSEPOL := $(SE_PATH)/libsepol/include $(SE_PATH)/libsepol/cil/include -LIBLZMA := $(EXT_PATH)/xz/src/liblzma/api -LIBLZ4 := $(EXT_PATH)/lz4/lib -LIBBZ2 := $(EXT_PATH)/bzip2 -LIBFDT := $(EXT_PATH)/dtc/libfdt -LIBNANOPB := $(EXT_PATH)/nanopb -LIBSYSTEMPROPERTIES := jni/systemproperties/include -LIBUTILS := jni/utils/include -LIBMINCRYPT := $(EXT_PATH)/mincrypt/include -LIBXZ := $(EXT_PATH)/xz-embedded -LIBPCRE2 := $(EXT_PATH)/pcre/include - ######################## # Binaries ######################## @@ -25,11 +9,7 @@ ifdef B_MAGISK include $(CLEAR_VARS) LOCAL_MODULE := magisk LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils -LOCAL_C_INCLUDES := \ - jni/include \ - $(LIBNANOPB) \ - $(LIBSYSTEMPROPERTIES) \ - $(LIBUTILS) +LOCAL_C_INCLUDES := jni/include LOCAL_SRC_FILES := \ core/applets.cpp \ @@ -72,10 +52,7 @@ LOCAL_STATIC_LIBRARIES := libsepol libxz libutils LOCAL_C_INCLUDES := \ jni/include \ out \ - out/$(TARGET_ARCH_ABI) \ - $(LIBXZ) \ - $(LIBSEPOL) \ - $(LIBUTILS) + out/$(TARGET_ARCH_ABI) LOCAL_SRC_FILES := \ init/init.cpp \ @@ -100,15 +77,7 @@ ifdef B_BOOT include $(CLEAR_VARS) LOCAL_MODULE := magiskboot LOCAL_STATIC_LIBRARIES := libmincrypt liblzma liblz4 libbz2 libfdt libutils -LOCAL_C_INCLUDES := \ - jni/include \ - $(EXT_PATH)/include \ - $(LIBMINCRYPT) \ - $(LIBLZMA) \ - $(LIBLZ4) \ - $(LIBBZ2) \ - $(LIBFDT) \ - $(LIBUTILS) +LOCAL_C_INCLUDES := jni/include LOCAL_SRC_FILES := \ magiskboot/main.cpp \ @@ -131,10 +100,7 @@ ifdef B_POLICY include $(CLEAR_VARS) LOCAL_MODULE := magiskpolicy LOCAL_STATIC_LIBRARIES := libsepol libutils -LOCAL_C_INCLUDES := \ - jni/include \ - $(LIBSEPOL) \ - $(LIBUTILS) +LOCAL_C_INCLUDES := jni/include LOCAL_SRC_FILES := \ core/applet_stub.cpp \ @@ -156,11 +122,7 @@ ifdef B_PROP include $(CLEAR_VARS) LOCAL_MODULE := resetprop LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils -LOCAL_C_INCLUDES := \ - jni/include \ - $(LIBNANOPB) \ - $(LIBSYSTEMPROPERTIES) \ - $(LIBUTILS) +LOCAL_C_INCLUDES := jni/include LOCAL_SRC_FILES := \ core/applet_stub.cpp \ @@ -178,9 +140,7 @@ ifdef B_TEST include $(CLEAR_VARS) LOCAL_MODULE := test LOCAL_STATIC_LIBRARIES := libutils -LOCAL_C_INCLUDES := \ - jni/include \ - $(LIBUTILS) +LOCAL_C_INCLUDES := jni/include LOCAL_SRC_FILES := test.cpp LOCAL_LDFLAGS := -static include $(BUILD_EXECUTABLE) diff --git a/native/jni/external/Android.mk b/native/jni/external/Android.mk index 7f572f93b..87afe1a06 100644 --- a/native/jni/external/Android.mk +++ b/native/jni/external/Android.mk @@ -3,7 +3,8 @@ LOCAL_PATH := $(call my-dir) # libxz.a include $(CLEAR_VARS) LOCAL_MODULE:= libxz -LOCAL_C_INCLUDES := $(LIBXZ) +LOCAL_C_INCLUDES := $(LOCAL_PATH)/xz-embedded +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) LOCAL_SRC_FILES := \ xz-embedded/xz_crc32.c \ xz-embedded/xz_dec_lzma2.c \ @@ -13,7 +14,8 @@ include $(BUILD_STATIC_LIBRARY) # libnanopb.a include $(CLEAR_VARS) LOCAL_MODULE:= libnanopb -LOCAL_C_INCLUDES := $(LIBNANOPB) +LOCAL_C_INCLUDES := $(LOCAL_PATH)/nanopb +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) LOCAL_SRC_FILES := \ nanopb/pb_common.c \ nanopb/pb_decode.c \ @@ -23,7 +25,8 @@ include $(BUILD_STATIC_LIBRARY) # libfdt.a include $(CLEAR_VARS) LOCAL_MODULE:= libfdt -LOCAL_C_INCLUDES := $(LIBFDT) +LOCAL_C_INCLUDES := $(LOCAL_PATH)/dtc/libfdt +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) LOCAL_SRC_FILES := \ dtc/libfdt/fdt.c \ dtc/libfdt/fdt_addresses.c \ @@ -39,7 +42,8 @@ include $(BUILD_STATIC_LIBRARY) # liblz4.a include $(CLEAR_VARS) LOCAL_MODULE := liblz4 -LOCAL_C_INCLUDES += $(LIBLZ4) +LOCAL_C_INCLUDES := $(LOCAL_PATH)/lz4/lib +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) LOCAL_SRC_FILES := \ lz4/lib/lz4.c \ lz4/lib/lz4frame.c \ @@ -50,7 +54,8 @@ include $(BUILD_STATIC_LIBRARY) # libbz2.a include $(CLEAR_VARS) LOCAL_MODULE := libbz2 -LOCAL_C_INCLUDES += $(LIBBZ2) +LOCAL_C_INCLUDES := $(LOCAL_PATH)/bzip2 +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) LOCAL_SRC_FILES := \ bzip2/blocksort.c \ bzip2/huffman.c \ @@ -64,18 +69,19 @@ include $(BUILD_STATIC_LIBRARY) # liblzma.a include $(CLEAR_VARS) LOCAL_MODULE := liblzma -LOCAL_C_INCLUDES += \ - $(EXT_PATH)/xz_config \ - $(EXT_PATH)/xz/src/common \ - $(EXT_PATH)/xz/src/liblzma/api \ - $(EXT_PATH)/xz/src/liblzma/check \ - $(EXT_PATH)/xz/src/liblzma/common \ - $(EXT_PATH)/xz/src/liblzma/delta \ - $(EXT_PATH)/xz/src/liblzma/lz \ - $(EXT_PATH)/xz/src/liblzma/lzma \ - $(EXT_PATH)/xz/src/liblzma/rangecoder \ - $(EXT_PATH)/xz/src/liblzma/simple \ - $(EXT_PATH)/xz/src/liblzma +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/xz_config \ + $(LOCAL_PATH)/xz/src/common \ + $(LOCAL_PATH)/xz/src/liblzma/api \ + $(LOCAL_PATH)/xz/src/liblzma/check \ + $(LOCAL_PATH)/xz/src/liblzma/common \ + $(LOCAL_PATH)/xz/src/liblzma/delta \ + $(LOCAL_PATH)/xz/src/liblzma/lz \ + $(LOCAL_PATH)/xz/src/liblzma/lzma \ + $(LOCAL_PATH)/xz/src/liblzma/rangecoder \ + $(LOCAL_PATH)/xz/src/liblzma/simple \ + $(LOCAL_PATH)/xz/src/liblzma +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/xz/src/liblzma/api LOCAL_SRC_FILES := \ xz/src/common/tuklib_cpucores.c \ xz/src/common/tuklib_exit.c \ @@ -157,13 +163,17 @@ LOCAL_SRC_FILES := \ xz/src/liblzma/simple/simple_encoder.c \ xz/src/liblzma/simple/sparc.c \ xz/src/liblzma/simple/x86.c -LOCAL_CFLAGS += -DHAVE_CONFIG_H -Wno-implicit-function-declaration +LOCAL_CFLAGS := -DHAVE_CONFIG_H -Wno-implicit-function-declaration include $(BUILD_STATIC_LIBRARY) +SE_PATH := $(LOCAL_PATH)/selinux + # libsepol.a include $(CLEAR_VARS) +LIBSEPOL := $(SE_PATH)/libsepol/include $(SE_PATH)/libsepol/cil/include LOCAL_MODULE := libsepol -LOCAL_C_INCLUDES := $(LIBSEPOL) $(EXT_PATH)/selinux/libsepol/src +LOCAL_C_INCLUDES := $(LIBSEPOL) $(LOCAL_PATH)/selinux/libsepol/src +LOCAL_EXPORT_C_INCLUDES := $(LIBSEPOL) LOCAL_SRC_FILES := \ selinux/libsepol/src/assertion.c \ selinux/libsepol/src/avrule_block.c \ @@ -231,49 +241,15 @@ LOCAL_SRC_FILES := \ selinux/libsepol/cil/src/cil_symtab.c \ selinux/libsepol/cil/src/cil_tree.c \ selinux/libsepol/cil/src/cil_verify.c -LOCAL_CFLAGS += -Dgetline=__getline -Wno-implicit-function-declaration -include $(BUILD_STATIC_LIBRARY) - -# libpcre2.a -include $(CLEAR_VARS) -LOCAL_MODULE:= libpcre2 -LOCAL_CFLAGS := -DHAVE_CONFIG_H -LOCAL_C_INCLUDES := $(LIBPCRE2) $(LIBPCRE2)_internal -LOCAL_SRC_FILES := \ - pcre/dist2/src/pcre2_auto_possess.c \ - pcre/dist2/src/pcre2_chartables.c \ - pcre/dist2/src/pcre2_compile.c \ - pcre/dist2/src/pcre2_config.c \ - pcre/dist2/src/pcre2_context.c \ - pcre/dist2/src/pcre2_convert.c \ - pcre/dist2/src/pcre2_dfa_match.c \ - pcre/dist2/src/pcre2_error.c \ - pcre/dist2/src/pcre2_extuni.c \ - pcre/dist2/src/pcre2_find_bracket.c \ - pcre/dist2/src/pcre2_fuzzsupport.c \ - pcre/dist2/src/pcre2_jit_compile.c \ - pcre/dist2/src/pcre2_maketables.c \ - pcre/dist2/src/pcre2_match.c \ - pcre/dist2/src/pcre2_match_data.c \ - pcre/dist2/src/pcre2_newline.c \ - pcre/dist2/src/pcre2_ord2utf.c \ - pcre/dist2/src/pcre2_pattern_info.c \ - pcre/dist2/src/pcre2_script_run.c \ - pcre/dist2/src/pcre2_serialize.c \ - pcre/dist2/src/pcre2_string_utils.c \ - pcre/dist2/src/pcre2_study.c \ - pcre/dist2/src/pcre2_substitute.c \ - pcre/dist2/src/pcre2_substring.c \ - pcre/dist2/src/pcre2_tables.c \ - pcre/dist2/src/pcre2_ucd.c \ - pcre/dist2/src/pcre2_valid_utf.c \ - pcre/dist2/src/pcre2_xclass.c +LOCAL_CFLAGS := -Dgetline=__getline -Wno-implicit-function-declaration include $(BUILD_STATIC_LIBRARY) # libselinux.a include $(CLEAR_VARS) +LIBSELINUX := $(SE_PATH)/libselinux/include LOCAL_MODULE:= libselinux LOCAL_C_INCLUDES := $(LIBSELINUX) $(LIBPCRE2) +LOCAL_EXPORT_C_INCLUDES := $(LIBSELINUX) LOCAL_STATIC_LIBRARIES := libpcre2 LOCAL_CFLAGS := \ -Wno-implicit-function-declaration -Wno-int-conversion -Wno-unused-function \ @@ -339,4 +315,42 @@ LOCAL_SRC_FILES := \ selinux/libselinux/src/validatetrans.c include $(BUILD_STATIC_LIBRARY) -include $(EXT_PATH)/mincrypt/Android.mk +# libpcre2.a +include $(CLEAR_VARS) +LIBPCRE2 := $(LOCAL_PATH)/pcre/include +LOCAL_MODULE:= libpcre2 +LOCAL_CFLAGS := -DHAVE_CONFIG_H +LOCAL_C_INCLUDES := $(LIBPCRE2) $(LIBPCRE2)_internal +LOCAL_EXPORT_C_INCLUDES := $(LIBPCRE2) +LOCAL_SRC_FILES := \ + pcre/dist2/src/pcre2_auto_possess.c \ + pcre/dist2/src/pcre2_chartables.c \ + pcre/dist2/src/pcre2_compile.c \ + pcre/dist2/src/pcre2_config.c \ + pcre/dist2/src/pcre2_context.c \ + pcre/dist2/src/pcre2_convert.c \ + pcre/dist2/src/pcre2_dfa_match.c \ + pcre/dist2/src/pcre2_error.c \ + pcre/dist2/src/pcre2_extuni.c \ + pcre/dist2/src/pcre2_find_bracket.c \ + pcre/dist2/src/pcre2_fuzzsupport.c \ + pcre/dist2/src/pcre2_jit_compile.c \ + pcre/dist2/src/pcre2_maketables.c \ + pcre/dist2/src/pcre2_match.c \ + pcre/dist2/src/pcre2_match_data.c \ + pcre/dist2/src/pcre2_newline.c \ + pcre/dist2/src/pcre2_ord2utf.c \ + pcre/dist2/src/pcre2_pattern_info.c \ + pcre/dist2/src/pcre2_script_run.c \ + pcre/dist2/src/pcre2_serialize.c \ + pcre/dist2/src/pcre2_string_utils.c \ + pcre/dist2/src/pcre2_study.c \ + pcre/dist2/src/pcre2_substitute.c \ + pcre/dist2/src/pcre2_substring.c \ + pcre/dist2/src/pcre2_tables.c \ + pcre/dist2/src/pcre2_ucd.c \ + pcre/dist2/src/pcre2_valid_utf.c \ + pcre/dist2/src/pcre2_xclass.c +include $(BUILD_STATIC_LIBRARY) + +include $(LOCAL_PATH)/mincrypt/Android.mk diff --git a/native/jni/external/mincrypt b/native/jni/external/mincrypt index ac33afa79..1f355c50a 160000 --- a/native/jni/external/mincrypt +++ b/native/jni/external/mincrypt @@ -1 +1 @@ -Subproject commit ac33afa79e57e198b9eeec231140d64816a0bb1e +Subproject commit 1f355c50a4025a3549cbeeb6cb29b639d8721323 diff --git a/native/jni/systemproperties/Android.mk b/native/jni/systemproperties/Android.mk index 223d15388..398158310 100644 --- a/native/jni/systemproperties/Android.mk +++ b/native/jni/systemproperties/Android.mk @@ -2,7 +2,8 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:= libsystemproperties -LOCAL_C_INCLUDES := jni/include $(LIBSYSTEMPROPERTIES) +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) LOCAL_SRC_FILES := \ context_node.cpp \ contexts_serialized.cpp \ diff --git a/native/jni/utils/Android.mk b/native/jni/utils/Android.mk index a746c427b..f11fdc6d8 100644 --- a/native/jni/utils/Android.mk +++ b/native/jni/utils/Android.mk @@ -2,7 +2,8 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:= libutils -LOCAL_C_INCLUDES := jni/include $(LIBUTILS) +LOCAL_C_INCLUDES := jni/include $(LOCAL_PATH)/include +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_SRC_FILES := \ missing.cpp \ new.cpp \