Support filename and sub_dir attributes in sh_binary
Test: test by building system/timezone/apex:com.android.tzdata Change-Id: I08114910fccbdacf6750e237d3e80ba37fde7651
This commit is contained in:
@@ -62,11 +62,15 @@ func TestShBinarySimple(t *testing.T) {
|
|||||||
blueprint: `sh_binary {
|
blueprint: `sh_binary {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
src: "foo.sh",
|
src: "foo.sh",
|
||||||
|
filename: "foo.exe",
|
||||||
|
sub_dir: "sub",
|
||||||
bazel_module: { bp2build_available: true },
|
bazel_module: { bp2build_available: true },
|
||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{
|
expectedBazelTargets: []string{
|
||||||
makeBazelTarget("sh_binary", "foo", attrNameToString{
|
makeBazelTarget("sh_binary", "foo", attrNameToString{
|
||||||
"srcs": `["foo.sh"]`,
|
"srcs": `["foo.sh"]`,
|
||||||
|
"filename": `"foo.exe"`,
|
||||||
|
"sub_dir": `"sub"`,
|
||||||
})},
|
})},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -517,6 +517,8 @@ func ShTestHostFactory() android.Module {
|
|||||||
|
|
||||||
type bazelShBinaryAttributes struct {
|
type bazelShBinaryAttributes struct {
|
||||||
Srcs bazel.LabelListAttribute
|
Srcs bazel.LabelListAttribute
|
||||||
|
Filename string
|
||||||
|
Sub_dir string
|
||||||
// Bazel also supports the attributes below, but (so far) these are not required for Bionic
|
// Bazel also supports the attributes below, but (so far) these are not required for Bionic
|
||||||
// deps
|
// deps
|
||||||
// data
|
// data
|
||||||
@@ -547,12 +549,25 @@ func ShBinaryBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
srcs := bazel.MakeLabelListAttribute(
|
srcs := bazel.MakeLabelListAttribute(
|
||||||
android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))
|
android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))
|
||||||
|
|
||||||
|
var filename string
|
||||||
|
if m.properties.Filename != nil {
|
||||||
|
filename = *m.properties.Filename
|
||||||
|
}
|
||||||
|
|
||||||
|
var subDir string
|
||||||
|
if m.properties.Sub_dir != nil {
|
||||||
|
subDir = *m.properties.Sub_dir
|
||||||
|
}
|
||||||
|
|
||||||
attrs := &bazelShBinaryAttributes{
|
attrs := &bazelShBinaryAttributes{
|
||||||
Srcs: srcs,
|
Srcs: srcs,
|
||||||
|
Filename: filename,
|
||||||
|
Sub_dir: subDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "sh_binary",
|
Rule_class: "sh_binary",
|
||||||
|
Bzl_load_location: "//build/bazel/rules:sh_binary.bzl",
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
|
||||||
|
Reference in New Issue
Block a user