diff options
author | Rupert Shuttleworth <ruperts@google.com> | 2021-02-09 10:59:06 +0000 |
---|---|---|
committer | Rupert Shuttleworth <ruperts@google.com> | 2021-02-09 11:53:00 +0000 |
commit | a1a56e8f82ec154a6856e2485d63fb1d74d3a2ca (patch) | |
tree | 7a5df0bda330c3bb4b14d90d7514e5059ff943cd /sh | |
parent | 198158b9f7ebdb311b82dd2223f4b793215d4e3b (diff) | |
download | soong-a1a56e8f82ec154a6856e2485d63fb1d74d3a2ca.tar.gz |
Add sh_binary support to bp2build converter.
Test: Added a unit test in this CL.
Change-Id: I6e9b3c833a257414daf82e603b733e459535d206
Diffstat (limited to 'sh')
-rw-r--r-- | sh/sh_binary.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/sh/sh_binary.go b/sh/sh_binary.go index 66e493bf1..54dfc2467 100644 --- a/sh/sh_binary.go +++ b/sh/sh_binary.go @@ -24,6 +24,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/bazel" "android/soong/cc" "android/soong/tradefed" ) @@ -43,6 +44,8 @@ func init() { android.RegisterModuleType("sh_binary_host", ShBinaryHostFactory) android.RegisterModuleType("sh_test", ShTestFactory) android.RegisterModuleType("sh_test_host", ShTestHostFactory) + + android.RegisterBp2BuildMutator("sh_binary", ShBinaryBp2Build) } type shBinaryProperties struct { @@ -81,6 +84,9 @@ type shBinaryProperties struct { // Make this module available when building for recovery. Recovery_available *bool + + // Properties for Bazel migration purposes. + bazel.Properties } type TestProperties struct { @@ -461,4 +467,62 @@ func ShTestHostFactory() android.Module { return module } +type bazelShBinaryAttributes struct { + Srcs bazel.LabelList + // Bazel also supports the attributes below, but (so far) these are not required for Bionic + // deps + // data + // args + // compatible_with + // deprecation + // distribs + // env + // exec_compatible_with + // exec_properties + // features + // licenses + // output_licenses + // restricted_to + // tags + // target_compatible_with + // testonly + // toolchains + // visibility +} + +type bazelShBinary struct { + android.BazelTargetModuleBase + bazelShBinaryAttributes +} + +func BazelShBinaryFactory() android.Module { + module := &bazelShBinary{} + module.AddProperties(&module.bazelShBinaryAttributes) + android.InitBazelTargetModule(module) + return module +} + +func ShBinaryBp2Build(ctx android.TopDownMutatorContext) { + m, ok := ctx.Module().(*ShBinary) + if !ok || !m.properties.Bazel_module.Bp2build_available { + return + } + + srcs := android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}) + + attrs := &bazelShBinaryAttributes{ + Srcs: srcs, + } + + props := bazel.NewBazelTargetModuleProperties(m.Name(), "sh_binary", "") + + ctx.CreateBazelTargetModule(BazelShBinaryFactory, props, attrs) +} + +func (m *bazelShBinary) Name() string { + return m.BaseModuleName() +} + +func (m *bazelShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {} + var Bool = proptools.Bool |