Loading bp2build/gensrcs_conversion_test.go +7 −2 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,8 @@ func TestGensrcs(t *testing.T) { name: "foo", name: "foo", srcs: ["test/input.txt", ":external_files"], srcs: ["test/input.txt", ":external_files"], tool_files: ["program.py"], tool_files: ["program.py"], cmd: "$(location program.py) $(in) $(out)", cmd: "$(location program.py) $(in) $(out) $(location foo/file.txt) $(location :external_files)", data: ["foo/file.txt", ":external_files"], output_extension: "out", output_extension: "out", bazel_module: { bp2build_available: true }, bazel_module: { bp2build_available: true }, }`, }`, Loading @@ -44,7 +45,11 @@ func TestGensrcs(t *testing.T) { ]`, ]`, "tools": `["program.py"]`, "tools": `["program.py"]`, "output_extension": `"out"`, "output_extension": `"out"`, "cmd": `"$(location program.py) $(SRC) $(OUT)"`, "cmd": `"$(location program.py) $(SRC) $(OUT) $(location foo/file.txt) $(location :external_files__BP2BUILD__MISSING__DEP)"`, "data": `[ "foo/file.txt", ":external_files__BP2BUILD__MISSING__DEP", ]`, }, }, }, }, { { Loading genrule/genrule.go +19 −10 Original line number Original line Diff line number Diff line Loading @@ -873,6 +873,7 @@ type bazelGensrcsAttributes struct { Output_extension *string Output_extension *string Tools bazel.LabelListAttribute Tools bazel.LabelListAttribute Cmd string Cmd string Data bazel.LabelListAttribute } } const defaultShardSize = 50 const defaultShardSize = 50 Loading Loading @@ -952,6 +953,23 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { allReplacements.Append(tools.Value) allReplacements.Append(tools.Value) allReplacements.Append(bazel.FirstUniqueBazelLabelList(srcs_labels)) allReplacements.Append(bazel.FirstUniqueBazelLabelList(srcs_labels)) // The Output_extension prop is not in an immediately accessible field // in the Module struct, so use GetProperties and cast it // to the known struct prop. var outputExtension *string var data bazel.LabelListAttribute if ctx.ModuleType() == "gensrcs" { for _, propIntf := range m.GetProperties() { if props, ok := propIntf.(*genSrcsProperties); ok { outputExtension = props.Output_extension dataFiles := android.BazelLabelForModuleSrc(ctx, props.Data) allReplacements.Append(bazel.FirstUniqueBazelLabelList(dataFiles)) data = bazel.MakeLabelListAttribute(dataFiles) break } } } // Replace in and out variables with $< and $@ // Replace in and out variables with $< and $@ var cmd string var cmd string if m.properties.Cmd != nil { if m.properties.Cmd != nil { Loading Loading @@ -980,16 +998,6 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { tags := android.ApexAvailableTagsWithoutTestApexes(ctx, m) tags := android.ApexAvailableTagsWithoutTestApexes(ctx, m) if ctx.ModuleType() == "gensrcs" { if ctx.ModuleType() == "gensrcs" { // The Output_extension prop is not in an immediately accessible field // in the Module struct, so use GetProperties and cast it // to the known struct prop. var outputExtension *string for _, propIntf := range m.GetProperties() { if props, ok := propIntf.(*genSrcsProperties); ok { outputExtension = props.Output_extension break } } props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{ Rule_class: "gensrcs", Rule_class: "gensrcs", Bzl_load_location: "//build/bazel/rules:gensrcs.bzl", Bzl_load_location: "//build/bazel/rules:gensrcs.bzl", Loading @@ -999,6 +1007,7 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { Output_extension: outputExtension, Output_extension: outputExtension, Cmd: cmd, Cmd: cmd, Tools: tools, Tools: tools, Data: data, } } ctx.CreateBazelTargetModule(props, android.CommonAttributes{ ctx.CreateBazelTargetModule(props, android.CommonAttributes{ Name: m.Name(), Name: m.Name(), Loading Loading
bp2build/gensrcs_conversion_test.go +7 −2 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,8 @@ func TestGensrcs(t *testing.T) { name: "foo", name: "foo", srcs: ["test/input.txt", ":external_files"], srcs: ["test/input.txt", ":external_files"], tool_files: ["program.py"], tool_files: ["program.py"], cmd: "$(location program.py) $(in) $(out)", cmd: "$(location program.py) $(in) $(out) $(location foo/file.txt) $(location :external_files)", data: ["foo/file.txt", ":external_files"], output_extension: "out", output_extension: "out", bazel_module: { bp2build_available: true }, bazel_module: { bp2build_available: true }, }`, }`, Loading @@ -44,7 +45,11 @@ func TestGensrcs(t *testing.T) { ]`, ]`, "tools": `["program.py"]`, "tools": `["program.py"]`, "output_extension": `"out"`, "output_extension": `"out"`, "cmd": `"$(location program.py) $(SRC) $(OUT)"`, "cmd": `"$(location program.py) $(SRC) $(OUT) $(location foo/file.txt) $(location :external_files__BP2BUILD__MISSING__DEP)"`, "data": `[ "foo/file.txt", ":external_files__BP2BUILD__MISSING__DEP", ]`, }, }, }, }, { { Loading
genrule/genrule.go +19 −10 Original line number Original line Diff line number Diff line Loading @@ -873,6 +873,7 @@ type bazelGensrcsAttributes struct { Output_extension *string Output_extension *string Tools bazel.LabelListAttribute Tools bazel.LabelListAttribute Cmd string Cmd string Data bazel.LabelListAttribute } } const defaultShardSize = 50 const defaultShardSize = 50 Loading Loading @@ -952,6 +953,23 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { allReplacements.Append(tools.Value) allReplacements.Append(tools.Value) allReplacements.Append(bazel.FirstUniqueBazelLabelList(srcs_labels)) allReplacements.Append(bazel.FirstUniqueBazelLabelList(srcs_labels)) // The Output_extension prop is not in an immediately accessible field // in the Module struct, so use GetProperties and cast it // to the known struct prop. var outputExtension *string var data bazel.LabelListAttribute if ctx.ModuleType() == "gensrcs" { for _, propIntf := range m.GetProperties() { if props, ok := propIntf.(*genSrcsProperties); ok { outputExtension = props.Output_extension dataFiles := android.BazelLabelForModuleSrc(ctx, props.Data) allReplacements.Append(bazel.FirstUniqueBazelLabelList(dataFiles)) data = bazel.MakeLabelListAttribute(dataFiles) break } } } // Replace in and out variables with $< and $@ // Replace in and out variables with $< and $@ var cmd string var cmd string if m.properties.Cmd != nil { if m.properties.Cmd != nil { Loading Loading @@ -980,16 +998,6 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { tags := android.ApexAvailableTagsWithoutTestApexes(ctx, m) tags := android.ApexAvailableTagsWithoutTestApexes(ctx, m) if ctx.ModuleType() == "gensrcs" { if ctx.ModuleType() == "gensrcs" { // The Output_extension prop is not in an immediately accessible field // in the Module struct, so use GetProperties and cast it // to the known struct prop. var outputExtension *string for _, propIntf := range m.GetProperties() { if props, ok := propIntf.(*genSrcsProperties); ok { outputExtension = props.Output_extension break } } props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{ Rule_class: "gensrcs", Rule_class: "gensrcs", Bzl_load_location: "//build/bazel/rules:gensrcs.bzl", Bzl_load_location: "//build/bazel/rules:gensrcs.bzl", Loading @@ -999,6 +1007,7 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { Output_extension: outputExtension, Output_extension: outputExtension, Cmd: cmd, Cmd: cmd, Tools: tools, Tools: tools, Data: data, } } ctx.CreateBazelTargetModule(props, android.CommonAttributes{ ctx.CreateBazelTargetModule(props, android.CommonAttributes{ Name: m.Name(), Name: m.Name(), Loading