Merge "Rollforward "Split asm and c flags and srcs in...""
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 454b153..350bac1 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -41,6 +41,7 @@
)
func runCcLibraryTestCase(t *testing.T, tc bp2buildTestCase) {
+ t.Helper()
runBp2BuildTestCase(t, registerCcLibraryModuleTypes, tc)
}
@@ -52,6 +53,7 @@
}
func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.RegistrationContext), tc bp2buildTestCase) {
+ t.Helper()
dir := "."
filesystem := make(map[string][]byte)
toParse := []string{
diff --git a/bp2build/cc_library_headers_conversion_test.go b/bp2build/cc_library_headers_conversion_test.go
index 2859bab..264ba6b 100644
--- a/bp2build/cc_library_headers_conversion_test.go
+++ b/bp2build/cc_library_headers_conversion_test.go
@@ -84,6 +84,7 @@
}
func runCcLibraryHeadersTestCase(t *testing.T, tc bp2buildTestCase) {
+ t.Helper()
runBp2BuildTestCase(t, registerCcLibraryHeadersModuleTypes, tc)
}
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 6c6b39f..b7245a7 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -76,6 +76,7 @@
}
func runCcLibraryStaticTestCase(t *testing.T, tc bp2buildTestCase) {
+ t.Helper()
runBp2BuildTestCase(t, registerCcLibraryStaticModuleTypes, tc)
}
diff --git a/bp2build/cc_object_conversion_test.go b/bp2build/cc_object_conversion_test.go
index d4eeb7c..f7e94c2 100644
--- a/bp2build/cc_object_conversion_test.go
+++ b/bp2build/cc_object_conversion_test.go
@@ -27,6 +27,7 @@
}
func runCcObjectTestCase(t *testing.T, tc bp2buildTestCase) {
+ t.Helper()
runBp2BuildTestCase(t, registerCcObjectModuleTypes, tc)
}
diff --git a/bp2build/python_binary_conversion_test.go b/bp2build/python_binary_conversion_test.go
index 95bce3c..7bedf71 100644
--- a/bp2build/python_binary_conversion_test.go
+++ b/bp2build/python_binary_conversion_test.go
@@ -8,6 +8,7 @@
)
func runPythonTestCase(t *testing.T, tc bp2buildTestCase) {
+ t.Helper()
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
}
diff --git a/bp2build/sh_conversion_test.go b/bp2build/sh_conversion_test.go
index 91bba54..82e0a14 100644
--- a/bp2build/sh_conversion_test.go
+++ b/bp2build/sh_conversion_test.go
@@ -49,6 +49,7 @@
}
func runShBinaryTestCase(t *testing.T, tc bp2buildTestCase) {
+ t.Helper()
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index e417c69..9bf101e 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -105,7 +105,9 @@
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 @@
}
// 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,