How to use soong namespaces in order to conditionally compile modules

Viewed 957

I'm in the process of converting an Android.mk file to an Android.bp. The Android.mk file dynamically linked libraries within the /my/example/dir, choosing whether or not to link them based on a conditional using an environmental variable that was set elsewhere. .bp files don't allow for conditionals so I'm trying to replicate this behavior with soong_namespaces.

When I add soong namespaces to directories /my/example/dir/A and /my/example/dir/B, A and B now are no longer being linked, but I'm unclear as to how to make them be linked conditionally. The Soong documentation states:

If a module belongs to an explicit namespace, it can be referenced from a makefile only after after the name of the namespace has been added to the value of PRODUCT_SOONG_NAMESPACES variable.

So within the BoardConfig.mk I conditionally add to PRODUCT_SOONG_NAMESPACES either /my/example/dir/A or /my/example/dir/B but neither is being linked after doing so. Am I doing this incorrectly or is this not something soong namespaces can do?

1 Answers

I believe PRODUCT_SOONG_NAMESPACES expects relative paths from the root of your tree, rather than the absolute paths you specified.

e.g. if your tree lives at /my, you'll set

PRODUCT_SOONG_NAMESPACES := example/dir/A
Related