Mark implementation variant of prebuilts with stubs as not installable
This is necessary to avoid installing them. Previously, when install
dependencies were resolved in make, they weren't installed because they
got a .bootstrap suffix in their mk modules. However when that logic
moved into Soong by resolving transitive dependencies in
computeInstallDeps, they started to get dependencies and hence their
stubs could get installed, e.g. system/lib{,64}/libdexfile.so from
prebuilt_libdexfile.
Test: m nothing
Test: env NINJA_ARGS="-t path droid out/target/product/vsoc_x86_64/system/lib64/libdexfile.so" \
m SOONG_CONFIG_art_module_source_build=false nothing
verify that ninja reports no dependency path
Bug: 211770050
Bug: 220898484
Change-Id: Ifbfe31a15428926ce57b9e91b535b7ae79038fbd
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 94f75fe..901f458 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -20,6 +20,7 @@
"android/soong/android"
"android/soong/bazel/cquery"
+
"github.com/google/blueprint"
)
@@ -29,6 +30,7 @@
)
func testPrebuilt(t *testing.T, bp string, fs android.MockFS, handlers ...android.FixturePreparer) *android.TestContext {
+ t.Helper()
result := android.GroupFixturePreparers(
prepareForPrebuiltTest,
fs.AddToFixture(),
@@ -449,3 +451,72 @@
expectedOutputFiles := []string{pathPrefix + "foo.so"}
android.AssertDeepEquals(t, "output files", expectedOutputFiles, outputFiles.Strings())
}
+
+func TestPrebuiltStubNoinstall(t *testing.T) {
+ testFunc := func(t *testing.T, bp string) {
+ result := android.GroupFixturePreparers(
+ prepareForPrebuiltTest,
+ android.PrepareForTestWithMakevars,
+ ).RunTestWithBp(t, bp)
+
+ installRules := result.InstallMakeRulesForTesting(t)
+ var installedlibRule *android.InstallMakeRule
+ for i, rule := range installRules {
+ if rule.Target == "out/target/product/test_device/system/lib/installedlib.so" {
+ if installedlibRule != nil {
+ t.Errorf("Duplicate install rules for %s", rule.Target)
+ }
+ installedlibRule = &installRules[i]
+ }
+ }
+ if installedlibRule == nil {
+ t.Errorf("No install rule found for installedlib")
+ return
+ }
+
+ android.AssertStringListDoesNotContain(t,
+ "installedlib has install dependency on stub",
+ installedlibRule.Deps,
+ "out/target/product/test_device/system/lib/stublib.so")
+ android.AssertStringListDoesNotContain(t,
+ "installedlib has order-only install dependency on stub",
+ installedlibRule.OrderOnlyDeps,
+ "out/target/product/test_device/system/lib/stublib.so")
+ }
+
+ const prebuiltStublibBp = `
+ cc_prebuilt_library {
+ name: "stublib",
+ prefer: true,
+ srcs: ["foo.so"],
+ stubs: {
+ versions: ["1"],
+ },
+ }
+ `
+
+ const installedlibBp = `
+ cc_library {
+ name: "installedlib",
+ shared_libs: ["stublib"],
+ }
+ `
+
+ t.Run("prebuilt without source", func(t *testing.T) {
+ testFunc(t, prebuiltStublibBp+installedlibBp)
+ })
+
+ const disabledSourceStublibBp = `
+ cc_library {
+ name: "stublib",
+ enabled: false,
+ stubs: {
+ versions: ["1"],
+ },
+ }
+ `
+
+ t.Run("prebuilt with disabled source", func(t *testing.T) {
+ testFunc(t, disabledSourceStublibBp+prebuiltStublibBp+installedlibBp)
+ })
+}