bp2build: refactor compiler/linker prop function.
This changes the return value into a compiler/linker attr struct to
standardize callsites and make it easier to retrieve the parsed attrs.
Test: TH
Change-Id: I1e3956e7cb5d924ce8472ece940faea459beef37
diff --git a/cc/bp2build.go b/cc/bp2build.go
index e7e4aa8..0bca30a 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -59,13 +59,17 @@
ctx.AddDependency(module, nil, android.SortedUniqueStrings(allDeps)...)
}
+// Convenience struct to hold all attributes parsed from compiler properties.
+type compilerAttributes struct {
+ copts bazel.StringListAttribute
+ srcs bazel.LabelListAttribute
+ hdrs bazel.LabelListAttribute
+}
+
// bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes.
-func bp2BuildParseCompilerProps(
- ctx android.TopDownMutatorContext,
- module *Module) (
- copts bazel.StringListAttribute,
- srcs bazel.LabelListAttribute,
- hdrs bazel.LabelListAttribute) {
+func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Module) compilerAttributes {
+ var hdrs, srcs bazel.LabelListAttribute
+ var copts bazel.StringListAttribute
hdrsAndSrcs := func(baseCompilerProps *BaseCompilerProperties) (bazel.LabelList, bazel.LabelList) {
srcsList := android.BazelLabelForModuleSrcExcludes(
@@ -100,13 +104,22 @@
}
}
- return copts, srcs, hdrs
+ return compilerAttributes{
+ hdrs: hdrs,
+ srcs: srcs,
+ copts: copts,
+ }
+}
+
+// Convenience struct to hold all attributes parsed from linker properties.
+type linkerAttributes struct {
+ deps bazel.LabelListAttribute
+ linkopts bazel.StringListAttribute
}
// bp2BuildParseLinkerProps creates a label list attribute containing the header library deps of a module, including
// configurable attribute values.
-func bp2BuildParseLinkerProps(
- ctx android.TopDownMutatorContext, module *Module) (bazel.LabelListAttribute, bazel.StringListAttribute) {
+func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module) linkerAttributes {
var deps bazel.LabelListAttribute
var linkopts bazel.StringListAttribute
@@ -142,7 +155,10 @@
}
}
- return deps, linkopts
+ return linkerAttributes{
+ deps: deps,
+ linkopts: linkopts,
+ }
}
func bp2BuildListHeadersInDir(ctx android.TopDownMutatorContext, includeDir string) bazel.LabelList {