From 5f90649036e7f29994bfd691e3cda528ed6c1904 Mon Sep 17 00:00:00 2001 From: Sam Delmerico Date: Wed, 15 Mar 2023 18:06:18 -0400 Subject: [PATCH] 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 --- bp2build/apex_conversion_test.go | 6 ++--- bp2build/cc_library_conversion_test.go | 6 ++--- bp2build/cc_library_shared_conversion_test.go | 6 ++--- bp2build/testing.go | 10 ++++---- cc/library.go | 24 +++++++++---------- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/bp2build/apex_conversion_test.go b/bp2build/apex_conversion_test.go index 73c889f1c..03fb5d4e1 100644 --- a/bp2build/apex_conversion_test.go +++ b/bp2build/apex_conversion_test.go @@ -1191,9 +1191,9 @@ apex { "tags": `["apex_available=myapex"]`, }), MakeBazelTarget("cc_stub_suite", "foo_stub_libs", AttrNameToString{ - "soname": `"foo.so"`, - "source_library": `":foo"`, - "symbol_file": `"foo.map.txt"`, + "soname": `"foo.so"`, + "source_library_label": `"//:foo"`, + "symbol_file": `"foo.map.txt"`, "versions": `[ "28", "29", diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go index e20cffd4a..fbe6e76ec 100644 --- a/bp2build/cc_library_conversion_test.go +++ b/bp2build/cc_library_conversion_test.go @@ -2780,9 +2780,9 @@ func TestCcLibraryStubs(t *testing.T) { "stubs_symbol_file": `"a.map.txt"`, }) expectedBazelTargets = append(expectedBazelTargets, makeCcStubSuiteTargets("a", AttrNameToString{ - "soname": `"a.so"`, - "source_library": `":a"`, - "stubs_symbol_file": `"a.map.txt"`, + "soname": `"a.so"`, + "source_library_label": `"//foo/bar:a"`, + "stubs_symbol_file": `"a.map.txt"`, "stubs_versions": `[ "28", "29", diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go index 838b29759..b685a2c30 100644 --- a/bp2build/cc_library_shared_conversion_test.go +++ b/bp2build/cc_library_shared_conversion_test.go @@ -540,9 +540,9 @@ cc_library_shared { }, Blueprint: soongCcLibraryPreamble, ExpectedBazelTargets: []string{makeCcStubSuiteTargets("a", AttrNameToString{ - "soname": `"a.so"`, - "source_library": `":a"`, - "stubs_symbol_file": `"a.map.txt"`, + "soname": `"a.so"`, + "source_library_label": `"//foo/bar:a"`, + "stubs_symbol_file": `"a.map.txt"`, "stubs_versions": `[ "28", "29", diff --git a/bp2build/testing.go b/bp2build/testing.go index a737ea14a..ee2ab0872 100644 --- a/bp2build/testing.go +++ b/bp2build/testing.go @@ -623,16 +623,18 @@ func makeCcStubSuiteTargets(name string, attrs AttrNameToString) string { return "" } STUB_SUITE_ATTRS := map[string]string{ - "stubs_symbol_file": "symbol_file", - "stubs_versions": "versions", - "soname": "soname", - "source_library": "source_library", + "stubs_symbol_file": "symbol_file", + "stubs_versions": "versions", + "soname": "soname", + "source_library_label": "source_library_label", } stubSuiteAttrs := AttrNameToString{} for key, _ := range attrs { if _, stubSuiteAttr := STUB_SUITE_ATTRS[key]; stubSuiteAttr { 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) diff --git a/cc/library.go b/cc/library.go index 27f06230b..91960d515 100644 --- a/cc/library.go +++ b/cc/library.go @@ -454,12 +454,12 @@ func createStubsBazelTargetIfNeeded(ctx android.TopDownMutatorContext, m *Module } soname := m.Name() + ".so" stubSuitesAttrs := &bazelCcStubSuiteAttributes{ - Symbol_file: compilerAttrs.stubsSymbolFile, - Versions: compilerAttrs.stubsVersions, - Export_includes: exportedIncludes.Includes, - Soname: &soname, - Source_library: *bazel.MakeLabelAttribute(":" + m.Name()), - Deps: baseAttributes.deps, + Symbol_file: compilerAttrs.stubsSymbolFile, + Versions: compilerAttrs.stubsVersions, + Export_includes: exportedIncludes.Includes, + Soname: &soname, + Source_library_label: proptools.StringPtr(m.GetBazelLabel(ctx, m)), + Deps: baseAttributes.deps, } ctx.CreateBazelTargetModule(stubSuitesProps, android.CommonAttributes{Name: m.Name() + "_stub_libs"}, @@ -3033,12 +3033,12 @@ type bazelCcLibrarySharedAttributes struct { } type bazelCcStubSuiteAttributes struct { - Symbol_file *string - Versions bazel.StringListAttribute - Export_includes bazel.StringListAttribute - Source_library bazel.LabelAttribute - Soname *string - Deps bazel.LabelListAttribute + Symbol_file *string + Versions bazel.StringListAttribute + Export_includes bazel.StringListAttribute + Source_library_label *string + Soname *string + Deps bazel.LabelListAttribute } type bazelCcHeaderAbiCheckerAttributes struct {