Handle stubs within an apex with apex_available
Note this doesn't entirely match Soong's logic but is an improvement to
allow linking against implementation when two cc modules are
apex_available to the same module.
It is not possible to recreate the logic for "directly in" without
significant changes to bp2build as we do not add dependencies nor run
apex mutators. Rather than trying to replicate this, we would be better
off refactoring Soong to no longer support the "directly in apex" logic
and require users to correctly specify apex_available.
Bug: 272378496
Test: go test conversion tests
Change-Id: I17ac426f9b4bdad0c2ab661484e5d994f63568ce
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 16d8f6e..d2c463d 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -3038,6 +3038,7 @@
},
},
bazel_module: { bp2build_available: true },
+ apex_available: ["foo"],
}`,
ExpectedBazelTargets: makeCcLibraryTargets("foolib", AttrNameToString{
"implementation_dynamic_deps": `select({
@@ -3045,6 +3046,7 @@
"//conditions:default": [":barlib"],
})`,
"local_includes": `["."]`,
+ "tags": `["apex_available=foo"]`,
}),
})
}
@@ -3078,6 +3080,7 @@
},
include_build_directory: false,
bazel_module: { bp2build_available: true },
+ apex_available: ["foo"],
}`,
ExpectedBazelTargets: makeCcLibraryTargets("foolib", AttrNameToString{
"implementation_dynamic_deps": `select({
@@ -3102,6 +3105,7 @@
":quxlib",
],
})`,
+ "tags": `["apex_available=foo"]`,
}),
})
}