From ed2654cfdc6e2336057511288c6686ec6a19c572 Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Mon, 17 Oct 2022 16:36:30 -0700 Subject: [PATCH] Refactor the bp file to avoid arch variant in cc_genrule. The arch variant of genrule.out will be soon disallowed in soong. Bug: 253645813 Test: Manually build. Change-Id: Ia07d45195de8c22f18487aef34795279d2962c4c --- libc/Android.bp | 347 +++++++++++++++++++++++++----------------------- 1 file changed, 181 insertions(+), 166 deletions(-) diff --git a/libc/Android.bp b/libc/Android.bp index 1185b1ec8..cf7e82c16 100644 --- a/libc/Android.bp +++ b/libc/Android.bp @@ -2478,13 +2478,8 @@ genrule { cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)", } -cc_genrule { - name: "libseccomp_policy_app_zygote_sources", - recovery_available: true, - cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)", - - tools: [ "genseccomp" ], - +filegroup { + name: "seccomp_syscalls_sources_zygote", srcs: [ "SYSCALLS.TXT", "SECCOMP_ALLOWLIST_COMMON.TXT", @@ -2493,62 +2488,10 @@ cc_genrule { "SECCOMP_PRIORITY.TXT", ":generate_app_zygote_blocklist", ], - - arch: { - arm: { - srcs: [ - ":libseccomp_gen_syscall_nrs_arm", - ":libseccomp_gen_syscall_nrs_arm64", - ], - out: [ - "arm_app_zygote_policy.cpp", - "arm64_app_zygote_policy.cpp", - ], - }, - arm64: { - srcs: [ - ":libseccomp_gen_syscall_nrs_arm", - ":libseccomp_gen_syscall_nrs_arm64", - ], - out: [ - "arm_app_zygote_policy.cpp", - "arm64_app_zygote_policy.cpp", - ], - }, - riscv64: { - srcs: [":libseccomp_gen_syscall_nrs_riscv64"], - out: ["riscv64_app_zygote_policy.cpp"], - }, - x86: { - srcs: [ - ":libseccomp_gen_syscall_nrs_x86", - ":libseccomp_gen_syscall_nrs_x86_64", - ], - out: [ - "x86_app_zygote_policy.cpp", - "x86_64_app_zygote_policy.cpp", - ], - }, - x86_64: { - srcs: [ - ":libseccomp_gen_syscall_nrs_x86", - ":libseccomp_gen_syscall_nrs_x86_64", - ], - out: [ - "x86_app_zygote_policy.cpp", - "x86_64_app_zygote_policy.cpp", - ], - }, - }, } -cc_genrule { - name: "libseccomp_policy_app_sources", - recovery_available: true, - cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)", - - tools: [ "genseccomp" ], - +filegroup { + name: "seccomp_syscalls_sources_app", srcs: [ "SYSCALLS.TXT", "SECCOMP_ALLOWLIST_COMMON.TXT", @@ -2557,62 +2500,10 @@ cc_genrule { "SECCOMP_BLOCKLIST_APP.TXT", "SECCOMP_PRIORITY.TXT", ], - - arch: { - arm: { - srcs: [ - ":libseccomp_gen_syscall_nrs_arm", - ":libseccomp_gen_syscall_nrs_arm64", - ], - out: [ - "arm_app_policy.cpp", - "arm64_app_policy.cpp", - ], - }, - arm64: { - srcs: [ - ":libseccomp_gen_syscall_nrs_arm", - ":libseccomp_gen_syscall_nrs_arm64", - ], - out: [ - "arm_app_policy.cpp", - "arm64_app_policy.cpp", - ], - }, - riscv64: { - srcs: [":libseccomp_gen_syscall_nrs_riscv64"], - out: ["riscv64_app_policy.cpp"], - }, - x86: { - srcs: [ - ":libseccomp_gen_syscall_nrs_x86", - ":libseccomp_gen_syscall_nrs_x86_64", - ], - out: [ - "x86_app_policy.cpp", - "x86_64_app_policy.cpp", - ], - }, - x86_64: { - srcs: [ - ":libseccomp_gen_syscall_nrs_x86", - ":libseccomp_gen_syscall_nrs_x86_64", - ], - out: [ - "x86_app_policy.cpp", - "x86_64_app_policy.cpp", - ], - }, - }, } -cc_genrule { - name: "libseccomp_policy_system_sources", - recovery_available: true, - cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)", - - tools: [ "genseccomp" ], - +filegroup { + name: "seccomp_syscalls_sources_system", srcs: [ "SYSCALLS.TXT", "SECCOMP_ALLOWLIST_COMMON.TXT", @@ -2620,64 +2511,188 @@ cc_genrule { "SECCOMP_BLOCKLIST_COMMON.TXT", "SECCOMP_PRIORITY.TXT", ], +} - arch: { - arm: { - srcs: [ - ":libseccomp_gen_syscall_nrs_arm", - ":libseccomp_gen_syscall_nrs_arm64", - ], - out: [ - "arm_system_policy.cpp", - "arm64_system_policy.cpp", - ], - }, - arm64: { - srcs: [ - ":libseccomp_gen_syscall_nrs_arm", - ":libseccomp_gen_syscall_nrs_arm64", - ], - out: [ - "arm_system_policy.cpp", - "arm64_system_policy.cpp", - ], - }, - riscv64: { - srcs: [":libseccomp_gen_syscall_nrs_riscv64"], - out: ["riscv64_system_policy.cpp"], - }, - x86: { - srcs: [ - ":libseccomp_gen_syscall_nrs_x86", - ":libseccomp_gen_syscall_nrs_x86_64", - ], - out: [ - "x86_system_policy.cpp", - "x86_64_system_policy.cpp", - ], - }, - x86_64: { - srcs: [ - ":libseccomp_gen_syscall_nrs_x86", - ":libseccomp_gen_syscall_nrs_x86_64", - ], - out: [ - "x86_system_policy.cpp", - "x86_64_system_policy.cpp", - ], - }, - }, +cc_genrule { + name: "libseccomp_policy_app_zygote_sources_x86", + recovery_available: true, + cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)", + tools: [ "genseccomp" ], + srcs: [ + ":seccomp_syscalls_sources_zygote", + ":libseccomp_gen_syscall_nrs_x86", + ":libseccomp_gen_syscall_nrs_x86_64", + ], + out: [ + "x86_app_zygote_policy.cpp", + "x86_64_app_zygote_policy.cpp", + ], +} + +cc_genrule { + name: "libseccomp_policy_app_zygote_sources_arm", + recovery_available: true, + cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)", + tools: [ "genseccomp" ], + srcs: [ + ":seccomp_syscalls_sources_zygote", + ":libseccomp_gen_syscall_nrs_arm", + ":libseccomp_gen_syscall_nrs_arm64", + ], + out: [ + "arm_app_zygote_policy.cpp", + "arm64_app_zygote_policy.cpp", + ], +} + +cc_genrule { + name: "libseccomp_policy_app_zygote_sources_riscv64", + recovery_available: true, + cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)", + tools: [ "genseccomp" ], + srcs: [ + ":seccomp_syscalls_sources_zygote", + ":libseccomp_gen_syscall_nrs_riscv64", + ], + out: [ + "riscv64_app_zygote_policy.cpp", + ], +} + +cc_genrule { + name: "libseccomp_policy_app_sources_x86", + recovery_available: true, + cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)", + tools: [ "genseccomp" ], + srcs: [ + ":seccomp_syscalls_sources_app", + ":libseccomp_gen_syscall_nrs_x86", + ":libseccomp_gen_syscall_nrs_x86_64", + ], + out: [ + "x86_app_policy.cpp", + "x86_64_app_policy.cpp", + ], +} + +cc_genrule { + name: "libseccomp_policy_app_sources_arm", + recovery_available: true, + cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)", + tools: [ "genseccomp" ], + srcs: [ + ":seccomp_syscalls_sources_app", + ":libseccomp_gen_syscall_nrs_arm", + ":libseccomp_gen_syscall_nrs_arm64", + ], + out: [ + "arm_app_policy.cpp", + "arm64_app_policy.cpp", + ], +} + +cc_genrule { + name: "libseccomp_policy_app_sources_riscv64", + recovery_available: true, + cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)", + tools: [ "genseccomp" ], + srcs: [ + ":seccomp_syscalls_sources_app", + ":libseccomp_gen_syscall_nrs_riscv64", + ], + out: [ + "riscv64_app_policy.cpp", + ], +} + +cc_genrule { + name: "libseccomp_policy_system_sources_x86", + recovery_available: true, + cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)", + tools: [ "genseccomp" ], + srcs: [ + ":seccomp_syscalls_sources_system", + ":libseccomp_gen_syscall_nrs_x86", + ":libseccomp_gen_syscall_nrs_x86_64", + ], + out: [ + "x86_system_policy.cpp", + "x86_64_system_policy.cpp", + ], +} + +cc_genrule { + name: "libseccomp_policy_system_sources_arm", + recovery_available: true, + cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)", + tools: [ "genseccomp" ], + srcs: [ + ":seccomp_syscalls_sources_system", + ":libseccomp_gen_syscall_nrs_arm", + ":libseccomp_gen_syscall_nrs_arm64", + ], + out: [ + "arm_system_policy.cpp", + "arm64_system_policy.cpp", + ], +} + +cc_genrule { + name: "libseccomp_policy_system_sources_riscv64", + recovery_available: true, + cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)", + tools: [ "genseccomp" ], + srcs: [ + ":seccomp_syscalls_sources_system", + ":libseccomp_gen_syscall_nrs_riscv64", + ], + out: [ + "riscv64_system_policy.cpp", + ], } cc_library { name: "libseccomp_policy", recovery_available: true, generated_headers: ["func_to_syscall_nrs"], - generated_sources: [ - "libseccomp_policy_app_sources", - "libseccomp_policy_app_zygote_sources", - "libseccomp_policy_system_sources", - ], + + arch: { + arm: { + generated_sources: [ + "libseccomp_policy_app_sources_arm", + "libseccomp_policy_app_zygote_sources_arm", + "libseccomp_policy_system_sources_arm", + ], + }, + arm64: { + generated_sources: [ + "libseccomp_policy_app_sources_arm", + "libseccomp_policy_app_zygote_sources_arm", + "libseccomp_policy_system_sources_arm", + ], + }, + riscv64: { + generated_sources: [ + "libseccomp_policy_app_sources_riscv64", + "libseccomp_policy_app_zygote_sources_riscv64", + "libseccomp_policy_system_sources_riscv64", + ], + }, + x86: { + generated_sources: [ + "libseccomp_policy_app_sources_x86", + "libseccomp_policy_app_zygote_sources_x86", + "libseccomp_policy_system_sources_x86", + ], + }, + x86_64: { + generated_sources: [ + "libseccomp_policy_app_sources_x86", + "libseccomp_policy_app_zygote_sources_x86", + "libseccomp_policy_system_sources_x86", + ], + }, + }, srcs: [ "seccomp/seccomp_policy.cpp",