bp2build converter for sh_test followup
Test: m nothing Bug: 283486885 Change-Id: Ib8229e75dfcd9fd251fb1a83485cf5f88bdc3afb
This commit is contained in:
@@ -502,7 +502,7 @@ func ShBinaryHostFactory() android.Module {
|
||||
// sh_test defines a shell script based test module.
|
||||
func ShTestFactory() android.Module {
|
||||
module := &ShTest{}
|
||||
initShBinaryModule(&module.ShBinary, false)
|
||||
initShBinaryModule(&module.ShBinary, true)
|
||||
module.AddProperties(&module.testProperties)
|
||||
|
||||
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibFirst)
|
||||
@@ -512,7 +512,7 @@ func ShTestFactory() android.Module {
|
||||
// sh_test_host defines a shell script based test module that runs on a host.
|
||||
func ShTestHostFactory() android.Module {
|
||||
module := &ShTest{}
|
||||
initShBinaryModule(&module.ShBinary, false)
|
||||
initShBinaryModule(&module.ShBinary, true)
|
||||
module.AddProperties(&module.testProperties)
|
||||
// Default sh_test_host to unit_tests = true
|
||||
if module.testProperties.Test_options.Unit_test == nil {
|
||||
@@ -548,6 +548,15 @@ type bazelShBinaryAttributes struct {
|
||||
// visibility
|
||||
}
|
||||
|
||||
type bazelShTestAttributes struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
Data bazel.LabelListAttribute
|
||||
Tags bazel.StringListAttribute
|
||||
Test_config *string
|
||||
Test_config_template *string
|
||||
Auto_gen_config *bool
|
||||
}
|
||||
|
||||
func (m *ShBinary) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||
srcs := bazel.MakeLabelListAttribute(
|
||||
android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))
|
||||
@@ -576,6 +585,41 @@ func (m *ShBinary) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
|
||||
}
|
||||
|
||||
func (m *ShTest) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||
srcs := bazel.MakeLabelListAttribute(
|
||||
android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))
|
||||
|
||||
combinedData := append(m.testProperties.Data, m.testProperties.Data_bins...)
|
||||
combinedData = append(combinedData, m.testProperties.Data_libs...)
|
||||
|
||||
data := bazel.MakeLabelListAttribute(
|
||||
android.BazelLabelForModuleSrc(ctx, combinedData))
|
||||
|
||||
tags := bazel.MakeStringListAttribute(
|
||||
m.testProperties.Test_options.Tags)
|
||||
|
||||
test_config := m.testProperties.Test_config
|
||||
|
||||
test_config_template := m.testProperties.Test_config_template
|
||||
|
||||
auto_gen_config := m.testProperties.Auto_gen_config
|
||||
|
||||
attrs := &bazelShTestAttributes{
|
||||
Srcs: srcs,
|
||||
Data: data,
|
||||
Tags: tags,
|
||||
Test_config: test_config,
|
||||
Test_config_template: test_config_template,
|
||||
Auto_gen_config: auto_gen_config,
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "sh_test",
|
||||
Bzl_load_location: "//build/bazel/rules:sh_test.bzl",
|
||||
}
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
|
||||
}
|
||||
|
||||
var Bool = proptools.Bool
|
||||
|
||||
var _ snapshot.RelativeInstallPath = (*ShBinary)(nil)
|
||||
|
Reference in New Issue
Block a user