Update Makefiles

This commit is contained in:
topjohnwu 2020-04-06 22:45:08 -07:00
parent 4729514a22
commit 4066e5bf14
6 changed files with 85 additions and 107 deletions

View File

@ -253,9 +253,11 @@ def gen_update_binary():
def run_ndk_build(flags): 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: if proc.returncode != 0:
error('Build binary failed!') error('Build binary failed!')
os.chdir('..')
collect_binary() collect_binary()

View File

@ -1,21 +1,5 @@
LOCAL_PATH := $(call my-dir) 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 # Binaries
######################## ########################
@ -25,11 +9,7 @@ ifdef B_MAGISK
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := magisk LOCAL_MODULE := magisk
LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils
LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := jni/include
jni/include \
$(LIBNANOPB) \
$(LIBSYSTEMPROPERTIES) \
$(LIBUTILS)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
core/applets.cpp \ core/applets.cpp \
@ -72,10 +52,7 @@ LOCAL_STATIC_LIBRARIES := libsepol libxz libutils
LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := \
jni/include \ jni/include \
out \ out \
out/$(TARGET_ARCH_ABI) \ out/$(TARGET_ARCH_ABI)
$(LIBXZ) \
$(LIBSEPOL) \
$(LIBUTILS)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
init/init.cpp \ init/init.cpp \
@ -100,15 +77,7 @@ ifdef B_BOOT
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := magiskboot LOCAL_MODULE := magiskboot
LOCAL_STATIC_LIBRARIES := libmincrypt liblzma liblz4 libbz2 libfdt libutils LOCAL_STATIC_LIBRARIES := libmincrypt liblzma liblz4 libbz2 libfdt libutils
LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := jni/include
jni/include \
$(EXT_PATH)/include \
$(LIBMINCRYPT) \
$(LIBLZMA) \
$(LIBLZ4) \
$(LIBBZ2) \
$(LIBFDT) \
$(LIBUTILS)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
magiskboot/main.cpp \ magiskboot/main.cpp \
@ -131,10 +100,7 @@ ifdef B_POLICY
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := magiskpolicy LOCAL_MODULE := magiskpolicy
LOCAL_STATIC_LIBRARIES := libsepol libutils LOCAL_STATIC_LIBRARIES := libsepol libutils
LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := jni/include
jni/include \
$(LIBSEPOL) \
$(LIBUTILS)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
core/applet_stub.cpp \ core/applet_stub.cpp \
@ -156,11 +122,7 @@ ifdef B_PROP
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := resetprop LOCAL_MODULE := resetprop
LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils
LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := jni/include
jni/include \
$(LIBNANOPB) \
$(LIBSYSTEMPROPERTIES) \
$(LIBUTILS)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
core/applet_stub.cpp \ core/applet_stub.cpp \
@ -178,9 +140,7 @@ ifdef B_TEST
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := test LOCAL_MODULE := test
LOCAL_STATIC_LIBRARIES := libutils LOCAL_STATIC_LIBRARIES := libutils
LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := jni/include
jni/include \
$(LIBUTILS)
LOCAL_SRC_FILES := test.cpp LOCAL_SRC_FILES := test.cpp
LOCAL_LDFLAGS := -static LOCAL_LDFLAGS := -static
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)

View File

