From 2ce4a5543b9e9e5dfd8460a2f8ae48835aa4a917 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 13 Dec 2024 17:00:40 -0800 Subject: [PATCH] Make ndk-build happy when Rust libs are missing --- native/src/Android-rs.mk | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/native/src/Android-rs.mk b/native/src/Android-rs.mk index cb04a076f..98f295924 100644 --- a/native/src/Android-rs.mk +++ b/native/src/Android-rs.mk @@ -4,35 +4,43 @@ LOCAL_PATH := $(call my-dir) # Rust compilation outputs ########################### -LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagisk-rs.a -ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH))) include $(CLEAR_VARS) LOCAL_MODULE := magisk-rs LOCAL_EXPORT_C_INCLUDES := src/core/include -LOCAL_SRC_FILES := $(LIBRARY_PATH) +LOCAL_LIB = ../out/$(TARGET_ARCH_ABI)/libmagisk-rs.a +ifneq (,$(wildcard $(LOCAL_PATH)/$(LOCAL_LIB))) +LOCAL_SRC_FILES := $(LOCAL_LIB) include $(PREBUILT_STATIC_LIBRARY) +else +include $(BUILD_STATIC_LIBRARY) endif -LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagiskboot-rs.a -ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH))) include $(CLEAR_VARS) LOCAL_MODULE := boot-rs -LOCAL_SRC_FILES := $(LIBRARY_PATH) +LOCAL_LIB = ../out/$(TARGET_ARCH_ABI)/libmagiskboot-rs.a +ifneq (,$(wildcard $(LOCAL_PATH)/$(LOCAL_LIB))) +LOCAL_SRC_FILES := $(LOCAL_LIB) include $(PREBUILT_STATIC_LIBRARY) +else +include $(BUILD_STATIC_LIBRARY) endif -LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagiskinit-rs.a -ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH))) include $(CLEAR_VARS) LOCAL_MODULE := init-rs -LOCAL_SRC_FILES := $(LIBRARY_PATH) +LOCAL_LIB = ../out/$(TARGET_ARCH_ABI)/libmagiskinit-rs.a +ifneq (,$(wildcard $(LOCAL_PATH)/$(LOCAL_LIB))) +LOCAL_SRC_FILES := $(LOCAL_LIB) include $(PREBUILT_STATIC_LIBRARY) +else +include $(BUILD_STATIC_LIBRARY) endif -LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagiskpolicy-rs.a -ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH))) include $(CLEAR_VARS) LOCAL_MODULE := policy-rs -LOCAL_SRC_FILES := $(LIBRARY_PATH) +LOCAL_LIB = ../out/$(TARGET_ARCH_ABI)/libmagiskpolicy-rs.a +ifneq (,$(wildcard $(LOCAL_PATH)/$(LOCAL_LIB))) +LOCAL_SRC_FILES := $(LOCAL_LIB) include $(PREBUILT_STATIC_LIBRARY) +else +include $(BUILD_STATIC_LIBRARY) endif