Loading android/bazel_paths.go +4 −4 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ func BazelLabelForModuleDeps(ctx BazelConversionPathContext, modules []string) b } if m, t := SrcIsModuleWithTag(module); m != "" { l := getOtherModuleLabel(ctx, m, t) l.Bp_text = bpText l.OriginalModuleName = bpText labels.Includes = append(labels.Includes, l) } else { ctx.ModuleErrorf("%q, is not a module reference", module) Loading Loading @@ -156,8 +156,8 @@ func directoryHasBlueprint(fs pathtools.FileSystem, prefix string, components [] func transformSubpackagePath(ctx BazelConversionPathContext, path bazel.Label) bazel.Label { var newPath bazel.Label // Don't transform Bp_text newPath.Bp_text = path.Bp_text // Don't transform OriginalModuleName newPath.OriginalModuleName = path.OriginalModuleName if strings.HasPrefix(path.Label, "//") { // Assume absolute labels are already correct (e.g. //path/to/some/package:foo.h) Loading Loading @@ -247,7 +247,7 @@ func expandSrcsForBazel(ctx BazelConversionPathContext, paths, expandedExcludes if m, tag := SrcIsModuleWithTag(p); m != "" { l := getOtherModuleLabel(ctx, m, tag) if !InList(l.Label, expandedExcludes) { l.Bp_text = fmt.Sprintf(":%s", m) l.OriginalModuleName = fmt.Sprintf(":%s", m) labels.Includes = append(labels.Includes, l) } } else { Loading bazel/properties.go +20 −4 Original line number Diff line number Diff line Loading @@ -35,11 +35,27 @@ const BazelTargetModuleNamePrefix = "__bp2build__" var productVariableSubstitutionPattern = regexp.MustCompile("%(d|s)") // Label is used to represent a Bazel compatible Label. Also stores the original bp text to support // string replacement. // Label is used to represent a Bazel compatible Label. Also stores the original // bp text to support string replacement. type Label struct { Bp_text string // The string representation of a Bazel target label. This can be a relative // or fully qualified label. These labels are used for generating BUILD // files with bp2build. Label string // The original Soong/Blueprint module name that the label was derived from. // This is used for replacing references to the original name with the new // label, for example in genrule cmds. // // While there is a reversible 1:1 mapping from the module name to Bazel // label with bp2build that could make computing the original module name // from the label automatic, it is not the case for handcrafted targets, // where modules can have a custom label mapping through the { bazel_module: // { label: <label> } } property. // // With handcrafted labels, those modules don't go through bp2build // conversion, but relies on handcrafted targets in the source tree. OriginalModuleName string } // LabelList is used to represent a list of Bazel labels. Loading genrule/genrule.go +2 −2 Original line number Diff line number Diff line Loading @@ -856,8 +856,8 @@ func GenruleBp2Build(ctx android.TopDownMutatorContext) { cmd = strings.Replace(cmd, "$(locations)", fmt.Sprintf("$(locations %s)", tools.Value.Includes[0].Label), -1) } for _, l := range allReplacements.Includes { bpLoc := fmt.Sprintf("$(location %s)", l.Bp_text) bpLocs := fmt.Sprintf("$(locations %s)", l.Bp_text) bpLoc := fmt.Sprintf("$(location %s)", l.OriginalModuleName) bpLocs := fmt.Sprintf("$(locations %s)", l.OriginalModuleName) bazelLoc := fmt.Sprintf("$(location %s)", l.Label) bazelLocs := fmt.Sprintf("$(locations %s)", l.Label) cmd = strings.Replace(cmd, bpLoc, bazelLoc, -1) Loading Loading
android/bazel_paths.go +4 −4 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ func BazelLabelForModuleDeps(ctx BazelConversionPathContext, modules []string) b } if m, t := SrcIsModuleWithTag(module); m != "" { l := getOtherModuleLabel(ctx, m, t) l.Bp_text = bpText l.OriginalModuleName = bpText labels.Includes = append(labels.Includes, l) } else { ctx.ModuleErrorf("%q, is not a module reference", module) Loading Loading @@ -156,8 +156,8 @@ func directoryHasBlueprint(fs pathtools.FileSystem, prefix string, components [] func transformSubpackagePath(ctx BazelConversionPathContext, path bazel.Label) bazel.Label { var newPath bazel.Label // Don't transform Bp_text newPath.Bp_text = path.Bp_text // Don't transform OriginalModuleName newPath.OriginalModuleName = path.OriginalModuleName if strings.HasPrefix(path.Label, "//") { // Assume absolute labels are already correct (e.g. //path/to/some/package:foo.h) Loading Loading @@ -247,7 +247,7 @@ func expandSrcsForBazel(ctx BazelConversionPathContext, paths, expandedExcludes if m, tag := SrcIsModuleWithTag(p); m != "" { l := getOtherModuleLabel(ctx, m, tag) if !InList(l.Label, expandedExcludes) { l.Bp_text = fmt.Sprintf(":%s", m) l.OriginalModuleName = fmt.Sprintf(":%s", m) labels.Includes = append(labels.Includes, l) } } else { Loading
bazel/properties.go +20 −4 Original line number Diff line number Diff line Loading @@ -35,11 +35,27 @@ const BazelTargetModuleNamePrefix = "__bp2build__" var productVariableSubstitutionPattern = regexp.MustCompile("%(d|s)") // Label is used to represent a Bazel compatible Label. Also stores the original bp text to support // string replacement. // Label is used to represent a Bazel compatible Label. Also stores the original // bp text to support string replacement. type Label struct { Bp_text string // The string representation of a Bazel target label. This can be a relative // or fully qualified label. These labels are used for generating BUILD // files with bp2build. Label string // The original Soong/Blueprint module name that the label was derived from. // This is used for replacing references to the original name with the new // label, for example in genrule cmds. // // While there is a reversible 1:1 mapping from the module name to Bazel // label with bp2build that could make computing the original module name // from the label automatic, it is not the case for handcrafted targets, // where modules can have a custom label mapping through the { bazel_module: // { label: <label> } } property. // // With handcrafted labels, those modules don't go through bp2build // conversion, but relies on handcrafted targets in the source tree. OriginalModuleName string } // LabelList is used to represent a list of Bazel labels. Loading
genrule/genrule.go +2 −2 Original line number Diff line number Diff line Loading @@ -856,8 +856,8 @@ func GenruleBp2Build(ctx android.TopDownMutatorContext) { cmd = strings.Replace(cmd, "$(locations)", fmt.Sprintf("$(locations %s)", tools.Value.Includes[0].Label), -1) } for _, l := range allReplacements.Includes { bpLoc := fmt.Sprintf("$(location %s)", l.Bp_text) bpLocs := fmt.Sprintf("$(locations %s)", l.Bp_text) bpLoc := fmt.Sprintf("$(location %s)", l.OriginalModuleName) bpLocs := fmt.Sprintf("$(locations %s)", l.OriginalModuleName) bazelLoc := fmt.Sprintf("$(location %s)", l.Label) bazelLocs := fmt.Sprintf("$(locations %s)", l.Label) cmd = strings.Replace(cmd, bpLoc, bazelLoc, -1) Loading