AOSP構建

梦过无声發表於2024-05-24

五種預編譯選項

var prebuiltTypes = map[string]string{
        "SHARED_LIBRARIES": "cc_prebuilt_library_shared",
        "STATIC_LIBRARIES": "cc_prebuilt_library_static",
        "EXECUTABLES":      "cc_prebuilt_binary",
        "JAVA_LIBRARIES":   "java_import",
        "ETC":              "prebuilt_etc",
}

構建預編譯動態庫

cc_prebuilt_library_shared {
        name: "libprebuilt_test",
        target: {
            android_arm: {
                srcs: ["lib32/libprebuilt_test.so"],
            },
            android_arm64: {
                srcs: ["lib64/libprebuilt_test.so"],
            },
        },
        strip: {
            none:true,
        },
        shared_libs: ["libx", "libxx", "libxxx", "libxxxx"],
        check_elf_files: false,
        compile_multilib: "both"//32位和64位都預編譯
    }

或者

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libprebuilt_test
LOCAL_MODULE_SUFFIX := .so 
LOCAL_MODULE_CLASS := SHARED_LIBRARIES                                                                                                                                                       
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES_arm := lib32/libprebuilt_test.so
LOCAL_SRC_FILES_arm64 := lib64/libprebuilt_test.so

LOCAL_SHARED_LIBRARIES := libx  libxx  libxxx libxxxx
LOCAL_MULTILIB := both
include $(BUILD_PREBUILT)

預編譯靜態庫

cc_prebuilt_library_static {
        name: "libprebuilt_static",
        target: {
            android_arm: {
                srcs: ["lib32/libprebuilt_static.a"],
            },
            android_arm64: {
                srcs: ["lib64/libprebuilt_static.a"],
            },
        },
        strip: {
            none:true,
        },
        check_elf_files: false,
        compile_multilib: "both"
}

或者

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libprebuilt_static
LOCAL_MODULE_SUFFIX := .a
LOCAL_MODULE_CLASS := STATIC_LIBRARIES                                                                                              
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES_arm := arm32/libprebuilt.a
LOCAL_SRC_FILES_arm64 := arm64/libprebuilt.a
LOCAL_CHECK_ELF_FILES := false
LOCAL_MULTILIB := both

include $(BUILD_PREBUILT)

相關文章