Add sh_binary support to bp2build converter.

Test: Added a unit test in this CL.
Change-Id: I6e9b3c833a257414daf82e603b733e459535d206
This commit is contained in:
Rupert Shuttleworth
2021-02-09 10:59:06 +00:00
parent 198158b9f7
commit a1a56e8f82
3 changed files with 89 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ bootstrap_go_package {
"soong-android",
"soong-bazel",
"soong-genrule",
"soong-sh",
],
testSrcs: [
"build_conversion_test.go",

View File

@@ -17,6 +17,7 @@ package bp2build
import (
"android/soong/android"
"android/soong/genrule"
"android/soong/sh"
"strings"
"testing"
)
@@ -357,6 +358,12 @@ load("//build/bazel/rules:java.bzl", "java_binary")`,
ruleClass: "genrule",
// Note: no bzlLoadLocation for native rules
},
BazelTarget{
name: "sh_binary_target",
ruleClass: "sh_binary",
// Note: no bzlLoadLocation for native rules
// TODO(ruperts): Could open source the existing, experimental Starlark sh_ rules?
},
},
expectedLoadStatements: `load("//build/bazel/rules:cc.bzl", "cc_binary")
load("//build/bazel/rules:java.bzl", "java_binary")`,
@@ -853,6 +860,23 @@ genrule {
)`,
},
},
{
description: "sh_binary test",
moduleTypeUnderTest: "sh_binary",
moduleTypeUnderTestFactory: sh.ShBinaryFactory,
moduleTypeUnderTestBp2BuildMutator: sh.ShBinaryBp2Build,
bp: `sh_binary {
name: "foo",
src: "foo.sh",
bazel_module: { bp2build_available: true },
}`,
expectedBazelTargets: []string{`sh_binary(
name = "foo",
srcs = [
"foo.sh",
],
)`},
},
}
dir := "."