Loading apex/apex.go +3 −3 Original line number Diff line number Diff line Loading @@ -3201,7 +3201,7 @@ type bazelApexBundleAttributes struct { File_contexts bazel.LabelAttribute Key bazel.LabelAttribute Certificate bazel.LabelAttribute Min_sdk_version string Min_sdk_version *string Updatable bazel.BoolAttribute Installable bazel.BoolAttribute Native_shared_libs bazel.LabelListAttribute Loading Loading @@ -3241,9 +3241,9 @@ func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexB fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.properties.File_contexts)) } var minSdkVersion string var minSdkVersion *string if module.properties.Min_sdk_version != nil { minSdkVersion = *module.properties.Min_sdk_version minSdkVersion = module.properties.Min_sdk_version } var keyLabelAttribute bazel.LabelAttribute Loading bp2build/build_conversion.go +3 −3 Original line number Diff line number Diff line Loading @@ -698,9 +698,9 @@ func isZero(value reflect.Value) bool { } else { return true } // Always print bools, if you want a bool attribute to be able to take the default value, use a // bool pointer instead case reflect.Bool: // Always print bool/strings, if you want a bool/string attribute to be able to take the default value, use a // pointer instead case reflect.Bool, reflect.String: return false default: if !value.IsValid() { Loading bp2build/build_conversion_test.go +24 −4 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { soong_module_deps = [ ], bool_prop = False, string_prop = "", )`, }, { Loading @@ -58,6 +59,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { soong_module_deps = [ ], bool_prop = True, string_prop = "", )`, }, { Loading @@ -76,6 +78,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { ], bool_prop = False, owner = "a_string_with\"quotes\"_and_\\backslashes\\\\", string_prop = "", )`, }, { Loading @@ -94,6 +97,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { ], bool_prop = False, required = ["bar"], string_prop = "", )`, }, { Loading @@ -111,6 +115,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { soong_module_deps = [ ], bool_prop = False, string_prop = "", target_required = [ "qux", "bazqux", Loading Loading @@ -147,6 +152,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { "tag": ".bar", "targets": ["goal_bar"], }], string_prop = "", )`, }, { Loading Loading @@ -179,6 +185,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { }], owner = "custom_owner", required = ["bar"], string_prop = "", target_required = [ "qux", "bazqux", Loading Loading @@ -222,12 +229,25 @@ func TestGenerateSoongModuleTargets(t *testing.T) { func TestGenerateBazelTargetModules(t *testing.T) { testCases := []bp2buildTestCase{ { description: "string ptr props", blueprint: `custom { name: "foo", string_ptr_prop: "", bazel_module: { bp2build_available: true }, }`, expectedBazelTargets: []string{ makeBazelTarget("custom", "foo", attrNameToString{ "string_ptr_prop": `""`, }), }, }, { description: "string props", blueprint: `custom { name: "foo", string_list_prop: ["a", "b"], string_prop: "a", string_ptr_prop: "a", bazel_module: { bp2build_available: true }, }`, expectedBazelTargets: []string{ Loading @@ -236,7 +256,7 @@ func TestGenerateBazelTargetModules(t *testing.T) { "a", "b", ]`, "string_prop": `"a"`, "string_ptr_prop": `"a"`, }), }, }, Loading @@ -245,7 +265,7 @@ func TestGenerateBazelTargetModules(t *testing.T) { blueprint: `custom { name: "foo", string_list_prop: ["\t", "\n"], string_prop: "a\t\n\r", string_ptr_prop: "a\t\n\r", bazel_module: { bp2build_available: true }, }`, expectedBazelTargets: []string{ Loading @@ -254,7 +274,7 @@ func TestGenerateBazelTargetModules(t *testing.T) { "\t", "\n", ]`, "string_prop": `"a\t\n\r"`, "string_ptr_prop": `"a\t\n\r"`, }), }, }, Loading bp2build/testing.go +7 −7 Original line number Diff line number Diff line Loading @@ -149,15 +149,15 @@ func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.Regi } type nestedProps struct { Nested_prop string Nested_prop *string } type EmbeddedProps struct { Embedded_prop string Embedded_prop *string } type OtherEmbeddedProps struct { Other_embedded_prop string Other_embedded_prop *string } type customProps struct { Loading Loading @@ -262,17 +262,17 @@ func customDefaultsModuleFactory() android.Module { } type EmbeddedAttr struct { Embedded_attr string Embedded_attr *string } type OtherEmbeddedAttr struct { Other_embedded_attr string Other_embedded_attr *string } type customBazelModuleAttributes struct { EmbeddedAttr *OtherEmbeddedAttr String_prop string String_ptr_prop *string String_list_prop []string Arch_paths bazel.LabelListAttribute } Loading @@ -296,7 +296,7 @@ func customBp2BuildMutator(ctx android.TopDownMutatorContext) { paths.ResolveExcludes() attrs := &customBazelModuleAttributes{ String_prop: m.props.String_prop, String_ptr_prop: m.props.String_ptr_prop, String_list_prop: m.props.String_list_prop, Arch_paths: paths, } Loading cc/bp2build.go +9 −1 Original line number Diff line number Diff line Loading @@ -388,7 +388,15 @@ func bp2buildResolveCppStdValue(c_std *string, cpp_std *string, gnu_extensions * } cStdVal, cppStdVal = maybeReplaceGnuToC(gnu_extensions, cStdVal, cppStdVal) return &cStdVal, &cppStdVal var c_std_prop, cpp_std_prop *string if cStdVal != "" { c_std_prop = &cStdVal } if cppStdVal != "" { cpp_std_prop = &cppStdVal } return c_std_prop, cpp_std_prop } // bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes. Loading Loading
apex/apex.go +3 −3 Original line number Diff line number Diff line Loading @@ -3201,7 +3201,7 @@ type bazelApexBundleAttributes struct { File_contexts bazel.LabelAttribute Key bazel.LabelAttribute Certificate bazel.LabelAttribute Min_sdk_version string Min_sdk_version *string Updatable bazel.BoolAttribute Installable bazel.BoolAttribute Native_shared_libs bazel.LabelListAttribute Loading Loading @@ -3241,9 +3241,9 @@ func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexB fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.properties.File_contexts)) } var minSdkVersion string var minSdkVersion *string if module.properties.Min_sdk_version != nil { minSdkVersion = *module.properties.Min_sdk_version minSdkVersion = module.properties.Min_sdk_version } var keyLabelAttribute bazel.LabelAttribute Loading
bp2build/build_conversion.go +3 −3 Original line number Diff line number Diff line Loading @@ -698,9 +698,9 @@ func isZero(value reflect.Value) bool { } else { return true } // Always print bools, if you want a bool attribute to be able to take the default value, use a // bool pointer instead case reflect.Bool: // Always print bool/strings, if you want a bool/string attribute to be able to take the default value, use a // pointer instead case reflect.Bool, reflect.String: return false default: if !value.IsValid() { Loading
bp2build/build_conversion_test.go +24 −4 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { soong_module_deps = [ ], bool_prop = False, string_prop = "", )`, }, { Loading @@ -58,6 +59,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { soong_module_deps = [ ], bool_prop = True, string_prop = "", )`, }, { Loading @@ -76,6 +78,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { ], bool_prop = False, owner = "a_string_with\"quotes\"_and_\\backslashes\\\\", string_prop = "", )`, }, { Loading @@ -94,6 +97,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { ], bool_prop = False, required = ["bar"], string_prop = "", )`, }, { Loading @@ -111,6 +115,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { soong_module_deps = [ ], bool_prop = False, string_prop = "", target_required = [ "qux", "bazqux", Loading Loading @@ -147,6 +152,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { "tag": ".bar", "targets": ["goal_bar"], }], string_prop = "", )`, }, { Loading Loading @@ -179,6 +185,7 @@ func TestGenerateSoongModuleTargets(t *testing.T) { }], owner = "custom_owner", required = ["bar"], string_prop = "", target_required = [ "qux", "bazqux", Loading Loading @@ -222,12 +229,25 @@ func TestGenerateSoongModuleTargets(t *testing.T) { func TestGenerateBazelTargetModules(t *testing.T) { testCases := []bp2buildTestCase{ { description: "string ptr props", blueprint: `custom { name: "foo", string_ptr_prop: "", bazel_module: { bp2build_available: true }, }`, expectedBazelTargets: []string{ makeBazelTarget("custom", "foo", attrNameToString{ "string_ptr_prop": `""`, }), }, }, { description: "string props", blueprint: `custom { name: "foo", string_list_prop: ["a", "b"], string_prop: "a", string_ptr_prop: "a", bazel_module: { bp2build_available: true }, }`, expectedBazelTargets: []string{ Loading @@ -236,7 +256,7 @@ func TestGenerateBazelTargetModules(t *testing.T) { "a", "b", ]`, "string_prop": `"a"`, "string_ptr_prop": `"a"`, }), }, }, Loading @@ -245,7 +265,7 @@ func TestGenerateBazelTargetModules(t *testing.T) { blueprint: `custom { name: "foo", string_list_prop: ["\t", "\n"], string_prop: "a\t\n\r", string_ptr_prop: "a\t\n\r", bazel_module: { bp2build_available: true }, }`, expectedBazelTargets: []string{ Loading @@ -254,7 +274,7 @@ func TestGenerateBazelTargetModules(t *testing.T) { "\t", "\n", ]`, "string_prop": `"a\t\n\r"`, "string_ptr_prop": `"a\t\n\r"`, }), }, }, Loading
bp2build/testing.go +7 −7 Original line number Diff line number Diff line Loading @@ -149,15 +149,15 @@ func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.Regi } type nestedProps struct { Nested_prop string Nested_prop *string } type EmbeddedProps struct { Embedded_prop string Embedded_prop *string } type OtherEmbeddedProps struct { Other_embedded_prop string Other_embedded_prop *string } type customProps struct { Loading Loading @@ -262,17 +262,17 @@ func customDefaultsModuleFactory() android.Module { } type EmbeddedAttr struct { Embedded_attr string Embedded_attr *string } type OtherEmbeddedAttr struct { Other_embedded_attr string Other_embedded_attr *string } type customBazelModuleAttributes struct { EmbeddedAttr *OtherEmbeddedAttr String_prop string String_ptr_prop *string String_list_prop []string Arch_paths bazel.LabelListAttribute } Loading @@ -296,7 +296,7 @@ func customBp2BuildMutator(ctx android.TopDownMutatorContext) { paths.ResolveExcludes() attrs := &customBazelModuleAttributes{ String_prop: m.props.String_prop, String_ptr_prop: m.props.String_ptr_prop, String_list_prop: m.props.String_list_prop, Arch_paths: paths, } Loading
cc/bp2build.go +9 −1 Original line number Diff line number Diff line Loading @@ -388,7 +388,15 @@ func bp2buildResolveCppStdValue(c_std *string, cpp_std *string, gnu_extensions * } cStdVal, cppStdVal = maybeReplaceGnuToC(gnu_extensions, cStdVal, cppStdVal) return &cStdVal, &cppStdVal var c_std_prop, cpp_std_prop *string if cStdVal != "" { c_std_prop = &cStdVal } if cppStdVal != "" { cpp_std_prop = &cppStdVal } return c_std_prop, cpp_std_prop } // bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes. Loading