ANDROID: Use pkg_* instead of copy_file for kselftests.
cc_binary_with_abi() now produces a pkg_files() as its top-level target so it can be included in pkg_filegroup. Modifies kselftest related rules accordingly. Bug: 312798837 Test: local test Change-Id: I74938c7afe10ade4066eaf3205cd70c7d6dde009 Signed-off-by: HONG Yifan <elsk@google.com>
This commit is contained in:
+12
-20
@@ -7,7 +7,6 @@ load(
|
||||
"@rules_pkg//pkg:mappings.bzl",
|
||||
"pkg_filegroup",
|
||||
"pkg_files",
|
||||
"strip_prefix",
|
||||
)
|
||||
load("@rules_pkg//pkg:pkg.bzl", "pkg_zip")
|
||||
load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir")
|
||||
@@ -15,7 +14,6 @@ load("//build/kernel/kleaf:common_kernels.bzl", "define_common_kernels")
|
||||
load("//build/kernel/kleaf:constants.bzl", "X86_64_OUTS")
|
||||
load(
|
||||
"//build/kernel/kleaf:kernel.bzl",
|
||||
"android_filegroup",
|
||||
"checkpatch",
|
||||
"ddk_headers",
|
||||
"ddk_headers_archive",
|
||||
@@ -1986,7 +1984,7 @@ pkg_files(
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
android_filegroup(
|
||||
pkg_filegroup(
|
||||
name = "kselftest_tests_x86_64",
|
||||
srcs = [
|
||||
":kselftest_binderfs_binderfs_test_x86_64",
|
||||
@@ -2052,11 +2050,10 @@ android_filegroup(
|
||||
":kselftest_x86_syscall_nt_x86_64",
|
||||
":kselftest_x86_test_mremap_vdso_x86_64",
|
||||
],
|
||||
cpu = "x86_64",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
android_filegroup(
|
||||
pkg_filegroup(
|
||||
name = "kselftest_tests_x86",
|
||||
srcs = [
|
||||
":kselftest_binderfs_binderfs_test_x86",
|
||||
@@ -2122,11 +2119,10 @@ android_filegroup(
|
||||
":kselftest_x86_syscall_nt_x86",
|
||||
":kselftest_x86_test_mremap_vdso_x86",
|
||||
],
|
||||
cpu = "i386",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
android_filegroup(
|
||||
pkg_filegroup(
|
||||
name = "kselftest_tests_arm",
|
||||
srcs = [
|
||||
":kselftest_binderfs_binderfs_test_arm",
|
||||
@@ -2185,11 +2181,10 @@ android_filegroup(
|
||||
":kselftest_vdso_vdso_test_getcpu_arm",
|
||||
":kselftest_vdso_vdso_test_gettimeofday_arm",
|
||||
],
|
||||
cpu = "arm",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
android_filegroup(
|
||||
pkg_filegroup(
|
||||
name = "kselftest_tests_arm64",
|
||||
srcs = [
|
||||
":kselftest_binderfs_binderfs_test_arm64",
|
||||
@@ -2249,35 +2244,33 @@ android_filegroup(
|
||||
":kselftest_vdso_vdso_test_getcpu_arm64",
|
||||
":kselftest_vdso_vdso_test_gettimeofday_arm64",
|
||||
],
|
||||
cpu = "arm64",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "kselftest_tests_x86_64_pkg_files",
|
||||
pkg_filegroup(
|
||||
name = "kselftest_tests_x86_64_pkg_filegroup",
|
||||
srcs = [
|
||||
":kselftest_config_x86_64",
|
||||
":kselftest_tests_x86",
|
||||
":kselftest_tests_x86_64",
|
||||
],
|
||||
strip_prefix = strip_prefix.from_pkg(),
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "kselftest_tests_arm64_pkg_files",
|
||||
pkg_filegroup(
|
||||
name = "kselftest_tests_arm64_pkg_filegroup",
|
||||
srcs = [
|
||||
":kselftest_config_arm64",
|
||||
":kselftest_tests_arm",
|
||||
":kselftest_tests_arm64",
|
||||
],
|
||||
strip_prefix = strip_prefix.from_pkg(),
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
pkg_zip(
|
||||
name = "tests_zip_x86_64",
|
||||
srcs = [
|
||||
":kselftest_config_x86_64",
|
||||
":kselftest_tests_x86_64_pkg_files",
|
||||
":kselftest_tests_x86_64_pkg_filegroup",
|
||||
":kunit_tests_x86_64_pkg_files",
|
||||
],
|
||||
out = "x86_64/tests.zip",
|
||||
@@ -2287,8 +2280,7 @@ pkg_zip(
|
||||
pkg_zip(
|
||||
name = "tests_zip_arm64",
|
||||
srcs = [
|
||||
":kselftest_config_arm64",
|
||||
":kselftest_tests_arm64_pkg_files",
|
||||
":kselftest_tests_arm64_pkg_filegroup",
|
||||
":kunit_tests_arm64_pkg_files",
|
||||
],
|
||||
out = "arm64/tests.zip",
|
||||
|
||||
@@ -6,8 +6,16 @@ ABI aware build rules.
|
||||
"""
|
||||
|
||||
load("@bazel_skylib//lib:paths.bzl", "paths")
|
||||
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
||||
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
|
||||
load(
|
||||
"@rules_pkg//pkg:mappings.bzl",
|
||||
"pkg_files",
|
||||
"strip_prefix",
|
||||
)
|
||||
load(
|
||||
"//build/kernel/kleaf:kernel.bzl",
|
||||
"android_filegroup",
|
||||
)
|
||||
|
||||
visibility("private")
|
||||
|
||||
@@ -27,11 +35,22 @@ def _copy_with_abi(
|
||||
out = name
|
||||
|
||||
for abi in abis:
|
||||
copy_file(
|
||||
cpu = abi
|
||||
if abi == "x86":
|
||||
cpu = "i386"
|
||||
android_filegroup(
|
||||
name = "{name}_{abi}_bin".format(name = name, abi = abi),
|
||||
srcs = [":{name}".format(name = name)],
|
||||
cpu = cpu,
|
||||
visibility = visibility,
|
||||
)
|
||||
pkg_files(
|
||||
name = "{name}_{abi}".format(name = name, abi = abi),
|
||||
src = ":{name}".format(name = name),
|
||||
out = paths.join(path_prefix, abi, out),
|
||||
allow_symlink = True,
|
||||
srcs = [":{name}_{abi}_bin".format(name = name, abi = abi)],
|
||||
renames = {
|
||||
":{name}_{abi}_bin".format(name = name, abi = abi): paths.join(path_prefix, abi, out),
|
||||
},
|
||||
strip_prefix = strip_prefix.from_pkg(),
|
||||
visibility = visibility,
|
||||
)
|
||||
|
||||
@@ -46,11 +65,11 @@ def cc_binary_with_abi(
|
||||
|
||||
For example:
|
||||
```
|
||||
cc_binary_with_abi(
|
||||
cc_binary_with_abi(
|
||||
name = "a_binary",
|
||||
abis = ["x86_64", "arm64"],
|
||||
path_prefix = "my/path",
|
||||
)
|
||||
)
|
||||
```
|
||||
generates 2 rules:
|
||||
* Rule a_binary_x86_64: Builds the cc_binary and put output in my/path/x86_64/a_binary.
|
||||
@@ -59,13 +78,13 @@ def cc_binary_with_abi(
|
||||
Args:
|
||||
name: the name of the build rule.
|
||||
path_prefix: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The path prefix to attach to output.
|
||||
The path prefix to attach to output.
|
||||
abis: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The intended abis to generate. Default is arm64 & x86_64.
|
||||
The intended abis to generate. Default is arm64 & x86_64.
|
||||
visibility: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The visibility attribute on a target controls whether the target can be used in other packages.
|
||||
The visibility attribute on a target controls whether the target can be used in other packages.
|
||||
out: [Nonconfigurable](https://bazel.build/reference/be/common-definitions#configurable-attributes).
|
||||
The output filename. Default is `name`.
|
||||
The output filename. Default is `name`.
|
||||
**kwargs: the rest args that cc_binary uses.
|
||||
"""
|
||||
native.cc_binary(
|
||||
|
||||
Reference in New Issue
Block a user