add target_compatible_with stanza for host targets

Soong modules that are specific for the host platform (e.g.
java_library_host, cc_binary_host, java_genrule_host, etc.) should
not be built on the target platform (Android), so we add a
target_compatible_with attribute to skip this type of module on an
Android target build.

Bug: 215229742
Test: go test ./bp2build
Change-Id: Ifb76ef4e0dc4cb3adb6a64b5c375ce36f7973e48
This commit is contained in:
Sam Delmerico
2022-01-31 14:37:29 +00:00
parent d519b331f2
commit 75539d62ae
9 changed files with 236 additions and 95 deletions

View File

@@ -17,8 +17,6 @@ package java
import (
"android/soong/android"
"android/soong/bazel"
"github.com/google/blueprint/proptools"
)
func init() {
@@ -78,12 +76,9 @@ func (p *Plugin) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
attrs.Processor_class = p.pluginProperties.Processor_class
}
var enabledProperty bazel.BoolAttribute
enabledProperty.SetSelectValue(bazel.OsConfigurationAxis, android.Android.Name, proptools.BoolPtr(false))
props := bazel.BazelTargetModuleProperties{
Rule_class: "java_plugin",
}
ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: p.Name()}, attrs, enabledProperty)
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: p.Name()}, attrs)
}