5

I have an Android.mk, which builds some library:

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

I want to add a test module to it, preferably cc_test, because I want to be able to call it using atest utility.

Apparently, simply adding it in the "shared_libs" section like this doesn't work:

Android.bp:

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

Directories structure:

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

I receive an error:

.../Android.bp:1:1: "libowner-vendor-test" depends on undefined module "libowner-vendor"
a_girl
  • 959
  • 7
  • 22

1 Answers1

4

According to the Soong documentation, you cannot directly access modules defined in an 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.

I did not find an example of how to make use of PRODUCT_SOONG_NAMESPACES. But since Android.mk is legacy, you should consider converting your Android.mk to Android.bp with the androidmk tool which is part of the 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
Simpl
  • 1,938
  • 1
  • 10
  • 21
  • I know mk is legasy, but it is more convenient for conditionals during the build process, and, since my mk file uses them, it is impossible to convert it to bp. I'll try to find more info on PRODUCT_SOONG_NAMESPACES, thanks. – a_girl Aug 01 '19 at 09:25