summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Liz Kammer <eakammer@google.com> 2021-05-24 15:41:47 -0400
committer Liz Kammer <eakammer@google.com> 2021-05-25 08:28:43 -0400
commit2222c6bb4298920fc78f1af51ca28a449b33e501 (patch)
treecff926546b51d819d1461d16f4e48b77f2d7e720
parent32cf58a8fcfc043246a9c402b32c863e8aebc499 (diff)
Combine bp2build handling of static/shared props
Test: go test soong tests Change-Id: I793f88bcbad2cdee042c6b2d17104e9ca03602b9
-rw-r--r--cc/bp2build.go58
1 files changed, 18 insertions, 40 deletions
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 95a3fe157..f18829b1d 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -105,7 +105,9 @@ func depsBp2BuildMutator(ctx android.BottomUpMutatorContext) {
ctx.AddDependency(module, nil, android.SortedUniqueStrings(allDeps)...)
}
-type sharedAttributes struct {
+// staticOrSharedAttributes are the Bazel-ified versions of StaticOrSharedProperties --
+// properities which apply to either the shared or static version of a cc_library module.
+type staticOrSharedAttributes struct {
copts bazel.StringListAttribute
srcs bazel.LabelListAttribute
staticDeps bazel.LabelListAttribute
@@ -114,65 +116,41 @@ type sharedAttributes struct {
}
// bp2buildParseSharedProps returns the attributes for the shared variant of a cc_library.
-func bp2BuildParseSharedProps(ctx android.TopDownMutatorContext, module *Module) sharedAttributes {
+func bp2BuildParseSharedProps(ctx android.TopDownMutatorContext, module *Module) staticOrSharedAttributes {
lib, ok := module.compiler.(*libraryDecorator)
if !ok {
- return sharedAttributes{}
+ return staticOrSharedAttributes{}
}
- copts := bazel.StringListAttribute{Value: lib.SharedProperties.Shared.Cflags}
-
- srcs := bazel.LabelListAttribute{
- Value: android.BazelLabelForModuleSrc(ctx, lib.SharedProperties.Shared.Srcs)}
-
- staticDeps := bazel.LabelListAttribute{
- Value: android.BazelLabelForModuleDeps(ctx, lib.SharedProperties.Shared.Static_libs)}
-
- dynamicDeps := bazel.LabelListAttribute{
- Value: android.BazelLabelForModuleDeps(ctx, lib.SharedProperties.Shared.Shared_libs)}
-
- wholeArchiveDeps := bazel.LabelListAttribute{
- Value: android.BazelLabelForModuleDeps(ctx, lib.SharedProperties.Shared.Whole_static_libs)}
-
- return sharedAttributes{
- copts: copts,
- srcs: srcs,
- staticDeps: staticDeps,
- dynamicDeps: dynamicDeps,
- wholeArchiveDeps: wholeArchiveDeps,
- }
-}
-
-type staticAttributes struct {
- copts bazel.StringListAttribute
- srcs bazel.LabelListAttribute
- staticDeps bazel.LabelListAttribute
- dynamicDeps bazel.LabelListAttribute
- wholeArchiveDeps bazel.LabelListAttribute
+ return bp2buildParseStaticOrSharedProps(ctx, lib.SharedProperties.Shared)
}
// bp2buildParseStaticProps returns the attributes for the static variant of a cc_library.
-func bp2BuildParseStaticProps(ctx android.TopDownMutatorContext, module *Module) staticAttributes {
+func bp2BuildParseStaticProps(ctx android.TopDownMutatorContext, module *Module) staticOrSharedAttributes {
lib, ok := module.compiler.(*libraryDecorator)
if !ok {
- return staticAttributes{}
+ return staticOrSharedAttributes{}
}
- copts := bazel.StringListAttribute{Value: lib.StaticProperties.Static.Cflags}
+ return bp2buildParseStaticOrSharedProps(ctx, lib.StaticProperties.Static)
+}
+
+func bp2buildParseStaticOrSharedProps(ctx android.TopDownMutatorContext, props StaticOrSharedProperties) staticOrSharedAttributes {
+ copts := bazel.StringListAttribute{Value: props.Cflags}
srcs := bazel.LabelListAttribute{
- Value: android.BazelLabelForModuleSrc(ctx, lib.StaticProperties.Static.Srcs)}
+ Value: android.BazelLabelForModuleSrc(ctx, props.Srcs)}
staticDeps := bazel.LabelListAttribute{
- Value: android.BazelLabelForModuleDeps(ctx, lib.StaticProperties.Static.Static_libs)}
+ Value: android.BazelLabelForModuleDeps(ctx, props.Static_libs)}
dynamicDeps := bazel.LabelListAttribute{
- Value: android.BazelLabelForModuleDeps(ctx, lib.StaticProperties.Static.Shared_libs)}
+ Value: android.BazelLabelForModuleDeps(ctx, props.Shared_libs)}
wholeArchiveDeps := bazel.LabelListAttribute{
- Value: android.BazelLabelForModuleDeps(ctx, lib.StaticProperties.Static.Whole_static_libs)}
+ Value: android.BazelLabelForModuleDeps(ctx, props.Whole_static_libs)}
- return staticAttributes{
+ return staticOrSharedAttributes{
copts: copts,
srcs: srcs,
staticDeps: staticDeps,