Change apex_available value of libavf based on avf_enabled
When avf_enabled is set libavf is included in com.android.virt,
but when it is unset libavf is not included in any apex. That
triggered a shortcut in Soong when no apex variations exist
resulting in the platform variant not being hidden from Make
despite the module not setting //apex_available:platform.
When the shortcut is fixed to consistently hide the platform
variant it triggers a check-abi-dump-list failure because
libavf is now hidden from Make and not included in the LLNDK
libraries in LSDUMP_PATHS.
Add a conditional to libavf so that when avf_enabled it sets
apex_available: ["com.android.virt"] as before and uses the apex variant
to create the lsdump, but when avf_enabled is unset leaves apex_available
unset so that the platform variant exists and is unhidden to create the
lsdump.
Also add //apex_available:platform to authfs to counteract the
com.android.virt in crosvm_defaults so it is available to the platform
and can be embedded in the microdroid image.
Bug: 394664568
Test: builds
Change-Id: Id85edd1cb9548074537845137d66813e145642ea
diff --git a/guest/authfs/Android.bp b/guest/authfs/Android.bp
index d7a8322..28e0f4a 100644
--- a/guest/authfs/Android.bp
+++ b/guest/authfs/Android.bp
@@ -47,5 +47,8 @@
rust_binary {
name: "authfs",
defaults: ["authfs_defaults"],
- apex_available: ["com.android.virt"],
+ // //apex_available:platform is necessary here to counteract the
+ // com.android.virt in crosvm_defaults and make authfs available
+ // to the platform so it can be embedded in the microdroid image.
+ apex_available: ["//apex_available:platform"],
}
diff --git a/libs/libavf/Android.bp b/libs/libavf/Android.bp
index c958796..aceb927 100644
--- a/libs/libavf/Android.bp
+++ b/libs/libavf/Android.bp
@@ -40,8 +40,30 @@
defaults: ["libavf.default"],
}
+soong_config_module_type {
+ name: "virt_cc_defaults",
+ module_type: "cc_defaults",
+ config_namespace: "ANDROID",
+ bool_variables: [
+ "avf_enabled",
+ ],
+ properties: [
+ "apex_available",
+ ],
+}
+
+virt_cc_defaults {
+ name: "libavf_apex_available_defaults",
+ soong_config_variables: {
+ avf_enabled: {
+ apex_available: ["com.android.virt"],
+ },
+ },
+}
+
cc_library {
name: "libavf",
+ defaults: ["libavf_apex_available_defaults"],
llndk: {
symbol_file: "libavf.map.txt",
moved_to_apex: true,
@@ -53,7 +75,6 @@
"liblog",
],
export_include_dirs: ["include"],
- apex_available: ["com.android.virt"],
version_script: "libavf.map.txt",
stubs: {
symbol_file: "libavf.map.txt",