gpt4 book ai didi

android - 将 Android.mk 中的共享库包含到 Android.bp 的 cc_test 中

转载 作者:行者123 更新时间:2023-11-29 22:57:18 28 4
gpt4 key购买 nike

我有一个 Android.mk,它构建了一些库:

ifeq ($(CONDITION),something)
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
BDROID_DIR := $(TOP_DIR)system/bt
LOCAL_CFLAGS += \
-Wall \
-Werror
LOCAL_SRC_FILES := ...
LOCAL_HEADER_LIBRARIES := libutils_headers
LOCAL_C_INCLUDES += ...
LOCAL_SHARED_LIBRARIES := \
libcutils \
liblog
LOCAL_MODULE := libowner-vendor
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_OWNER := owner
LOCAL_PROPRIETARY_MODULE := true
include $(BUILD_SHARED_LIBRARY)

include $(call first-makefiles-under,$(LOCAL_PATH))
endif

我想向其中添加一个测试模块,最好是 cc_test,因为我希望能够使用 atest 实用程序调用它。

显然,像这样简单地将它添加到“shared_libs”部分是行不通的:

Android.bp:

cc_test = {
proprietary: true,
name: "libowner-vendor-test",
cflags: [
"-Werror",
"-Wall",
],
srcs: [...],
shared_libs: [
...,
"libowner-vendor",
],
host_supported: false,
}

目录结构:

+ lib:
- Android.mk
- ... (sources and headers)
+ lib/test:
-- ... (test sources)

我收到一个错误:

.../Android.bp:1:1: "libowner-vendor-test" depends on undefined module "libowner-vendor"

最佳答案

根据Soong documentation ,您不能直接访问 Android.mk 中定义的模块。

Until we have fully converted from Make to Soong, it will be necessary for the Make product config to specify a value of PRODUCT_SOONG_NAMESPACES. Its value should be a space-separated list of namespaces that Soong export to Make to be built by the m command. After we have fully converted from Make to Soong, the details of enabling namespaces could potentially change.

我没有找到如何使用 PRODUCT_SOONG_NAMESPACES 的示例。但是由于 Android.mk 是遗留的,您应该考虑使用 androidmk 将您的 Android.mk 转换为 Android.bp > 属于 AOSP 一部分的工具。

. build/envsetup.sh
lunch
m androidmk
androidmk path/to/your/Android.mk > path/to/your/Android.bp
mv path/to/your/Android.mk path/to/your/Android.mk.old

关于android - 将 Android.mk 中的共享库包含到 Android.bp 的 cc_test 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57291037/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com