diff options
author | 2023-08-08 22:09:12 -0400 | |
---|---|---|
committer | 2023-08-22 23:07:33 -0400 | |
commit | 6d8d44af245ade571cfcf90a2b6de033086997f6 (patch) | |
tree | a385d09e8380c2bb051a5454642974e29ef000b6 /sh/sh_binary.go | |
parent | 1311c1af27e76d365062772acfe1d79e19219de1 (diff) |
bp2build converter for sh_test followup
Test: m nothing
Bug: 283486885
Change-Id: Ib8229e75dfcd9fd251fb1a83485cf5f88bdc3afb
Diffstat (limited to 'sh/sh_binary.go')
-rw-r--r-- | sh/sh_binary.go | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/sh/sh_binary.go b/sh/sh_binary.go index d2eede65d..545990475 100644 --- a/sh/sh_binary.go +++ b/sh/sh_binary.go @@ -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) |