remove stub dependency on source_library

Since the source_library attribute of _cc_stub_library_shared was a
label attribute, the source library was added as a dependency of the
stub which doesn't always make sense. E.g. it caused validation actions
for the source library to run even when we weren't building the source
library.

This change converts the label attriubte to a string attribute so that
we don't add the dependency.

Bug: 263390551
Change-Id: I19c62d1e14847dff68ab37156452addaa119eaf9
This commit is contained in:
Sam Delmerico
2023-03-15 18:06:18 -04:00
parent a8c1cacaf9
commit 5f90649036
5 changed files with 27 additions and 25 deletions

View File

@@ -1191,9 +1191,9 @@ apex {
"tags": `["apex_available=myapex"]`, "tags": `["apex_available=myapex"]`,
}), }),
MakeBazelTarget("cc_stub_suite", "foo_stub_libs", AttrNameToString{ MakeBazelTarget("cc_stub_suite", "foo_stub_libs", AttrNameToString{
"soname": `"foo.so"`, "soname": `"foo.so"`,
"source_library": `":foo"`, "source_library_label": `"//:foo"`,
"symbol_file": `"foo.map.txt"`, "symbol_file": `"foo.map.txt"`,
"versions": `[ "versions": `[
"28", "28",
"29", "29",

View File

@@ -2780,9 +2780,9 @@ func TestCcLibraryStubs(t *testing.T) {
"stubs_symbol_file": `"a.map.txt"`, "stubs_symbol_file": `"a.map.txt"`,
}) })
expectedBazelTargets = append(expectedBazelTargets, makeCcStubSuiteTargets("a", AttrNameToString{ expectedBazelTargets = append(expectedBazelTargets, makeCcStubSuiteTargets("a", AttrNameToString{
"soname": `"a.so"`, "soname": `"a.so"`,
"source_library": `":a"`, "source_library_label": `"//foo/bar:a"`,
"stubs_symbol_file": `"a.map.txt"`, "stubs_symbol_file": `"a.map.txt"`,
"stubs_versions": `[ "stubs_versions": `[
"28", "28",
"29", "29",

View File

@@ -540,9 +540,9 @@ cc_library_shared {
}, },
Blueprint: soongCcLibraryPreamble, Blueprint: soongCcLibraryPreamble,
ExpectedBazelTargets: []string{makeCcStubSuiteTargets("a", AttrNameToString{ ExpectedBazelTargets: []string{makeCcStubSuiteTargets("a", AttrNameToString{
"soname": `"a.so"`, "soname": `"a.so"`,
"source_library": `":a"`, "source_library_label": `"//foo/bar:a"`,
"stubs_symbol_file": `"a.map.txt"`, "stubs_symbol_file": `"a.map.txt"`,
"stubs_versions": `[ "stubs_versions": `[
"28", "28",
"29", "29",

View File

@@ -623,16 +623,18 @@ func makeCcStubSuiteTargets(name string, attrs AttrNameToString) string {
return "" return ""
} }
STUB_SUITE_ATTRS := map[string]string{ STUB_SUITE_ATTRS := map[string]string{
"stubs_symbol_file": "symbol_file", "stubs_symbol_file": "symbol_file",
"stubs_versions": "versions", "stubs_versions": "versions",
"soname": "soname", "soname": "soname",
"source_library": "source_library", "source_library_label": "source_library_label",
} }
stubSuiteAttrs := AttrNameToString{} stubSuiteAttrs := AttrNameToString{}
for key, _ := range attrs { for key, _ := range attrs {
if _, stubSuiteAttr := STUB_SUITE_ATTRS[key]; stubSuiteAttr { if _, stubSuiteAttr := STUB_SUITE_ATTRS[key]; stubSuiteAttr {
stubSuiteAttrs[STUB_SUITE_ATTRS[key]] = attrs[key] stubSuiteAttrs[STUB_SUITE_ATTRS[key]] = attrs[key]
} else {
panic(fmt.Sprintf("unused cc_stub_suite attr %q\n", key))
} }
} }
return MakeBazelTarget("cc_stub_suite", name+"_stub_libs", stubSuiteAttrs) return MakeBazelTarget("cc_stub_suite", name+"_stub_libs", stubSuiteAttrs)

View File

@@ -454,12 +454,12 @@ func createStubsBazelTargetIfNeeded(ctx android.TopDownMutatorContext, m *Module
} }
soname := m.Name() + ".so" soname := m.Name() + ".so"
stubSuitesAttrs := &bazelCcStubSuiteAttributes{ stubSuitesAttrs := &bazelCcStubSuiteAttributes{
Symbol_file: compilerAttrs.stubsSymbolFile, Symbol_file: compilerAttrs.stubsSymbolFile,
Versions: compilerAttrs.stubsVersions, Versions: compilerAttrs.stubsVersions,
Export_includes: exportedIncludes.Includes, Export_includes: exportedIncludes.Includes,
Soname: &soname, Soname: &soname,
Source_library: *bazel.MakeLabelAttribute(":" + m.Name()), Source_library_label: proptools.StringPtr(m.GetBazelLabel(ctx, m)),
Deps: baseAttributes.deps, Deps: baseAttributes.deps,
} }
ctx.CreateBazelTargetModule(stubSuitesProps, ctx.CreateBazelTargetModule(stubSuitesProps,
android.CommonAttributes{Name: m.Name() + "_stub_libs"}, android.CommonAttributes{Name: m.Name() + "_stub_libs"},
@@ -3033,12 +3033,12 @@ type bazelCcLibrarySharedAttributes struct {
} }
type bazelCcStubSuiteAttributes struct { type bazelCcStubSuiteAttributes struct {
Symbol_file *string Symbol_file *string
Versions bazel.StringListAttribute Versions bazel.StringListAttribute
Export_includes bazel.StringListAttribute Export_includes bazel.StringListAttribute
Source_library bazel.LabelAttribute Source_library_label *string
Soname *string Soname *string
Deps bazel.LabelListAttribute Deps bazel.LabelListAttribute
} }
type bazelCcHeaderAbiCheckerAttributes struct { type bazelCcHeaderAbiCheckerAttributes struct {