Mark implementation variant of prebuilts with stubs as not installable am: 5bdf2d589c

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1974259

Change-Id: I51f0c05a736a78051ba3453bad554f25cd4b3571
This commit is contained in:
Martin Stjernholm 2022-02-23 16:56:19 +00:00 committed by Automerger Merge Worker
commit 60da7cf31e
2 changed files with 82 additions and 0 deletions

View file

@ -16,6 +16,7 @@ package cc
import (
"path/filepath"
"strings"
"android/soong/android"
"android/soong/bazel"
@ -188,6 +189,16 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
TableOfContents: p.tocFile,
})
// TODO(b/220898484): Mainline module sdk prebuilts of stub libraries use a stub
// library as their source and must not be installed, but libclang_rt.* libraries
// have stubs because they are LLNDK libraries, but use an implementation library
// as their source and need to be installed. This discrepancy should be resolved
// without the prefix hack below.
if p.hasStubsVariants() && !p.buildStubs() && !ctx.Host() &&
!strings.HasPrefix(ctx.baseModuleName(), "libclang_rt.") {
ctx.Module().MakeUninstallable()
}
return outputFile
}
}

View file

@ -20,6 +20,7 @@ import (
"android/soong/android"
"android/soong/bazel/cquery"
"github.com/google/blueprint"
)
@ -29,6 +30,7 @@ var prepareForPrebuiltTest = android.GroupFixturePreparers(
)
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 @@ cc_prebuilt_library_shared {
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)
})
}