@@ -27,6 +27,18 @@ C99_FLAGS = select({
27
27
],
28
28
})
29
29
30
+ PLATFORM_CPU_X86 = ("@platforms//cpu:x86_32" , "@platforms//cpu:x86_64" )
31
+
32
+ PLATFORM_CPU_ARM = ("@platforms//cpu:arm" , "@platforms//cpu:armv7" )
33
+
34
+ PLATFORM_CPU_ARM64 = "@platforms//cpu:arm64"
35
+
36
+ PLATFORM_CPU_MIPS = "@platforms//cpu:mips64"
37
+
38
+ PLATFORM_CPU_PPC = "@platforms//cpu:ppc"
39
+
40
+ PLATFORM_CPU_RISCV = ("@platforms//cpu:riscv32" , "@platforms//cpu:riscv64" )
41
+
30
42
cc_library (
31
43
name = "cpu_features_macros" ,
32
44
copts = C99_FLAGS ,
@@ -218,38 +230,38 @@ cc_library(
218
230
cc_library (
219
231
name = "cpuinfo" ,
220
232
srcs = selects .with_or ({
221
- ( "@platforms//cpu:x86_32" , "@platforms//cpu:x86_64" ) : [
233
+ PLATFORM_CPU_X86 : [
222
234
"src/impl_x86_freebsd.c" ,
223
235
"src/impl_x86_linux_or_android.c" ,
224
236
"src/impl_x86_macos.c" ,
225
237
"src/impl_x86_windows.c" ,
226
238
],
227
- "@platforms//cpu:arm" : ["src/impl_arm_linux_or_android.c" ],
228
- "@platforms//cpu:arm64" : [
239
+ PLATFORM_CPU_ARM : ["src/impl_arm_linux_or_android.c" ],
240
+ PLATFORM_CPU_ARM64 : [
229
241
"src/impl_aarch64_cpuid.c" ,
230
242
"src/impl_aarch64_linux_or_android.c" ,
231
243
"src/impl_aarch64_macos_or_iphone.c" ,
232
244
"src/impl_aarch64_windows.c" ,
233
245
"src/impl_aarch64_freebsd_or_openbsd.c" ,
234
246
],
235
- "@platforms//cpu:mips64" : ["src/impl_mips_linux_or_android.c" ],
236
- "@platforms//cpu:ppc" : ["src/impl_ppc_linux.c" ],
237
- ( "@platforms//cpu:riscv32" , "@platforms//cpu:riscv64" ) : ["src/impl_riscv_linux.c" ],
247
+ PLATFORM_CPU_MIPS : ["src/impl_mips_linux_or_android.c" ],
248
+ PLATFORM_CPU_PPC : ["src/impl_ppc_linux.c" ],
249
+ PLATFORM_CPU_RISCV : ["src/impl_riscv_linux.c" ],
238
250
}),
239
251
hdrs = selects .with_or ({
240
- ( "@platforms//cpu:x86_32" , "@platforms//cpu:x86_64" ) : [
252
+ PLATFORM_CPU_X86 : [
241
253
"include/cpuinfo_x86.h" ,
242
254
"include/internal/cpuid_x86.h" ,
243
255
"include/internal/windows_utils.h" ,
244
256
],
245
- "@platforms//cpu:arm" : ["include/cpuinfo_arm.h" ],
246
- "@platforms//cpu:arm64" : [
257
+ PLATFORM_CPU_ARM : ["include/cpuinfo_arm.h" ],
258
+ PLATFORM_CPU_ARM64 : [
247
259
"include/cpuinfo_aarch64.h" ,
248
260
"include/internal/cpuid_aarch64.h" ,
249
261
],
250
- "@platforms//cpu:mips64" : ["include/cpuinfo_mips.h" ],
251
- "@platforms//cpu:ppc" : ["include/cpuinfo_ppc.h" ],
252
- ( "@platforms//cpu:riscv32" , "@platforms//cpu:riscv64" ) : ["include/cpuinfo_riscv.h" ],
262
+ PLATFORM_CPU_MIPS : ["include/cpuinfo_mips.h" ],
263
+ PLATFORM_CPU_PPC : ["include/cpuinfo_ppc.h" ],
264
+ PLATFORM_CPU_RISCV : ["include/cpuinfo_riscv.h" ],
253
265
}),
254
266
copts = C99_FLAGS ,
255
267
defines = selects .with_or ({
@@ -258,8 +270,8 @@ cc_library(
258
270
}),
259
271
includes = INCLUDES ,
260
272
textual_hdrs = selects .with_or ({
261
- ( "@platforms//cpu:x86_32" , "@platforms//cpu:x86_64" ) : ["src/impl_x86__base_implementation.inl" ],
262
- "@platforms//cpu:arm64" : ["src/impl_aarch64__base_implementation.inl" ],
273
+ PLATFORM_CPU_X86 : ["src/impl_x86__base_implementation.inl" ],
274
+ PLATFORM_CPU_ARM64 : ["src/impl_aarch64__base_implementation.inl" ],
263
275
"//conditions:default" : [],
264
276
}) + [
265
277
"src/define_introspection.inl" ,
@@ -281,43 +293,43 @@ cc_library(
281
293
name = "cpuinfo_for_testing" ,
282
294
testonly = 1 ,
283
295
srcs = selects .with_or ({
284
- ( "@platforms//cpu:x86_32" , "@platforms//cpu:x86_64" ) : [
296
+ PLATFORM_CPU_X86 : [
285
297
"src/impl_x86_freebsd.c" ,
286
298
"src/impl_x86_linux_or_android.c" ,
287
299
"src/impl_x86_macos.c" ,
288
300
"src/impl_x86_windows.c" ,
289
301
],
290
- "@platforms//cpu:arm" : ["src/impl_arm_linux_or_android.c" ],
291
- "@platforms//cpu:arm64" : [
302
+ PLATFORM_CPU_ARM : ["src/impl_arm_linux_or_android.c" ],
303
+ PLATFORM_CPU_ARM64 : [
292
304
"src/impl_aarch64_cpuid.c" ,
293
305
"src/impl_aarch64_linux_or_android.c" ,
294
306
"src/impl_aarch64_macos_or_iphone.c" ,
295
307
"src/impl_aarch64_windows.c" ,
296
308
"src/impl_aarch64_freebsd_or_openbsd.c" ,
297
309
],
298
- "@platforms//cpu:mips64" : ["src/impl_mips_linux_or_android.c" ],
299
- "@platforms//cpu:ppc" : ["src/impl_ppc_linux.c" ],
300
- ( "@platforms//cpu:riscv32" , "@platforms//cpu:riscv64" ) : ["src/impl_riscv_linux.c" ],
310
+ PLATFORM_CPU_MIPS : ["src/impl_mips_linux_or_android.c" ],
311
+ PLATFORM_CPU_PPC : ["src/impl_ppc_linux.c" ],
312
+ PLATFORM_CPU_RISCV : ["src/impl_riscv_linux.c" ],
301
313
}),
302
314
hdrs = selects .with_or ({
303
- ( "@platforms//cpu:x86_32" , "@platforms//cpu:x86_64" ) : [
315
+ PLATFORM_CPU_X86 : [
304
316
"include/cpuinfo_x86.h" ,
305
317
"include/internal/cpuid_x86.h" ,
306
318
"include/internal/windows_utils.h" ,
307
319
],
308
- "@platforms//cpu:arm" : ["include/cpuinfo_arm.h" ],
309
- "@platforms//cpu:arm64" : [
320
+ PLATFORM_CPU_ARM : ["include/cpuinfo_arm.h" ],
321
+ PLATFORM_CPU_ARM64 : [
310
322
"include/cpuinfo_aarch64.h" ,
311
323
"include/internal/cpuid_aarch64.h" ,
312
324
],
313
- "@platforms//cpu:mips64" : ["include/cpuinfo_mips.h" ],
314
- "@platforms//cpu:ppc" : ["include/cpuinfo_ppc.h" ],
315
- ( "@platforms//cpu:riscv32" , "@platforms//cpu:riscv64" ) : ["include/cpuinfo_riscv.h" ],
325
+ PLATFORM_CPU_MIPS : ["include/cpuinfo_mips.h" ],
326
+ PLATFORM_CPU_PPC : ["include/cpuinfo_ppc.h" ],
327
+ PLATFORM_CPU_RISCV : ["include/cpuinfo_riscv.h" ],
316
328
}),
317
329
copts = C99_FLAGS ,
318
330
defines = selects .with_or ({
319
- ( "@platforms//cpu:x86_32" , "@platforms//cpu:x86_64" ) : ["CPU_FEATURES_MOCK_CPUID_X86" ],
320
- "@platforms//cpu:arm64" : [
331
+ PLATFORM_CPU_X86 : ["CPU_FEATURES_MOCK_CPUID_X86" ],
332
+ PLATFORM_CPU_ARM64 : [
321
333
"CPU_FEATURES_MOCK_CPUID_AARCH64" ,
322
334
"CPU_FEATURES_MOCK_SYSCTL_AARCH64" ,
323
335
],
@@ -328,8 +340,8 @@ cc_library(
328
340
}),
329
341
includes = INCLUDES ,
330
342
textual_hdrs = selects .with_or ({
331
- ( "@platforms//cpu:x86_32" , "@platforms//cpu:x86_64" ) : ["src/impl_x86__base_implementation.inl" ],
332
- "@platforms//cpu:arm64" : ["src/impl_aarch64__base_implementation.inl" ],
343
+ PLATFORM_CPU_X86 : ["src/impl_x86__base_implementation.inl" ],
344
+ PLATFORM_CPU_ARM64 : ["src/impl_aarch64__base_implementation.inl" ],
333
345
"//conditions:default" : [],
334
346
}) + [
335
347
"src/define_introspection.inl" ,
@@ -350,12 +362,12 @@ cc_library(
350
362
cc_test (
351
363
name = "cpuinfo_test" ,
352
364
srcs = selects .with_or ({
353
- "@platforms//cpu:arm64" : ["test/cpuinfo_aarch64_test.cc" ],
354
- "@platforms//cpu:arm" : ["test/cpuinfo_arm_test.cc" ],
355
- "@platforms//cpu:mips64" : ["test/cpuinfo_mips_test.cc" ],
356
- "@platforms//cpu:ppc" : ["test/cpuinfo_ppc_test.cc" ],
357
- ( "@platforms//cpu:riscv32" , "@platforms//cpu:riscv64" ) : ["test/cpuinfo_riscv_test.cc" ],
358
- ( "@platforms//cpu:x86_32" , "@platforms//cpu:x86_64" ) : ["test/cpuinfo_x86_test.cc" ],
365
+ PLATFORM_CPU_ARM64 : ["test/cpuinfo_aarch64_test.cc" ],
366
+ PLATFORM_CPU_ARM : ["test/cpuinfo_arm_test.cc" ],
367
+ PLATFORM_CPU_MIPS : ["test/cpuinfo_mips_test.cc" ],
368
+ PLATFORM_CPU_PPC : ["test/cpuinfo_ppc_test.cc" ],
369
+ PLATFORM_CPU_RISCV : ["test/cpuinfo_riscv_test.cc" ],
370
+ PLATFORM_CPU_X86 : ["test/cpuinfo_x86_test.cc" ],
359
371
}),
360
372
includes = INCLUDES ,
361
373
deps = [
0 commit comments