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:
@@ -51,6 +51,10 @@ func TestPythonBinaryHostSimple(t *testing.T) {
|
||||
"b/c.py",
|
||||
"b/d.py",
|
||||
]`,
|
||||
"target_compatible_with": `select({
|
||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
@@ -80,6 +84,10 @@ func TestPythonBinaryHostPy2(t *testing.T) {
|
||||
makeBazelTarget("py_binary", "foo", attrNameToString{
|
||||
"python_version": `"PY2"`,
|
||||
"srcs": `["a.py"]`,
|
||||
"target_compatible_with": `select({
|
||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
@@ -109,6 +117,10 @@ func TestPythonBinaryHostPy3(t *testing.T) {
|
||||
// python_version is PY3 by default.
|
||||
makeBazelTarget("py_binary", "foo", attrNameToString{
|
||||
"srcs": `["a.py"]`,
|
||||
"target_compatible_with": `select({
|
||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
@@ -140,6 +152,10 @@ func TestPythonBinaryHostArchVariance(t *testing.T) {
|
||||
"//build/bazel/platforms/arch:arm": ["arm.py"],
|
||||
"//build/bazel/platforms/arch:x86": ["x86.py"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
"target_compatible_with": `select({
|
||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
},
|
||||
|
Reference in New Issue
Block a user