Skip to content

Commit

Permalink
Merge pull request #382 from google/add_armv7
Browse files Browse the repository at this point in the history
[bazel] Add armv7 and use alias for cpus
  • Loading branch information
gchatelet authored Dec 18, 2024
2 parents 5cfee57 + 91c50b6 commit 7d06d41
Showing 1 changed file with 48 additions and 36 deletions.
84 changes: 48 additions & 36 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ C99_FLAGS = select({
],
})

PLATFORM_CPU_X86 = ("@platforms//cpu:x86_32", "@platforms//cpu:x86_64")

PLATFORM_CPU_ARM = ("@platforms//cpu:arm", "@platforms//cpu:armv7")

PLATFORM_CPU_ARM64 = "@platforms//cpu:arm64"

PLATFORM_CPU_MIPS = "@platforms//cpu:mips64"

PLATFORM_CPU_PPC = "@platforms//cpu:ppc"

PLATFORM_CPU_RISCV = ("@platforms//cpu:riscv32", "@platforms//cpu:riscv64")

cc_library(
name = "cpu_features_macros",
copts = C99_FLAGS,
Expand Down Expand Up @@ -218,38 +230,38 @@ cc_library(
cc_library(
name = "cpuinfo",
srcs = selects.with_or({
("@platforms//cpu:x86_32", "@platforms//cpu:x86_64"): [
PLATFORM_CPU_X86: [
"src/impl_x86_freebsd.c",
"src/impl_x86_linux_or_android.c",
"src/impl_x86_macos.c",
"src/impl_x86_windows.c",
],
"@platforms//cpu:arm": ["src/impl_arm_linux_or_android.c"],
"@platforms//cpu:arm64": [
PLATFORM_CPU_ARM: ["src/impl_arm_linux_or_android.c"],
PLATFORM_CPU_ARM64: [
"src/impl_aarch64_cpuid.c",
"src/impl_aarch64_linux_or_android.c",
"src/impl_aarch64_macos_or_iphone.c",
"src/impl_aarch64_windows.c",
"src/impl_aarch64_freebsd_or_openbsd.c",
],
"@platforms//cpu:mips64": ["src/impl_mips_linux_or_android.c"],
"@platforms//cpu:ppc": ["src/impl_ppc_linux.c"],
("@platforms//cpu:riscv32", "@platforms//cpu:riscv64"): ["src/impl_riscv_linux.c"],
PLATFORM_CPU_MIPS: ["src/impl_mips_linux_or_android.c"],
PLATFORM_CPU_PPC: ["src/impl_ppc_linux.c"],
PLATFORM_CPU_RISCV: ["src/impl_riscv_linux.c"],
}),
hdrs = selects.with_or({
("@platforms//cpu:x86_32", "@platforms//cpu:x86_64"): [
PLATFORM_CPU_X86: [
"include/cpuinfo_x86.h",
"include/internal/cpuid_x86.h",
"include/internal/windows_utils.h",
],
"@platforms//cpu:arm": ["include/cpuinfo_arm.h"],
"@platforms//cpu:arm64": [
PLATFORM_CPU_ARM: ["include/cpuinfo_arm.h"],
PLATFORM_CPU_ARM64: [
"include/cpuinfo_aarch64.h",
"include/internal/cpuid_aarch64.h",
],
"@platforms//cpu:mips64": ["include/cpuinfo_mips.h"],
"@platforms//cpu:ppc": ["include/cpuinfo_ppc.h"],
("@platforms//cpu:riscv32", "@platforms//cpu:riscv64"): ["include/cpuinfo_riscv.h"],
PLATFORM_CPU_MIPS: ["include/cpuinfo_mips.h"],
PLATFORM_CPU_PPC: ["include/cpuinfo_ppc.h"],
PLATFORM_CPU_RISCV: ["include/cpuinfo_riscv.h"],
}),
copts = C99_FLAGS,
defines = selects.with_or({
Expand All @@ -258,8 +270,8 @@ cc_library(
}),
includes = INCLUDES,
textual_hdrs = selects.with_or({
("@platforms//cpu:x86_32", "@platforms//cpu:x86_64"): ["src/impl_x86__base_implementation.inl"],
"@platforms//cpu:arm64": ["src/impl_aarch64__base_implementation.inl"],
PLATFORM_CPU_X86: ["src/impl_x86__base_implementation.inl"],
PLATFORM_CPU_ARM64: ["src/impl_aarch64__base_implementation.inl"],
"//conditions:default": [],
}) + [
"src/define_introspection.inl",
Expand All @@ -281,43 +293,43 @@ cc_library(
name = "cpuinfo_for_testing",
testonly = 1,
srcs = selects.with_or({
("@platforms//cpu:x86_32", "@platforms//cpu:x86_64"): [
PLATFORM_CPU_X86: [
"src/impl_x86_freebsd.c",
"src/impl_x86_linux_or_android.c",
"src/impl_x86_macos.c",
"src/impl_x86_windows.c",
],
"@platforms//cpu:arm": ["src/impl_arm_linux_or_android.c"],
"@platforms//cpu:arm64": [
PLATFORM_CPU_ARM: ["src/impl_arm_linux_or_android.c"],
PLATFORM_CPU_ARM64: [
"src/impl_aarch64_cpuid.c",
"src/impl_aarch64_linux_or_android.c",
"src/impl_aarch64_macos_or_iphone.c",
"src/impl_aarch64_windows.c",
"src/impl_aarch64_freebsd_or_openbsd.c",
],
"@platforms//cpu:mips64": ["src/impl_mips_linux_or_android.c"],
"@platforms//cpu:ppc": ["src/impl_ppc_linux.c"],
("@platforms//cpu:riscv32", "@platforms//cpu:riscv64"): ["src/impl_riscv_linux.c"],
PLATFORM_CPU_MIPS: ["src/impl_mips_linux_or_android.c"],
PLATFORM_CPU_PPC: ["src/impl_ppc_linux.c"],
PLATFORM_CPU_RISCV: ["src/impl_riscv_linux.c"],
}),
hdrs = selects.with_or({
("@platforms//cpu:x86_32", "@platforms//cpu:x86_64"): [
PLATFORM_CPU_X86: [
"include/cpuinfo_x86.h",
"include/internal/cpuid_x86.h",
"include/internal/windows_utils.h",
],
"@platforms//cpu:arm": ["include/cpuinfo_arm.h"],
"@platforms//cpu:arm64": [
PLATFORM_CPU_ARM: ["include/cpuinfo_arm.h"],
PLATFORM_CPU_ARM64: [
"include/cpuinfo_aarch64.h",
"include/internal/cpuid_aarch64.h",
],
"@platforms//cpu:mips64": ["include/cpuinfo_mips.h"],
"@platforms//cpu:ppc": ["include/cpuinfo_ppc.h"],
("@platforms//cpu:riscv32", "@platforms//cpu:riscv64"): ["include/cpuinfo_riscv.h"],
PLATFORM_CPU_MIPS: ["include/cpuinfo_mips.h"],
PLATFORM_CPU_PPC: ["include/cpuinfo_ppc.h"],
PLATFORM_CPU_RISCV: ["include/cpuinfo_riscv.h"],
}),
copts = C99_FLAGS,
defines = selects.with_or({
("@platforms//cpu:x86_32", "@platforms//cpu:x86_64"): ["CPU_FEATURES_MOCK_CPUID_X86"],
"@platforms//cpu:arm64": [
PLATFORM_CPU_X86: ["CPU_FEATURES_MOCK_CPUID_X86"],
PLATFORM_CPU_ARM64: [
"CPU_FEATURES_MOCK_CPUID_AARCH64",
"CPU_FEATURES_MOCK_SYSCTL_AARCH64",
],
Expand All @@ -328,8 +340,8 @@ cc_library(
}),
includes = INCLUDES,
textual_hdrs = selects.with_or({
("@platforms//cpu:x86_32", "@platforms//cpu:x86_64"): ["src/impl_x86__base_implementation.inl"],
"@platforms//cpu:arm64": ["src/impl_aarch64__base_implementation.inl"],
PLATFORM_CPU_X86: ["src/impl_x86__base_implementation.inl"],
PLATFORM_CPU_ARM64: ["src/impl_aarch64__base_implementation.inl"],
"//conditions:default": [],
}) + [
"src/define_introspection.inl",
Expand All @@ -350,12 +362,12 @@ cc_library(
cc_test(
name = "cpuinfo_test",
srcs = selects.with_or({
"@platforms//cpu:arm64": ["test/cpuinfo_aarch64_test.cc"],
"@platforms//cpu:arm": ["test/cpuinfo_arm_test.cc"],
"@platforms//cpu:mips64": ["test/cpuinfo_mips_test.cc"],
"@platforms//cpu:ppc": ["test/cpuinfo_ppc_test.cc"],
("@platforms//cpu:riscv32", "@platforms//cpu:riscv64"): ["test/cpuinfo_riscv_test.cc"],
("@platforms//cpu:x86_32", "@platforms//cpu:x86_64"): ["test/cpuinfo_x86_test.cc"],
PLATFORM_CPU_ARM64: ["test/cpuinfo_aarch64_test.cc"],
PLATFORM_CPU_ARM: ["test/cpuinfo_arm_test.cc"],
PLATFORM_CPU_MIPS: ["test/cpuinfo_mips_test.cc"],
PLATFORM_CPU_PPC: ["test/cpuinfo_ppc_test.cc"],
PLATFORM_CPU_RISCV: ["test/cpuinfo_riscv_test.cc"],
PLATFORM_CPU_X86: ["test/cpuinfo_x86_test.cc"],
}),
includes = INCLUDES,
deps = [
Expand Down

0 comments on commit 7d06d41

Please sign in to comment.