blob: df938d23854fab0fdedd284f20477c26ff4186a4 [file] [log] [blame]
Jingwen Chen91220d72021-03-24 02:18:33 -04001// Copyright 2021 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14package cc
15
16import (
Jingwen Chened9c17d2021-04-13 07:14:55 +000017 "path/filepath"
Jingwen Chen3950cd62021-05-12 04:33:00 +000018 "strings"
Chris Parsons484e50a2021-05-13 15:13:04 -040019
20 "android/soong/android"
21 "android/soong/bazel"
Liz Kammer7a210ac2021-09-22 15:52:58 -040022
Chris Parsons953b3562021-09-20 15:14:39 -040023 "github.com/google/blueprint"
Liz Kammerba7a9c52021-05-26 08:45:30 -040024
25 "github.com/google/blueprint/proptools"
Jingwen Chen91220d72021-03-24 02:18:33 -040026)
27
Liz Kammer2222c6b2021-05-24 15:41:47 -040028// staticOrSharedAttributes are the Bazel-ified versions of StaticOrSharedProperties --
Jingwen Chenbcf53042021-05-26 04:42:42 +000029// properties which apply to either the shared or static version of a cc_library module.
Liz Kammer2222c6b2021-05-24 15:41:47 -040030type staticOrSharedAttributes struct {
Jingwen Chenc4dc9b42021-06-11 12:51:48 +000031 Srcs bazel.LabelListAttribute
32 Srcs_c bazel.LabelListAttribute
33 Srcs_as bazel.LabelListAttribute
34 Copts bazel.StringListAttribute
Jingwen Chen14a8bda2021-06-02 11:10:02 +000035
Liz Kammer7a210ac2021-09-22 15:52:58 -040036 Deps bazel.LabelListAttribute
37 Implementation_deps bazel.LabelListAttribute
38 Dynamic_deps bazel.LabelListAttribute
39 Implementation_dynamic_deps bazel.LabelListAttribute
40 Whole_archive_deps bazel.LabelListAttribute
Chris Parsons51f8c392021-08-03 21:01:05 -040041
42 System_dynamic_deps bazel.LabelListAttribute
Jingwen Chen53681ef2021-04-29 08:15:13 +000043}
44
Jingwen Chen14a8bda2021-06-02 11:10:02 +000045func groupSrcsByExtension(ctx android.TopDownMutatorContext, srcs bazel.LabelListAttribute) (cppSrcs, cSrcs, asSrcs bazel.LabelListAttribute) {
Jingwen Chen14a8bda2021-06-02 11:10:02 +000046 // Check that a module is a filegroup type named <label>.
47 isFilegroupNamed := func(m android.Module, fullLabel string) bool {
48 if ctx.OtherModuleType(m) != "filegroup" {
49 return false
50 }
51 labelParts := strings.Split(fullLabel, ":")
52 if len(labelParts) > 2 {
53 // There should not be more than one colon in a label.
Liz Kammer57e2e7a2021-09-20 12:55:02 -040054 ctx.ModuleErrorf("%s is not a valid Bazel label for a filegroup", fullLabel)
Jingwen Chen14a8bda2021-06-02 11:10:02 +000055 }
Liz Kammer57e2e7a2021-09-20 12:55:02 -040056 return m.Name() == labelParts[len(labelParts)-1]
Jingwen Chen14a8bda2021-06-02 11:10:02 +000057 }
58
Liz Kammer57e2e7a2021-09-20 12:55:02 -040059 // Convert filegroup dependencies into extension-specific filegroups filtered in the filegroup.bzl
60 // macro.
61 addSuffixForFilegroup := func(suffix string) bazel.LabelMapper {
62 return func(ctx bazel.OtherModuleContext, label string) (string, bool) {
63 m, exists := ctx.ModuleFromName(label)
64 if !exists {
65 return label, false
Jingwen Chen14a8bda2021-06-02 11:10:02 +000066 }
Chris Parsons5a34ffb2021-07-21 14:34:58 -040067 aModule, _ := m.(android.Module)
Liz Kammer57e2e7a2021-09-20 12:55:02 -040068 if !isFilegroupNamed(aModule, label) {
69 return label, false
Jingwen Chen14a8bda2021-06-02 11:10:02 +000070 }
Liz Kammer57e2e7a2021-09-20 12:55:02 -040071 return label + suffix, true
Chris Parsons5a34ffb2021-07-21 14:34:58 -040072 }
Jingwen Chen14a8bda2021-06-02 11:10:02 +000073 }
74
Liz Kammer57e2e7a2021-09-20 12:55:02 -040075 // TODO(b/190006308): Handle language detection of sources in a Bazel rule.
76 partitioned := bazel.PartitionLabelListAttribute(ctx, &srcs, bazel.LabelPartitions{
77 "c": bazel.LabelPartition{Extensions: []string{".c"}, LabelMapper: addSuffixForFilegroup("_c_srcs")},
78 "as": bazel.LabelPartition{Extensions: []string{".s", ".S"}, LabelMapper: addSuffixForFilegroup("_as_srcs")},
79 // C++ is the "catch-all" group, and comprises generated sources because we don't
80 // know the language of these sources until the genrule is executed.
81 "cpp": bazel.LabelPartition{Extensions: []string{".cpp", ".cc", ".cxx", ".mm"}, LabelMapper: addSuffixForFilegroup("_cpp_srcs"), Keep_remainder: true},
82 })
Jingwen Chen14a8bda2021-06-02 11:10:02 +000083
Liz Kammer57e2e7a2021-09-20 12:55:02 -040084 cSrcs = partitioned["c"]
85 asSrcs = partitioned["as"]
86 cppSrcs = partitioned["cpp"]
Jingwen Chen14a8bda2021-06-02 11:10:02 +000087 return
88}
89
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +000090// bp2BuildParseLibProps returns the attributes for a variant of a cc_library.
91func bp2BuildParseLibProps(ctx android.TopDownMutatorContext, module *Module, isStatic bool) staticOrSharedAttributes {
Jingwen Chen53681ef2021-04-29 08:15:13 +000092 lib, ok := module.compiler.(*libraryDecorator)
93 if !ok {
Liz Kammer2222c6b2021-05-24 15:41:47 -040094 return staticOrSharedAttributes{}
Jingwen Chen53681ef2021-04-29 08:15:13 +000095 }
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +000096 return bp2buildParseStaticOrSharedProps(ctx, module, lib, isStatic)
97}
Jingwen Chen53681ef2021-04-29 08:15:13 +000098
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +000099// bp2buildParseSharedProps returns the attributes for the shared variant of a cc_library.
100func bp2BuildParseSharedProps(ctx android.TopDownMutatorContext, module *Module) staticOrSharedAttributes {
101 return bp2BuildParseLibProps(ctx, module, false)
Jingwen Chen53681ef2021-04-29 08:15:13 +0000102}
103
104// bp2buildParseStaticProps returns the attributes for the static variant of a cc_library.
Liz Kammer2222c6b2021-05-24 15:41:47 -0400105func bp2BuildParseStaticProps(ctx android.TopDownMutatorContext, module *Module) staticOrSharedAttributes {
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000106 return bp2BuildParseLibProps(ctx, module, true)
Liz Kammer2222c6b2021-05-24 15:41:47 -0400107}
108
Liz Kammer7a210ac2021-09-22 15:52:58 -0400109type depsPartition struct {
110 export bazel.LabelList
111 implementation bazel.LabelList
112}
113
114type bazelLabelForDepsFn func(android.TopDownMutatorContext, []string) bazel.LabelList
115
116func partitionExportedAndImplementationsDeps(ctx android.TopDownMutatorContext, allDeps, exportedDeps []string, fn bazelLabelForDepsFn) depsPartition {
117 implementation, export := android.FilterList(allDeps, exportedDeps)
118
119 return depsPartition{
120 export: fn(ctx, export),
121 implementation: fn(ctx, implementation),
122 }
123}
124
125type bazelLabelForDepsExcludesFn func(android.TopDownMutatorContext, []string, []string) bazel.LabelList
126
127func partitionExportedAndImplementationsDepsExcludes(ctx android.TopDownMutatorContext, allDeps, excludes, exportedDeps []string, fn bazelLabelForDepsExcludesFn) depsPartition {
128 implementation, export := android.FilterList(allDeps, exportedDeps)
129
130 return depsPartition{
131 export: fn(ctx, export, excludes),
132 implementation: fn(ctx, implementation, excludes),
133 }
134}
135
Jingwen Chenbcf53042021-05-26 04:42:42 +0000136func bp2buildParseStaticOrSharedProps(ctx android.TopDownMutatorContext, module *Module, lib *libraryDecorator, isStatic bool) staticOrSharedAttributes {
Liz Kammer135bf552021-08-11 10:46:06 -0400137 attrs := staticOrSharedAttributes{}
Jingwen Chenbcf53042021-05-26 04:42:42 +0000138
Liz Kammer9abd62d2021-05-21 08:37:59 -0400139 setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) {
Jingwen Chenc4dc9b42021-06-11 12:51:48 +0000140 attrs.Copts.SetSelectValue(axis, config, props.Cflags)
141 attrs.Srcs.SetSelectValue(axis, config, android.BazelLabelForModuleSrc(ctx, props.Srcs))
Chris Parsons953b3562021-09-20 15:14:39 -0400142 attrs.System_dynamic_deps.SetSelectValue(axis, config, bazelLabelForSharedDeps(ctx, props.System_shared_libs))
Liz Kammer7a210ac2021-09-22 15:52:58 -0400143
144 staticDeps := partitionExportedAndImplementationsDeps(ctx, props.Static_libs, props.Export_static_lib_headers, bazelLabelForStaticDeps)
145 attrs.Deps.SetSelectValue(axis, config, staticDeps.export)
146 attrs.Implementation_deps.SetSelectValue(axis, config, staticDeps.implementation)
147
148 sharedDeps := partitionExportedAndImplementationsDeps(ctx, props.Shared_libs, props.Export_shared_lib_headers, bazelLabelForSharedDeps)
149 attrs.Dynamic_deps.SetSelectValue(axis, config, sharedDeps.export)
150 attrs.Implementation_dynamic_deps.SetSelectValue(axis, config, sharedDeps.implementation)
151
152 attrs.Whole_archive_deps.SetSelectValue(axis, config, bazelLabelForWholeDeps(ctx, props.Whole_static_libs))
Jingwen Chenbcf53042021-05-26 04:42:42 +0000153 }
Liz Kammer135bf552021-08-11 10:46:06 -0400154 // system_dynamic_deps distinguishes between nil/empty list behavior:
155 // nil -> use default values
156 // empty list -> no values specified
157 attrs.System_dynamic_deps.ForceSpecifyEmptyList = true
Jingwen Chenbcf53042021-05-26 04:42:42 +0000158
159 if isStatic {
Liz Kammer9abd62d2021-05-21 08:37:59 -0400160 for axis, configToProps := range module.GetArchVariantProperties(ctx, &StaticProperties{}) {
161 for config, props := range configToProps {
162 if staticOrSharedProps, ok := props.(*StaticProperties); ok {
163 setAttrs(axis, config, staticOrSharedProps.Static)
Jingwen Chenbcf53042021-05-26 04:42:42 +0000164 }
165 }
166 }
167 } else {
Liz Kammer9abd62d2021-05-21 08:37:59 -0400168 for axis, configToProps := range module.GetArchVariantProperties(ctx, &SharedProperties{}) {
169 for config, props := range configToProps {
170 if staticOrSharedProps, ok := props.(*SharedProperties); ok {
171 setAttrs(axis, config, staticOrSharedProps.Shared)
Jingwen Chenbcf53042021-05-26 04:42:42 +0000172 }
173 }
174 }
175 }
176
Jingwen Chenc4dc9b42021-06-11 12:51:48 +0000177 cppSrcs, cSrcs, asSrcs := groupSrcsByExtension(ctx, attrs.Srcs)
178 attrs.Srcs = cppSrcs
179 attrs.Srcs_c = cSrcs
180 attrs.Srcs_as = asSrcs
Jingwen Chen14a8bda2021-06-02 11:10:02 +0000181
Jingwen Chenbcf53042021-05-26 04:42:42 +0000182 return attrs
Jingwen Chen53681ef2021-04-29 08:15:13 +0000183}
184
Rupert Shuttleworthffd45822021-05-14 03:02:34 -0400185// Convenience struct to hold all attributes parsed from prebuilt properties.
186type prebuiltAttributes struct {
187 Src bazel.LabelAttribute
188}
189
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000190// NOTE: Used outside of Soong repo project, in the clangprebuilts.go bootstrap_go_package
Rupert Shuttleworthffd45822021-05-14 03:02:34 -0400191func Bp2BuildParsePrebuiltLibraryProps(ctx android.TopDownMutatorContext, module *Module) prebuiltAttributes {
Rupert Shuttleworthffd45822021-05-14 03:02:34 -0400192 var srcLabelAttribute bazel.LabelAttribute
193
Liz Kammer9abd62d2021-05-21 08:37:59 -0400194 for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltLinkerProperties{}) {
195 for config, props := range configToProps {
Rupert Shuttleworthffd45822021-05-14 03:02:34 -0400196 if prebuiltLinkerProperties, ok := props.(*prebuiltLinkerProperties); ok {
197 if len(prebuiltLinkerProperties.Srcs) > 1 {
Liz Kammer9abd62d2021-05-21 08:37:59 -0400198 ctx.ModuleErrorf("Bp2BuildParsePrebuiltLibraryProps: Expected at most once source file for %s %s\n", axis, config)
199 continue
200 } else if len(prebuiltLinkerProperties.Srcs) == 0 {
201 continue
Rupert Shuttleworthffd45822021-05-14 03:02:34 -0400202 }
Liz Kammer9abd62d2021-05-21 08:37:59 -0400203 src := android.BazelLabelForModuleSrcSingle(ctx, prebuiltLinkerProperties.Srcs[0])
204 srcLabelAttribute.SetSelectValue(axis, config, src)
Rupert Shuttleworthffd45822021-05-14 03:02:34 -0400205 }
206 }
207 }
208
Rupert Shuttleworthffd45822021-05-14 03:02:34 -0400209 return prebuiltAttributes{
210 Src: srcLabelAttribute,
211 }
212}
213
Jingwen Chen107c0de2021-04-09 10:43:12 +0000214// Convenience struct to hold all attributes parsed from compiler properties.
215type compilerAttributes struct {
Chris Parsons990c4f42021-05-25 12:10:58 -0400216 // Options for all languages
217 copts bazel.StringListAttribute
218 // Assembly options and sources
219 asFlags bazel.StringListAttribute
220 asSrcs bazel.LabelListAttribute
221 // C options and sources
222 conlyFlags bazel.StringListAttribute
223 cSrcs bazel.LabelListAttribute
224 // C++ options and sources
225 cppFlags bazel.StringListAttribute
Jingwen Chened9c17d2021-04-13 07:14:55 +0000226 srcs bazel.LabelListAttribute
Chris Parsons2c788392021-08-10 11:58:07 -0400227
228 rtti bazel.BoolAttribute
Jingwen Chen5b11ab12021-10-11 17:44:33 +0000229
230 // Not affected by arch variants
231 stl *string
232 cppStd *string
Liz Kammer35687bc2021-09-10 10:07:07 -0400233
234 localIncludes bazel.StringListAttribute
235 absoluteIncludes bazel.StringListAttribute
Jingwen Chen107c0de2021-04-09 10:43:12 +0000236}
237
Jingwen Chen63930982021-03-24 10:04:33 -0400238// bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes.
Jingwen Chen107c0de2021-04-09 10:43:12 +0000239func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Module) compilerAttributes {
Jingwen Chen882bcc12021-04-27 05:54:20 +0000240 var srcs bazel.LabelListAttribute
Jingwen Chen107c0de2021-04-09 10:43:12 +0000241 var copts bazel.StringListAttribute
Chris Parsons990c4f42021-05-25 12:10:58 -0400242 var asFlags bazel.StringListAttribute
243 var conlyFlags bazel.StringListAttribute
244 var cppFlags bazel.StringListAttribute
Chris Parsons2c788392021-08-10 11:58:07 -0400245 var rtti bazel.BoolAttribute
Liz Kammer35687bc2021-09-10 10:07:07 -0400246 var localIncludes bazel.StringListAttribute
247 var absoluteIncludes bazel.StringListAttribute
Jingwen Chen5b11ab12021-10-11 17:44:33 +0000248 var stl *string = nil
249 var cppStd *string = nil
Jingwen Chened9c17d2021-04-13 07:14:55 +0000250
Chris Parsons990c4f42021-05-25 12:10:58 -0400251 parseCommandLineFlags := func(soongFlags []string) []string {
252 var result []string
253 for _, flag := range soongFlags {
Colin Cross52aa4e12021-05-25 15:20:39 +0000254 // Soong's cflags can contain spaces, like `-include header.h`. For
255 // Bazel's copts, split them up to be compatible with the
256 // no_copts_tokenization feature.
Chris Parsons990c4f42021-05-25 12:10:58 -0400257 result = append(result, strings.Split(flag, " ")...)
Colin Cross52aa4e12021-05-25 15:20:39 +0000258 }
Chris Parsons990c4f42021-05-25 12:10:58 -0400259 return result
260 }
261
Liz Kammer74deed42021-06-02 13:02:03 -0400262 // Parse srcs from an arch or OS's props value.
Jingwen Chene32e9e02021-04-23 09:17:24 +0000263 parseSrcs := func(baseCompilerProps *BaseCompilerProperties) bazel.LabelList {
Chris Parsons484e50a2021-05-13 15:13:04 -0400264 // Add srcs-like dependencies such as generated files.
265 // First create a LabelList containing these dependencies, then merge the values with srcs.
266 generatedHdrsAndSrcs := baseCompilerProps.Generated_headers
267 generatedHdrsAndSrcs = append(generatedHdrsAndSrcs, baseCompilerProps.Generated_sources...)
Chris Parsons484e50a2021-05-13 15:13:04 -0400268 generatedHdrsAndSrcsLabelList := android.BazelLabelForModuleDeps(ctx, generatedHdrsAndSrcs)
269
Liz Kammer74deed42021-06-02 13:02:03 -0400270 allSrcsLabelList := android.BazelLabelForModuleSrcExcludes(ctx, baseCompilerProps.Srcs, baseCompilerProps.Exclude_srcs)
Chris Parsons484e50a2021-05-13 15:13:04 -0400271 return bazel.AppendBazelLabelLists(allSrcsLabelList, generatedHdrsAndSrcsLabelList)
Jingwen Chene32e9e02021-04-23 09:17:24 +0000272 }
273
Liz Kammer9abd62d2021-05-21 08:37:59 -0400274 archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
Liz Kammer9abd62d2021-05-21 08:37:59 -0400275 for axis, configToProps := range archVariantCompilerProps {
276 for config, props := range configToProps {
277 if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok {
278 // If there's arch specific srcs or exclude_srcs, generate a select entry for it.
279 // TODO(b/186153868): do this for OS specific srcs and exclude_srcs too.
280 if len(baseCompilerProps.Srcs) > 0 || len(baseCompilerProps.Exclude_srcs) > 0 {
281 srcsList := parseSrcs(baseCompilerProps)
282 srcs.SetSelectValue(axis, config, srcsList)
Liz Kammer9abd62d2021-05-21 08:37:59 -0400283 }
284
Jingwen Chen97b85312021-10-08 10:41:31 +0000285 if axis == bazel.NoConfigAxis {
286 // If cpp_std is not specified, don't generate it in the
287 // BUILD file. For readability purposes, cpp_std and gnu_extensions are
288 // combined into a single -std=<version> copt, except in the
289 // default case where cpp_std is nil and gnu_extensions is true or unspecified,
290 // then the toolchain's default "gnu++17" will be used.
291 if baseCompilerProps.Cpp_std != nil {
292 // TODO(b/202491296): Handle C_std.
293 // These transformations are shared with compiler.go.
294 cppStdVal := parseCppStd(baseCompilerProps.Cpp_std)
295 _, cppStdVal = maybeReplaceGnuToC(baseCompilerProps.Gnu_extensions, "", cppStdVal)
Jingwen Chen5b11ab12021-10-11 17:44:33 +0000296 cppStd = &cppStdVal
Jingwen Chen97b85312021-10-08 10:41:31 +0000297 } else if baseCompilerProps.Gnu_extensions != nil && !*baseCompilerProps.Gnu_extensions {
Jingwen Chen5b11ab12021-10-11 17:44:33 +0000298 cppStdVal := "c++17"
299 cppStd = &cppStdVal
Jingwen Chen97b85312021-10-08 10:41:31 +0000300 }
301 }
Jingwen Chen5b11ab12021-10-11 17:44:33 +0000302
303 var archVariantCopts []string
Jingwen Chen97b85312021-10-08 10:41:31 +0000304 archVariantCopts = append(archVariantCopts, parseCommandLineFlags(baseCompilerProps.Cflags)...)
Chris Parsons69fa9f92021-07-13 11:47:44 -0400305 archVariantAsflags := parseCommandLineFlags(baseCompilerProps.Asflags)
Liz Kammer35687bc2021-09-10 10:07:07 -0400306
307 localIncludeDirs := baseCompilerProps.Local_include_dirs
308 if axis == bazel.NoConfigAxis && includeBuildDirectory(baseCompilerProps.Include_build_directory) {
309 localIncludeDirs = append(localIncludeDirs, ".")
Chris Parsons69fa9f92021-07-13 11:47:44 -0400310 }
311
Liz Kammer35687bc2021-09-10 10:07:07 -0400312 absoluteIncludes.SetSelectValue(axis, config, baseCompilerProps.Include_dirs)
313 localIncludes.SetSelectValue(axis, config, localIncludeDirs)
Liz Kammer135bf552021-08-11 10:46:06 -0400314
Chris Parsons69fa9f92021-07-13 11:47:44 -0400315 copts.SetSelectValue(axis, config, archVariantCopts)
316 asFlags.SetSelectValue(axis, config, archVariantAsflags)
Liz Kammer9abd62d2021-05-21 08:37:59 -0400317 conlyFlags.SetSelectValue(axis, config, parseCommandLineFlags(baseCompilerProps.Conlyflags))
318 cppFlags.SetSelectValue(axis, config, parseCommandLineFlags(baseCompilerProps.Cppflags))
Chris Parsons2c788392021-08-10 11:58:07 -0400319 rtti.SetSelectValue(axis, config, baseCompilerProps.Rtti)
Liz Kammer9abd62d2021-05-21 08:37:59 -0400320 }
Jingwen Chenc1c26502021-04-05 10:35:13 +0000321 }
322 }
323
Liz Kammer74deed42021-06-02 13:02:03 -0400324 srcs.ResolveExcludes()
Liz Kammer35687bc2021-09-10 10:07:07 -0400325 absoluteIncludes.DeduplicateAxesFromBase()
326 localIncludes.DeduplicateAxesFromBase()
Jingwen Chenc1c26502021-04-05 10:35:13 +0000327
Liz Kammerba7a9c52021-05-26 08:45:30 -0400328 productVarPropNameToAttribute := map[string]*bazel.StringListAttribute{
329 "Cflags": &copts,
330 "Asflags": &asFlags,
331 "CppFlags": &cppFlags,
332 }
Liz Kammer6fd7b3f2021-05-06 13:54:29 -0400333 productVariableProps := android.ProductVariableProperties(ctx)
Liz Kammerba7a9c52021-05-26 08:45:30 -0400334 for propName, attr := range productVarPropNameToAttribute {
335 if props, exists := productVariableProps[propName]; exists {
336 for _, prop := range props {
337 flags, ok := prop.Property.([]string)
338 if !ok {
339 ctx.ModuleErrorf("Could not convert product variable %s property", proptools.PropertyNameForField(propName))
340 }
341 newFlags, _ := bazel.TryVariableSubstitutions(flags, prop.ProductConfigVariable)
Liz Kammer47535c52021-06-02 16:02:22 -0400342 attr.SetSelectValue(bazel.ProductVariableConfigurationAxis(prop.FullConfig), prop.FullConfig, newFlags)
Liz Kammer6fd7b3f2021-05-06 13:54:29 -0400343 }
Liz Kammer6fd7b3f2021-05-06 13:54:29 -0400344 }
345 }
346
Jingwen Chen14a8bda2021-06-02 11:10:02 +0000347 srcs, cSrcs, asSrcs := groupSrcsByExtension(ctx, srcs)
348
Chris Parsonsa967f252021-09-23 16:34:35 -0400349 stlPropsByArch := module.GetArchVariantProperties(ctx, &StlProperties{})
350 for _, configToProps := range stlPropsByArch {
351 for _, props := range configToProps {
352 if stlProps, ok := props.(*StlProperties); ok {
353 if stlProps.Stl != nil {
354 if stl == nil {
355 stl = stlProps.Stl
356 } else {
357 if stl != stlProps.Stl {
358 ctx.ModuleErrorf("Unsupported conversion: module with different stl for different variants: %s and %s", *stl, stlProps.Stl)
359 }
360 }
361 }
362 }
363 }
364 }
365
Jingwen Chen107c0de2021-04-09 10:43:12 +0000366 return compilerAttributes{
Liz Kammer35687bc2021-09-10 10:07:07 -0400367 copts: copts,
368 srcs: srcs,
369 asFlags: asFlags,
370 asSrcs: asSrcs,
371 cSrcs: cSrcs,
372 conlyFlags: conlyFlags,
373 cppFlags: cppFlags,
374 rtti: rtti,
Chris Parsonsa967f252021-09-23 16:34:35 -0400375 stl: stl,
Jingwen Chen5b11ab12021-10-11 17:44:33 +0000376 cppStd: cppStd,
Liz Kammer35687bc2021-09-10 10:07:07 -0400377 localIncludes: localIncludes,
378 absoluteIncludes: absoluteIncludes,
Jingwen Chen107c0de2021-04-09 10:43:12 +0000379 }
380}
381
382// Convenience struct to hold all attributes parsed from linker properties.
383type linkerAttributes struct {
Liz Kammer7a210ac2021-09-22 15:52:58 -0400384 deps bazel.LabelListAttribute
385 implementationDeps bazel.LabelListAttribute
386 dynamicDeps bazel.LabelListAttribute
387 implementationDynamicDeps bazel.LabelListAttribute
388 wholeArchiveDeps bazel.LabelListAttribute
389 systemDynamicDeps bazel.LabelListAttribute
390
Jingwen Chen6ada5892021-09-17 11:38:09 +0000391 linkCrt bazel.BoolAttribute
Jingwen Chen3d383bb2021-06-09 07:18:37 +0000392 useLibcrt bazel.BoolAttribute
393 linkopts bazel.StringListAttribute
394 versionScript bazel.LabelAttribute
395 stripKeepSymbols bazel.BoolAttribute
396 stripKeepSymbolsAndDebugFrame bazel.BoolAttribute
397 stripKeepSymbolsList bazel.StringListAttribute
398 stripAll bazel.BoolAttribute
399 stripNone bazel.BoolAttribute
Liz Kammer0eae52e2021-10-06 10:32:26 -0400400 features bazel.StringListAttribute
Rupert Shuttleworth143be942021-05-09 23:55:51 -0400401}
402
Lukacs T. Berki1353e592021-04-30 15:35:09 +0200403// bp2BuildParseLinkerProps parses the linker properties of a module, including
Jingwen Chen91220d72021-03-24 02:18:33 -0400404// configurable attribute values.
Jingwen Chen107c0de2021-04-09 10:43:12 +0000405func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module) linkerAttributes {
Liz Kammer7a210ac2021-09-22 15:52:58 -0400406
Liz Kammer47535c52021-06-02 16:02:22 -0400407 var headerDeps bazel.LabelListAttribute
Liz Kammer7a210ac2021-09-22 15:52:58 -0400408 var implementationHeaderDeps bazel.LabelListAttribute
409 var deps bazel.LabelListAttribute
410 var implementationDeps bazel.LabelListAttribute
Rupert Shuttleworthc50fa8d2021-05-06 02:40:33 -0400411 var dynamicDeps bazel.LabelListAttribute
Liz Kammer7a210ac2021-09-22 15:52:58 -0400412 var implementationDynamicDeps bazel.LabelListAttribute
Chris Parsons08648312021-05-06 16:23:19 -0400413 var wholeArchiveDeps bazel.LabelListAttribute
Liz Kammer135bf552021-08-11 10:46:06 -0400414 systemSharedDeps := bazel.LabelListAttribute{ForceSpecifyEmptyList: true}
Liz Kammer7a210ac2021-09-22 15:52:58 -0400415
Jingwen Chen63930982021-03-24 10:04:33 -0400416 var linkopts bazel.StringListAttribute
Lukacs T. Berki1353e592021-04-30 15:35:09 +0200417 var versionScript bazel.LabelAttribute
Jingwen Chen6ada5892021-09-17 11:38:09 +0000418 var linkCrt bazel.BoolAttribute
Liz Kammerd366c902021-06-03 13:43:01 -0400419 var useLibcrt bazel.BoolAttribute
Jingwen Chen63930982021-03-24 10:04:33 -0400420
Jingwen Chen3d383bb2021-06-09 07:18:37 +0000421 var stripKeepSymbols bazel.BoolAttribute
422 var stripKeepSymbolsAndDebugFrame bazel.BoolAttribute
423 var stripKeepSymbolsList bazel.StringListAttribute
424 var stripAll bazel.BoolAttribute
425 var stripNone bazel.BoolAttribute
426
Liz Kammer0eae52e2021-10-06 10:32:26 -0400427 var features bazel.StringListAttribute
428
Jingwen Chen3d383bb2021-06-09 07:18:37 +0000429 for axis, configToProps := range module.GetArchVariantProperties(ctx, &StripProperties{}) {
430 for config, props := range configToProps {
431 if stripProperties, ok := props.(*StripProperties); ok {
432 stripKeepSymbols.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols)
433 stripKeepSymbolsList.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_list)
434 stripKeepSymbolsAndDebugFrame.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_and_debug_frame)
435 stripAll.SetSelectValue(axis, config, stripProperties.Strip.All)
436 stripNone.SetSelectValue(axis, config, stripProperties.Strip.None)
437 }
438 }
439 }
440
Jingwen Chen6ada5892021-09-17 11:38:09 +0000441 // Use a single variable to capture usage of nocrt in arch variants, so there's only 1 error message for this module
442 var disallowedArchVariantCrt bool
443
Liz Kammer9abd62d2021-05-21 08:37:59 -0400444 for axis, configToProps := range module.GetArchVariantProperties(ctx, &BaseLinkerProperties{}) {
445 for config, props := range configToProps {
446 if baseLinkerProps, ok := props.(*BaseLinkerProperties); ok {
Liz Kammer0eae52e2021-10-06 10:32:26 -0400447 var axisFeatures []string
Liz Kammer7a210ac2021-09-22 15:52:58 -0400448
Liz Kammer135bf552021-08-11 10:46:06 -0400449 // Excludes to parallel Soong:
450 // https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/linker.go;l=247-249;drc=088b53577dde6e40085ffd737a1ae96ad82fc4b0
Liz Kammer47535c52021-06-02 16:02:22 -0400451 staticLibs := android.FirstUniqueStrings(baseLinkerProps.Static_libs)
Liz Kammer7a210ac2021-09-22 15:52:58 -0400452 staticDeps := partitionExportedAndImplementationsDepsExcludes(ctx, staticLibs, baseLinkerProps.Exclude_static_libs, baseLinkerProps.Export_static_lib_headers, bazelLabelForStaticDepsExcludes)
453 deps.SetSelectValue(axis, config, staticDeps.export)
454 implementationDeps.SetSelectValue(axis, config, staticDeps.implementation)
455
456 wholeStaticLibs := android.FirstUniqueStrings(baseLinkerProps.Whole_static_libs)
457 wholeArchiveDeps.SetSelectValue(axis, config, bazelLabelForWholeDepsExcludes(ctx, wholeStaticLibs, baseLinkerProps.Exclude_static_libs))
Chris Parsons51f8c392021-08-03 21:01:05 -0400458
Liz Kammer135bf552021-08-11 10:46:06 -0400459 systemSharedLibs := baseLinkerProps.System_shared_libs
460 // systemSharedLibs distinguishes between nil/empty list behavior:
461 // nil -> use default values
462 // empty list -> no values specified
463 if len(systemSharedLibs) > 0 {
464 systemSharedLibs = android.FirstUniqueStrings(systemSharedLibs)
Chris Parsons51f8c392021-08-03 21:01:05 -0400465 }
Chris Parsons953b3562021-09-20 15:14:39 -0400466 systemSharedDeps.SetSelectValue(axis, config, bazelLabelForSharedDeps(ctx, systemSharedLibs))
Chris Parsons51f8c392021-08-03 21:01:05 -0400467
468 sharedLibs := android.FirstUniqueStrings(baseLinkerProps.Shared_libs)
Liz Kammer7a210ac2021-09-22 15:52:58 -0400469 sharedDeps := partitionExportedAndImplementationsDepsExcludes(ctx, sharedLibs, baseLinkerProps.Exclude_shared_libs, baseLinkerProps.Export_shared_lib_headers, bazelLabelForSharedDepsExcludes)
470 dynamicDeps.SetSelectValue(axis, config, sharedDeps.export)
471 implementationDynamicDeps.SetSelectValue(axis, config, sharedDeps.implementation)
Rupert Shuttleworthc194ffb2021-05-19 06:49:02 -0400472
Liz Kammer47535c52021-06-02 16:02:22 -0400473 headerLibs := android.FirstUniqueStrings(baseLinkerProps.Header_libs)
Liz Kammer7a210ac2021-09-22 15:52:58 -0400474 hDeps := partitionExportedAndImplementationsDeps(ctx, headerLibs, baseLinkerProps.Export_header_lib_headers, bazelLabelForHeaderDeps)
475
476 headerDeps.SetSelectValue(axis, config, hDeps.export)
477 implementationHeaderDeps.SetSelectValue(axis, config, hDeps.implementation)
Liz Kammer47535c52021-06-02 16:02:22 -0400478
Liz Kammer0eae52e2021-10-06 10:32:26 -0400479 linkopts.SetSelectValue(axis, config, baseLinkerProps.Ldflags)
480 if !BoolDefault(baseLinkerProps.Pack_relocations, packRelocationsDefault) {
481 axisFeatures = append(axisFeatures, "disable_pack_relocations")
482 }
483
484 if Bool(baseLinkerProps.Allow_undefined_symbols) {
485 axisFeatures = append(axisFeatures, "-no_undefined_symbols")
486 }
487
Rupert Shuttleworth22cd2eb2021-05-27 02:15:54 -0400488 if baseLinkerProps.Version_script != nil {
Liz Kammer9abd62d2021-05-21 08:37:59 -0400489 versionScript.SetSelectValue(axis, config, android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script))
Rupert Shuttleworth22cd2eb2021-05-27 02:15:54 -0400490 }
Liz Kammerd366c902021-06-03 13:43:01 -0400491 useLibcrt.SetSelectValue(axis, config, baseLinkerProps.libCrt())
Jingwen Chen6ada5892021-09-17 11:38:09 +0000492
493 // it's very unlikely for nocrt to be arch variant, so bp2build doesn't support it.
494 if baseLinkerProps.crt() != nil {
495 if axis == bazel.NoConfigAxis {
496 linkCrt.SetSelectValue(axis, config, baseLinkerProps.crt())
497 } else if axis == bazel.ArchConfigurationAxis {
498 disallowedArchVariantCrt = true
499 }
500 }
Liz Kammer0eae52e2021-10-06 10:32:26 -0400501
502 if axisFeatures != nil {
503 features.SetSelectValue(axis, config, axisFeatures)
504 }
Rupert Shuttleworthc194ffb2021-05-19 06:49:02 -0400505 }
Jingwen Chen91220d72021-03-24 02:18:33 -0400506 }
507 }
508
Jingwen Chen6ada5892021-09-17 11:38:09 +0000509 if disallowedArchVariantCrt {
510 ctx.ModuleErrorf("nocrt is not supported for arch variants")
511 }
512
Liz Kammer47535c52021-06-02 16:02:22 -0400513 type productVarDep struct {
514 // the name of the corresponding excludes field, if one exists
515 excludesField string
516 // reference to the bazel attribute that should be set for the given product variable config
517 attribute *bazel.LabelListAttribute
Liz Kammer2d7bbe32021-06-10 18:20:06 -0400518
Chris Parsons953b3562021-09-20 15:14:39 -0400519 depResolutionFunc func(ctx android.TopDownMutatorContext, modules, excludes []string) bazel.LabelList
Liz Kammer47535c52021-06-02 16:02:22 -0400520 }
521
522 productVarToDepFields := map[string]productVarDep{
523 // product variables do not support exclude_shared_libs
Liz Kammer7a210ac2021-09-22 15:52:58 -0400524 "Shared_libs": productVarDep{attribute: &implementationDynamicDeps, depResolutionFunc: bazelLabelForSharedDepsExcludes},
525 "Static_libs": productVarDep{"Exclude_static_libs", &implementationDeps, bazelLabelForStaticDepsExcludes},
Chris Parsons953b3562021-09-20 15:14:39 -0400526 "Whole_static_libs": productVarDep{"Exclude_static_libs", &wholeArchiveDeps, bazelLabelForWholeDepsExcludes},
Liz Kammer47535c52021-06-02 16:02:22 -0400527 }
528
529 productVariableProps := android.ProductVariableProperties(ctx)
530 for name, dep := range productVarToDepFields {
531 props, exists := productVariableProps[name]
532 excludeProps, excludesExists := productVariableProps[dep.excludesField]
533 // if neither an include or excludes property exists, then skip it
534 if !exists && !excludesExists {
535 continue
536 }
537 // collect all the configurations that an include or exclude property exists for.
538 // we want to iterate all configurations rather than either the include or exclude because for a
539 // particular configuration we may have only and include or only an exclude to handle
540 configs := make(map[string]bool, len(props)+len(excludeProps))
541 for config := range props {
542 configs[config] = true
543 }
544 for config := range excludeProps {
545 configs[config] = true
546 }
547
548 for config := range configs {
549 prop, includesExists := props[config]
550 excludesProp, excludesExists := excludeProps[config]
551 var includes, excludes []string
552 var ok bool
553 // if there was no includes/excludes property, casting fails and that's expected
554 if includes, ok = prop.Property.([]string); includesExists && !ok {
555 ctx.ModuleErrorf("Could not convert product variable %s property", name)
556 }
557 if excludes, ok = excludesProp.Property.([]string); excludesExists && !ok {
558 ctx.ModuleErrorf("Could not convert product variable %s property", dep.excludesField)
559 }
Liz Kammer2d7bbe32021-06-10 18:20:06 -0400560
561 dep.attribute.SetSelectValue(bazel.ProductVariableConfigurationAxis(config), config, dep.depResolutionFunc(ctx, android.FirstUniqueStrings(includes), excludes))
Liz Kammer47535c52021-06-02 16:02:22 -0400562 }
563 }
564
Liz Kammer7a210ac2021-09-22 15:52:58 -0400565 headerDeps.Append(deps)
566 implementationHeaderDeps.Append(implementationDeps)
567
568 headerDeps.ResolveExcludes()
569 implementationHeaderDeps.ResolveExcludes()
Liz Kammer47535c52021-06-02 16:02:22 -0400570 dynamicDeps.ResolveExcludes()
Liz Kammer7a210ac2021-09-22 15:52:58 -0400571 implementationDynamicDeps.ResolveExcludes()
Liz Kammer47535c52021-06-02 16:02:22 -0400572 wholeArchiveDeps.ResolveExcludes()
573
Jingwen Chen107c0de2021-04-09 10:43:12 +0000574 return linkerAttributes{
Liz Kammer7a210ac2021-09-22 15:52:58 -0400575 deps: headerDeps,
576 implementationDeps: implementationHeaderDeps,
577 dynamicDeps: dynamicDeps,
578 implementationDynamicDeps: implementationDynamicDeps,
579 wholeArchiveDeps: wholeArchiveDeps,
580 systemDynamicDeps: systemSharedDeps,
581
Jingwen Chen6ada5892021-09-17 11:38:09 +0000582 linkCrt: linkCrt,
Liz Kammer7a210ac2021-09-22 15:52:58 -0400583 linkopts: linkopts,
584 useLibcrt: useLibcrt,
585 versionScript: versionScript,
Jingwen Chen3d383bb2021-06-09 07:18:37 +0000586
587 // Strip properties
588 stripKeepSymbols: stripKeepSymbols,
589 stripKeepSymbolsAndDebugFrame: stripKeepSymbolsAndDebugFrame,
590 stripKeepSymbolsList: stripKeepSymbolsList,
591 stripAll: stripAll,
592 stripNone: stripNone,
Liz Kammer0eae52e2021-10-06 10:32:26 -0400593
594 features: features,
Jingwen Chen107c0de2021-04-09 10:43:12 +0000595 }
Jingwen Chen91220d72021-03-24 02:18:33 -0400596}
597
Jingwen Chened9c17d2021-04-13 07:14:55 +0000598// Relativize a list of root-relative paths with respect to the module's
599// directory.
600//
601// include_dirs Soong prop are root-relative (b/183742505), but
602// local_include_dirs, export_include_dirs and export_system_include_dirs are
603// module dir relative. This function makes a list of paths entirely module dir
604// relative.
605//
606// For the `include` attribute, Bazel wants the paths to be relative to the
607// module.
608func bp2BuildMakePathsRelativeToModule(ctx android.BazelConversionPathContext, paths []string) []string {
Rupert Shuttleworthb8151682021-04-06 20:06:21 +0000609 var relativePaths []string
610 for _, path := range paths {
Jingwen Chened9c17d2021-04-13 07:14:55 +0000611 // Semantics of filepath.Rel: join(ModuleDir, rel(ModuleDir, path)) == path
612 relativePath, err := filepath.Rel(ctx.ModuleDir(), path)
613 if err != nil {
614 panic(err)
615 }
Rupert Shuttleworthb8151682021-04-06 20:06:21 +0000616 relativePaths = append(relativePaths, relativePath)
617 }
618 return relativePaths
619}
620
Liz Kammer5fad5012021-09-09 14:08:21 -0400621// BazelIncludes contains information about -I and -isystem paths from a module converted to Bazel
622// attributes.
623type BazelIncludes struct {
624 Includes bazel.StringListAttribute
625 SystemIncludes bazel.StringListAttribute
626}
627
628func bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Module) BazelIncludes {
Jingwen Chen91220d72021-03-24 02:18:33 -0400629 libraryDecorator := module.linker.(*libraryDecorator)
Rupert Shuttleworthffd45822021-05-14 03:02:34 -0400630 return bp2BuildParseExportedIncludesHelper(ctx, module, libraryDecorator)
631}
Jingwen Chen91220d72021-03-24 02:18:33 -0400632
Liz Kammer5fad5012021-09-09 14:08:21 -0400633// Bp2buildParseExportedIncludesForPrebuiltLibrary returns a BazelIncludes with Bazel-ified values
634// to export includes from the underlying module's properties.
635func Bp2BuildParseExportedIncludesForPrebuiltLibrary(ctx android.TopDownMutatorContext, module *Module) BazelIncludes {
Rupert Shuttleworthffd45822021-05-14 03:02:34 -0400636 prebuiltLibraryLinker := module.linker.(*prebuiltLibraryLinker)
637 libraryDecorator := prebuiltLibraryLinker.libraryDecorator
638 return bp2BuildParseExportedIncludesHelper(ctx, module, libraryDecorator)
639}
640
641// bp2BuildParseExportedIncludes creates a string list attribute contains the
642// exported included directories of a module.
Liz Kammer5fad5012021-09-09 14:08:21 -0400643func bp2BuildParseExportedIncludesHelper(ctx android.TopDownMutatorContext, module *Module, libraryDecorator *libraryDecorator) BazelIncludes {
644 exported := BazelIncludes{}
Liz Kammer9abd62d2021-05-21 08:37:59 -0400645 for axis, configToProps := range module.GetArchVariantProperties(ctx, &FlagExporterProperties{}) {
646 for config, props := range configToProps {
647 if flagExporterProperties, ok := props.(*FlagExporterProperties); ok {
Liz Kammer5fad5012021-09-09 14:08:21 -0400648 if len(flagExporterProperties.Export_include_dirs) > 0 {
649 exported.Includes.SetSelectValue(axis, config, flagExporterProperties.Export_include_dirs)
650 }
651 if len(flagExporterProperties.Export_system_include_dirs) > 0 {
652 exported.SystemIncludes.SetSelectValue(axis, config, flagExporterProperties.Export_system_include_dirs)
Rupert Shuttleworthc194ffb2021-05-19 06:49:02 -0400653 }
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400654 }
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400655 }
656 }
Liz Kammer5fad5012021-09-09 14:08:21 -0400657 exported.Includes.DeduplicateAxesFromBase()
658 exported.SystemIncludes.DeduplicateAxesFromBase()
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400659
Liz Kammer5fad5012021-09-09 14:08:21 -0400660 return exported
Jingwen Chen91220d72021-03-24 02:18:33 -0400661}
Chris Parsons953b3562021-09-20 15:14:39 -0400662
663func bazelLabelForStaticModule(ctx android.TopDownMutatorContext, m blueprint.Module) string {
664 label := android.BazelModuleLabel(ctx, m)
665 if aModule, ok := m.(android.Module); ok {
666 if ctx.OtherModuleType(aModule) == "cc_library" && !android.GenerateCcLibraryStaticOnly(m.Name()) {
667 label += "_bp2build_cc_library_static"
668 }
669 }
670 return label
671}
672
673func bazelLabelForSharedModule(ctx android.TopDownMutatorContext, m blueprint.Module) string {
674 // cc_library, at it's root name, propagates the shared library, which depends on the static
675 // library.
676 return android.BazelModuleLabel(ctx, m)
677}
678
679func bazelLabelForStaticWholeModuleDeps(ctx android.TopDownMutatorContext, m blueprint.Module) string {
680 label := bazelLabelForStaticModule(ctx, m)
681 if aModule, ok := m.(android.Module); ok {
682 if android.IsModulePrebuilt(aModule) {
683 label += "_alwayslink"
684 }
685 }
686 return label
687}
688
689func bazelLabelForWholeDeps(ctx android.TopDownMutatorContext, modules []string) bazel.LabelList {
690 return android.BazelLabelForModuleDepsWithFn(ctx, modules, bazelLabelForStaticWholeModuleDeps)
691}
692
693func bazelLabelForWholeDepsExcludes(ctx android.TopDownMutatorContext, modules, excludes []string) bazel.LabelList {
694 return android.BazelLabelForModuleDepsExcludesWithFn(ctx, modules, excludes, bazelLabelForStaticWholeModuleDeps)
695}
696
697func bazelLabelForStaticDepsExcludes(ctx android.TopDownMutatorContext, modules, excludes []string) bazel.LabelList {
698 return android.BazelLabelForModuleDepsExcludesWithFn(ctx, modules, excludes, bazelLabelForStaticModule)
699}
700
701func bazelLabelForStaticDeps(ctx android.TopDownMutatorContext, modules []string) bazel.LabelList {
702 return android.BazelLabelForModuleDepsWithFn(ctx, modules, bazelLabelForStaticModule)
703}
704
705func bazelLabelForSharedDeps(ctx android.TopDownMutatorContext, modules []string) bazel.LabelList {
706 return android.BazelLabelForModuleDepsWithFn(ctx, modules, bazelLabelForSharedModule)
707}
708
709func bazelLabelForHeaderDeps(ctx android.TopDownMutatorContext, modules []string) bazel.LabelList {
710 // This is not elegant, but bp2build's shared library targets only propagate
711 // their header information as part of the normal C++ provider.
712 return bazelLabelForSharedDeps(ctx, modules)
713}
714
715func bazelLabelForSharedDepsExcludes(ctx android.TopDownMutatorContext, modules, excludes []string) bazel.LabelList {
716 return android.BazelLabelForModuleDepsExcludesWithFn(ctx, modules, excludes, bazelLabelForSharedModule)
717}