Loading android/bazel_paths.go +4 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,10 @@ func BazelLabelForModuleDeps(ctx BazelConversionPathContext, modules []string) b return labels } func BazelLabelForModuleSrcSingle(ctx BazelConversionPathContext, path string) bazel.Label { return BazelLabelForModuleSrcExcludes(ctx, []string{path}, []string(nil)).Includes[0] } // BazelLabelForModuleSrc expects a list of path (relative to local module directory) and module // references (":<module>") and returns a bazel.LabelList{} containing the resolved references in // paths, relative to the local module, or Bazel-labels (absolute if in a different package or Loading bazel/properties.go +9 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,15 @@ type Attribute interface { HasConfigurableValues() bool } // Represents an attribute whose value is a single label type LabelAttribute struct { Value Label } func (LabelAttribute) HasConfigurableValues() bool { return false } // Arch-specific label_list typed Bazel attribute values. This should correspond // to the types of architectures supported for compilation in arch.go. type labelListArchValues struct { Loading bp2build/build_conversion.go +1 −3 Original line number Diff line number Diff line Loading @@ -519,10 +519,8 @@ func isZero(value reflect.Value) bool { case reflect.Struct: valueIsZero := true for i := 0; i < value.NumField(); i++ { if value.Field(i).CanSet() { valueIsZero = valueIsZero && isZero(value.Field(i)) } } return valueIsZero case reflect.Ptr: if !value.IsNil() { Loading bp2build/cc_library_conversion_test.go +25 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,31 @@ cc_library_static { name: "b" } copts = ["-Ifoo/bar"], srcs = ["a.cpp"], static_deps_for_shared = [":b"], )`}, }, { description: "cc_library non-configured version script", moduleTypeUnderTest: "cc_library", moduleTypeUnderTestFactory: cc.LibraryFactory, moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build, depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, dir: "foo/bar", filesystem: map[string]string{ "foo/bar/Android.bp": ` cc_library { name: "a", srcs: ["a.cpp"], version_script: "v.map", bazel_module: { bp2build_available: true }, } `, }, bp: soongCcLibraryPreamble, expectedBazelTargets: []string{`cc_library( name = "a", copts = ["-Ifoo/bar"], srcs = ["a.cpp"], version_script = "v.map", )`}, }, } Loading bp2build/configurability.go +7 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,11 @@ func getStringListValues(list bazel.StringListAttribute) (reflect.Value, selects return value, archSelects, osSelects } func getLabelValue(label bazel.LabelAttribute) (reflect.Value, selects, selects) { value := reflect.ValueOf(label.Value) return value, nil, nil } func getLabelListValues(list bazel.LabelListAttribute) (reflect.Value, selects, selects) { value := reflect.ValueOf(list.Value.Includes) if !list.HasConfigurableValues() { Loading @@ -54,12 +59,13 @@ func getLabelListValues(list bazel.LabelListAttribute) (reflect.Value, selects, func prettyPrintAttribute(v bazel.Attribute, indent int) (string, error) { var value reflect.Value var archSelects, osSelects selects switch list := v.(type) { case bazel.StringListAttribute: value, archSelects, osSelects = getStringListValues(list) case bazel.LabelListAttribute: value, archSelects, osSelects = getLabelListValues(list) case bazel.LabelAttribute: value, archSelects, osSelects = getLabelValue(list) default: return "", fmt.Errorf("Not a supported Bazel attribute type: %s", v) } Loading Loading
android/bazel_paths.go +4 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,10 @@ func BazelLabelForModuleDeps(ctx BazelConversionPathContext, modules []string) b return labels } func BazelLabelForModuleSrcSingle(ctx BazelConversionPathContext, path string) bazel.Label { return BazelLabelForModuleSrcExcludes(ctx, []string{path}, []string(nil)).Includes[0] } // BazelLabelForModuleSrc expects a list of path (relative to local module directory) and module // references (":<module>") and returns a bazel.LabelList{} containing the resolved references in // paths, relative to the local module, or Bazel-labels (absolute if in a different package or Loading
bazel/properties.go +9 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,15 @@ type Attribute interface { HasConfigurableValues() bool } // Represents an attribute whose value is a single label type LabelAttribute struct { Value Label } func (LabelAttribute) HasConfigurableValues() bool { return false } // Arch-specific label_list typed Bazel attribute values. This should correspond // to the types of architectures supported for compilation in arch.go. type labelListArchValues struct { Loading
bp2build/build_conversion.go +1 −3 Original line number Diff line number Diff line Loading @@ -519,10 +519,8 @@ func isZero(value reflect.Value) bool { case reflect.Struct: valueIsZero := true for i := 0; i < value.NumField(); i++ { if value.Field(i).CanSet() { valueIsZero = valueIsZero && isZero(value.Field(i)) } } return valueIsZero case reflect.Ptr: if !value.IsNil() { Loading
bp2build/cc_library_conversion_test.go +25 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,31 @@ cc_library_static { name: "b" } copts = ["-Ifoo/bar"], srcs = ["a.cpp"], static_deps_for_shared = [":b"], )`}, }, { description: "cc_library non-configured version script", moduleTypeUnderTest: "cc_library", moduleTypeUnderTestFactory: cc.LibraryFactory, moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build, depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, dir: "foo/bar", filesystem: map[string]string{ "foo/bar/Android.bp": ` cc_library { name: "a", srcs: ["a.cpp"], version_script: "v.map", bazel_module: { bp2build_available: true }, } `, }, bp: soongCcLibraryPreamble, expectedBazelTargets: []string{`cc_library( name = "a", copts = ["-Ifoo/bar"], srcs = ["a.cpp"], version_script = "v.map", )`}, }, } Loading
bp2build/configurability.go +7 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,11 @@ func getStringListValues(list bazel.StringListAttribute) (reflect.Value, selects return value, archSelects, osSelects } func getLabelValue(label bazel.LabelAttribute) (reflect.Value, selects, selects) { value := reflect.ValueOf(label.Value) return value, nil, nil } func getLabelListValues(list bazel.LabelListAttribute) (reflect.Value, selects, selects) { value := reflect.ValueOf(list.Value.Includes) if !list.HasConfigurableValues() { Loading @@ -54,12 +59,13 @@ func getLabelListValues(list bazel.LabelListAttribute) (reflect.Value, selects, func prettyPrintAttribute(v bazel.Attribute, indent int) (string, error) { var value reflect.Value var archSelects, osSelects selects switch list := v.(type) { case bazel.StringListAttribute: value, archSelects, osSelects = getStringListValues(list) case bazel.LabelListAttribute: value, archSelects, osSelects = getLabelListValues(list) case bazel.LabelAttribute: value, archSelects, osSelects = getLabelValue(list) default: return "", fmt.Errorf("Not a supported Bazel attribute type: %s", v) } Loading