@ -3,7 +3,8 @@ LOCAL_PATH := $(call my-dir)
# libxz.a # libxz.a
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE:= libxz LOCAL_MODULE:= libxz
LOCAL_C_INCLUDES := $(LIBXZ) LOCAL_C_INCLUDES := $(LOCAL_PATH)/xz-embedded
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
xz-embedded/xz_crc32.c \ xz-embedded/xz_crc32.c \
xz-embedded/xz_dec_lzma2.c \ xz-embedded/xz_dec_lzma2.c \
@ -13,7 +14,8 @@ include $(BUILD_STATIC_LIBRARY)
# libnanopb.a # libnanopb.a
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE:= libnanopb LOCAL_MODULE:= libnanopb
LOCAL_C_INCLUDES := $(LIBNANOPB) LOCAL_C_INCLUDES := $(LOCAL_PATH)/nanopb
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
nanopb/pb_common.c \ nanopb/pb_common.c \
nanopb/pb_decode.c \ nanopb/pb_decode.c \
@ -23,7 +25,8 @@ include $(BUILD_STATIC_LIBRARY)
# libfdt.a # libfdt.a
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE:= libfdt LOCAL_MODULE:= libfdt
LOCAL_C_INCLUDES := $(LIBFDT) LOCAL_C_INCLUDES := $(LOCAL_PATH)/dtc/libfdt
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
dtc/libfdt/fdt.c \ dtc/libfdt/fdt.c \
dtc/libfdt/fdt_addresses.c \ dtc/libfdt/fdt_addresses.c \
@ -39,7 +42,8 @@ include $(BUILD_STATIC_LIBRARY)
# liblz4.a # liblz4.a
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := liblz4 LOCAL_MODULE := liblz4
LOCAL_C_INCLUDES += $(LIBLZ4) LOCAL_C_INCLUDES := $(LOCAL_PATH)/lz4/lib
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
lz4/lib/lz4.c \ lz4/lib/lz4.c \
lz4/lib/lz4frame.c \ lz4/lib/lz4frame.c \
@ -50,7 +54,8 @@ include $(BUILD_STATIC_LIBRARY)
# libbz2.a # libbz2.a
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := libbz2 LOCAL_MODULE := libbz2
LOCAL_C_INCLUDES += $(LIBBZ2) LOCAL_C_INCLUDES := $(LOCAL_PATH)/bzip2
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
bzip2/blocksort.c \ bzip2/blocksort.c \
bzip2/huffman.c \ bzip2/huffman.c \
@ -64,18 +69,19 @@ include $(BUILD_STATIC_LIBRARY)
# liblzma.a # liblzma.a
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := liblzma LOCAL_MODULE := liblzma
LOCAL_C_INCLUDES += \ LOCAL_C_INCLUDES := \
$(EXT_PATH)/xz_config \ $(LOCAL_PATH)/xz_config \
$(EXT_PATH)/xz/src/common \ $(LOCAL_PATH)/xz/src/common \
$(EXT_PATH)/xz/src/liblzma/api \ $(LOCAL_PATH)/xz/src/liblzma/api \
$(EXT_PATH)/xz/src/liblzma/check \ $(LOCAL_PATH)/xz/src/liblzma/check \
$(EXT_PATH)/xz/src/liblzma/common \ $(LOCAL_PATH)/xz/src/liblzma/common \
$(EXT_PATH)/xz/src/liblzma/delta \ $(LOCAL_PATH)/xz/src/liblzma/delta \
$(EXT_PATH)/xz/src/liblzma/lz \ $(LOCAL_PATH)/xz/src/liblzma/lz \
$(EXT_PATH)/xz/src/liblzma/lzma \ $(LOCAL_PATH)/xz/src/liblzma/lzma \
$(EXT_PATH)/xz/src/liblzma/rangecoder \ $(LOCAL_PATH)/xz/src/liblzma/rangecoder \
$(EXT_PATH)/xz/src/liblzma/simple \ $(LOCAL_PATH)/xz/src/liblzma/simple \
$(EXT_PATH)/xz/src/liblzma $(LOCAL_PATH)/xz/src/liblzma
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/xz/src/liblzma/api
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
xz/src/common/tuklib_cpucores.c \ xz/src/common/tuklib_cpucores.c \
xz/src/common/tuklib_exit.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/simple_encoder.c \
xz/src/liblzma/simple/sparc.c \ xz/src/liblzma/simple/sparc.c \
xz/src/liblzma/simple/x86.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) include $(BUILD_STATIC_LIBRARY)
SE_PATH := $(LOCAL_PATH)/selinux
# libsepol.a # libsepol.a
include $(CLEAR_VARS) include $(CLEAR_VARS)
LIBSEPOL := $(SE_PATH)/libsepol/include $(SE_PATH)/libsepol/cil/include
LOCAL_MODULE := libsepol 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 := \ LOCAL_SRC_FILES := \
selinux/libsepol/src/assertion.c \ selinux/libsepol/src/assertion.c \
selinux/libsepol/src/avrule_block.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_symtab.c \
selinux/libsepol/cil/src/cil_tree.c \ selinux/libsepol/cil/src/cil_tree.c \
selinux/libsepol/cil/src/cil_verify.c selinux/libsepol/cil/src/cil_verify.c
LOCAL_CFLAGS += -Dgetline=__getline -Wno-implicit-function-declaration 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
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
# libselinux.a # libselinux.a
include $(CLEAR_VARS) include $(CLEAR_VARS)
LIBSELINUX := $(SE_PATH)/libselinux/include
LOCAL_MODULE:= libselinux LOCAL_MODULE:= libselinux
LOCAL_C_INCLUDES := $(LIBSELINUX) $(LIBPCRE2) LOCAL_C_INCLUDES := $(LIBSELINUX) $(LIBPCRE2)
LOCAL_EXPORT_C_INCLUDES := $(LIBSELINUX)
LOCAL_STATIC_LIBRARIES := libpcre2 LOCAL_STATIC_LIBRARIES := libpcre2
LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
-Wno-implicit-function-declaration -Wno-int-conversion -Wno-unused-function \ -Wno-implicit-function-declaration -Wno-int-conversion -Wno-unused-function \
@ -339,4 +315,42 @@ LOCAL_SRC_FILES := \
selinux/libselinux/src/validatetrans.c selinux/libselinux/src/validatetrans.c
include $(BUILD_STATIC_LIBRARY) 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

@ -1 +1 @@
Subproject commit ac33afa79e57e198b9eeec231140d64816a0bb1e Subproject commit 1f355c50a4025a3549cbeeb6cb29b639d8721323

View File

@ -2,7 +2,8 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE:= libsystemproperties 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 := \ LOCAL_SRC_FILES := \
context_node.cpp \ context_node.cpp \
contexts_serialized.cpp \ contexts_serialized.cpp \

View File

@ -2,7 +2,8 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE:= libutils 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 := \ LOCAL_SRC_FILES := \
missing.cpp \ missing.cpp \
new.cpp \ new.cpp \