Skip to content

Commit def797f

Browse files
authored
Merge branch 'main' into patch-1
2 parents d898d1a + ec7d390 commit def797f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2245
-415
lines changed

.dockerignore

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
# Project Files unneeded by docker
2-
cmake/ci/Makefile
3-
cmake/ci/docker
4-
cmake/ci/doc
5-
cmake/ci/cache
62
.git
73
.gitignore
84
.github
@@ -16,6 +12,15 @@ CONTRIBUTORS
1612
LICENSE
1713
README.md
1814

15+
bazel/ci/Makefile
16+
bazel/ci/docker
17+
bazel/ci/doc
18+
19+
cmake/ci/Makefile
20+
cmake/ci/docker
21+
cmake/ci/doc
22+
cmake/ci/cache
23+
1924
build/
2025
cmake_build/
2126
build_cross/

.github/workflows/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
FROM alpine:edge
44
# Install system build dependencies
55
RUN apk add --no-cache git clang-extra-tools
6+
RUN git config --global --add safe.directory /repo
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: AArch64 Linux Bazel
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
# min hours day(month) month day(week)
8+
- cron: '0 0 7,22 * *'
9+
10+
jobs:
11+
# Building using the github runner environement directly.
12+
bazel:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out repository code
16+
uses: actions/checkout@v3
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v2
19+
- name: Check docker
20+
run: |
21+
docker info
22+
docker buildx ls
23+
- name: Build
24+
run: make --directory=bazel/ci arm64_build
25+
- name: Test
26+
run: make --directory=bazel/ci arm64_test

.github/workflows/amd64_freebsd_cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
# Only MacOS hosted runner provides virtualisation with vagrant/virtualbox installed.
1212
# see: https://github.com/actions/virtual-environments/tree/main/images/macos
1313
make:
14-
runs-on: macos-10.15
14+
runs-on: macos-latest
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: vagrant version

.github/workflows/amd64_linux_bazel.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Check out repository code
16-
uses: actions/checkout@v2
17-
- name: Install Bazel
16+
uses: actions/checkout@v3
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v2
19+
- name: Check docker
1820
run: |
19-
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
20-
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
21-
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
22-
sudo apt-get update
23-
sudo apt-get install bazel
24-
bazel --version
21+
docker info
22+
docker buildx ls
23+
- name: Build
24+
run: make --directory=bazel/ci amd64_build
2525
- name: Test
26-
run: bazel test -s --verbose_failures //...
26+
run: make --directory=bazel/ci amd64_test
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: amd64 MacOS Bazel
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
# min hours day(month) month day(week)
8+
- cron: '0 0 7,22 * *'
9+
10+
jobs:
11+
# Building using the github runner environement directly.
12+
bazel:
13+
runs-on: macos-latest
14+
steps:
15+
- name: Check out repository code
16+
uses: actions/checkout@v3
17+
- name: Install Bazel
18+
run: |
19+
brew update
20+
brew unlink bazelisk
21+
brew install bazel
22+
- name: Check Bazel
23+
run: bazel version
24+
- name: Build
25+
run: >
26+
bazel build
27+
-c opt
28+
--subcommands=true
29+
...
30+
- name: Test
31+
run: >
32+
bazel test
33+
-c opt
34+
--test_output=errors
35+
...

.github/workflows/clang_format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
clang-format:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v4
1111
- name: Fetch origin/main
1212
run: git fetch origin main
1313
- name: List of changed file(s)

BUILD.bazel

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# cpu_features, a cross platform C99 library to get cpu features at runtime.
22

33
load("@bazel_skylib//lib:selects.bzl", "selects")
4-
load("//:bazel/platforms.bzl", "PLATFORM_CPU_ARM", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_MIPS", "PLATFORM_CPU_PPC", "PLATFORM_CPU_X86_64")
4+
load("//:bazel/platforms.bzl", "PLATFORM_CPU_ARM", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_MIPS", "PLATFORM_CPU_PPC", "PLATFORM_CPU_RISCV32", "PLATFORM_CPU_RISCV64", "PLATFORM_CPU_X86_64")
5+
load("//:bazel/platforms.bzl", "PLATFORM_OS_MACOS", "PLATFORM_OS_LINUX", "PLATFORM_OS_FREEBSD", "PLATFORM_OS_ANDROID")
56

67
package(
78
default_visibility = ["//visibility:public"],
@@ -168,9 +169,19 @@ cc_library(
168169

169170
cc_library(
170171
name = "hwcaps",
171-
srcs = ["src/hwcaps.c"],
172+
srcs = [
173+
"src/hwcaps.c",
174+
"src/hwcaps_freebsd.c",
175+
"src/hwcaps_linux_or_android.c",
176+
],
172177
copts = C99_FLAGS,
173-
defines = ["HAVE_STRONG_GETAUXVAL"],
178+
defines = selects.with_or({
179+
PLATFORM_OS_MACOS: ["HAVE_DLFCN_H"],
180+
PLATFORM_OS_FREEBSD: ["HAVE_STRONG_ELF_AUX_INFO"],
181+
PLATFORM_OS_LINUX: ["HAVE_STRONG_GETAUXVAL"],
182+
PLATFORM_OS_ANDROID: ["HAVE_STRONG_GETAUXVAL"],
183+
"//conditions:default": [],
184+
}),
174185
includes = INCLUDES,
175186
textual_hdrs = ["include/internal/hwcaps.h"],
176187
deps = [
@@ -185,6 +196,8 @@ cc_library(
185196
testonly = 1,
186197
srcs = [
187198
"src/hwcaps.c",
199+
"src/hwcaps_freebsd.c",
200+
"src/hwcaps_linux_or_android.c",
188201
"test/hwcaps_for_testing.cc",
189202
],
190203
hdrs = [
@@ -213,26 +226,47 @@ cc_library(
213226
"src/impl_x86_windows.c",
214227
],
215228
PLATFORM_CPU_ARM: ["src/impl_arm_linux_or_android.c"],
216-
PLATFORM_CPU_ARM64: ["src/impl_aarch64_linux_or_android.c"],
229+
PLATFORM_CPU_ARM64: [
230+
"src/impl_aarch64_cpuid.c",
231+
"src/impl_aarch64_linux_or_android.c",
232+
"src/impl_aarch64_macos_or_iphone.c",
233+
"src/impl_aarch64_windows.c",
234+
"src/impl_aarch64_freebsd.c",
235+
],
217236
PLATFORM_CPU_MIPS: ["src/impl_mips_linux_or_android.c"],
218237
PLATFORM_CPU_PPC: [
219238
"src/impl_ppc_freebsd.c",
220239
"src/impl_ppc_linux.c",
221240
],
241+
PLATFORM_CPU_RISCV32: ["src/impl_riscv_linux.c"],
242+
PLATFORM_CPU_RISCV64: ["src/impl_riscv_linux.c"],
222243
}),
223-
copts = C99_FLAGS,
224-
includes = INCLUDES,
225-
textual_hdrs = selects.with_or({
244+
hdrs = selects.with_or({
226245
PLATFORM_CPU_X86_64: [
227-
"src/impl_x86__base_implementation.inl",
228246
"include/cpuinfo_x86.h",
229247
"include/internal/cpuid_x86.h",
230248
"include/internal/windows_utils.h",
231249
],
232250
PLATFORM_CPU_ARM: ["include/cpuinfo_arm.h"],
233-
PLATFORM_CPU_ARM64: ["include/cpuinfo_aarch64.h"],
251+
PLATFORM_CPU_ARM64: [
252+
"include/cpuinfo_aarch64.h",
253+
"include/internal/cpuid_aarch64.h",
254+
],
234255
PLATFORM_CPU_MIPS: ["include/cpuinfo_mips.h"],
235256
PLATFORM_CPU_PPC: ["include/cpuinfo_ppc.h"],
257+
PLATFORM_CPU_RISCV32: ["include/cpuinfo_riscv.h"],
258+
PLATFORM_CPU_RISCV64: ["include/cpuinfo_riscv.h"],
259+
}),
260+
copts = C99_FLAGS,
261+
defines = selects.with_or({
262+
PLATFORM_OS_MACOS: ["HAVE_SYSCTLBYNAME"],
263+
"//conditions:default": [],
264+
}),
265+
includes = INCLUDES,
266+
textual_hdrs = selects.with_or({
267+
PLATFORM_CPU_X86_64: ["src/impl_x86__base_implementation.inl"],
268+
PLATFORM_CPU_ARM64: ["src/impl_aarch64__base_implementation.inl"],
269+
"//conditions:default": [],
236270
}) + [
237271
"src/define_introspection.inl",
238272
"src/define_introspection_and_hwcaps.inl",
@@ -260,12 +294,20 @@ cc_library(
260294
"src/impl_x86_windows.c",
261295
],
262296
PLATFORM_CPU_ARM: ["src/impl_arm_linux_or_android.c"],
263-
PLATFORM_CPU_ARM64: ["src/impl_aarch64_linux_or_android.c"],
297+
PLATFORM_CPU_ARM64: [
298+
"src/impl_aarch64_cpuid.c",
299+
"src/impl_aarch64_linux_or_android.c",
300+
"src/impl_aarch64_macos_or_iphone.c",
301+
"src/impl_aarch64_windows.c",
302+
"src/impl_aarch64_freebsd.c",
303+
],
264304
PLATFORM_CPU_MIPS: ["src/impl_mips_linux_or_android.c"],
265305
PLATFORM_CPU_PPC: [
266306
"src/impl_ppc_freebsd.c",
267307
"src/impl_ppc_linux.c",
268308
],
309+
PLATFORM_CPU_RISCV32: ["src/impl_riscv_linux.c"],
310+
PLATFORM_CPU_RISCV64: ["src/impl_riscv_linux.c"],
269311
}),
270312
hdrs = selects.with_or({
271313
PLATFORM_CPU_X86_64: [
@@ -274,18 +316,27 @@ cc_library(
274316
"include/internal/windows_utils.h",
275317
],
276318
PLATFORM_CPU_ARM: ["include/cpuinfo_arm.h"],
277-
PLATFORM_CPU_ARM64: ["include/cpuinfo_aarch64.h"],
319+
PLATFORM_CPU_ARM64: [
320+
"include/cpuinfo_aarch64.h",
321+
"include/internal/cpuid_aarch64.h"
322+
],
278323
PLATFORM_CPU_MIPS: ["include/cpuinfo_mips.h"],
279324
PLATFORM_CPU_PPC: ["include/cpuinfo_ppc.h"],
325+
PLATFORM_CPU_RISCV32: ["include/cpuinfo_riscv.h"],
326+
PLATFORM_CPU_RISCV64: ["include/cpuinfo_riscv.h"],
280327
}),
281328
copts = C99_FLAGS,
282329
defines = selects.with_or({
283330
PLATFORM_CPU_X86_64: ["CPU_FEATURES_MOCK_CPUID_X86"],
284331
"//conditions:default": [],
332+
}) + selects.with_or({
333+
PLATFORM_OS_MACOS: ["HAVE_SYSCTLBYNAME"],
334+
"//conditions:default": [],
285335
}),
286336
includes = INCLUDES,
287337
textual_hdrs = selects.with_or({
288338
PLATFORM_CPU_X86_64: ["src/impl_x86__base_implementation.inl"],
339+
PLATFORM_CPU_ARM64: ["src/impl_aarch64__base_implementation.inl"],
289340
"//conditions:default": [],
290341
}) + [
291342
"src/define_introspection.inl",
@@ -310,6 +361,8 @@ cc_test(
310361
PLATFORM_CPU_ARM: ["test/cpuinfo_arm_test.cc"],
311362
PLATFORM_CPU_MIPS: ["test/cpuinfo_mips_test.cc"],
312363
PLATFORM_CPU_PPC: ["test/cpuinfo_ppc_test.cc"],
364+
PLATFORM_CPU_RISCV32: ["test/cpuinfo_riscv_test.cc"],
365+
PLATFORM_CPU_RISCV64: ["test/cpuinfo_riscv_test.cc"],
313366
PLATFORM_CPU_X86_64: ["test/cpuinfo_x86_test.cc"],
314367
}),
315368
includes = INCLUDES,
@@ -333,3 +386,18 @@ cc_binary(
333386
":cpuinfo",
334387
],
335388
)
389+
390+
cc_library(
391+
name = "ndk_compat",
392+
srcs = ["ndk_compat/cpu-features.c"],
393+
copts = C99_FLAGS,
394+
includes = INCLUDES + ["ndk_compat"],
395+
textual_hdrs = ["ndk_compat/cpu-features.h"],
396+
deps = [
397+
":cpu_features_macros",
398+
":cpuinfo",
399+
":filesystem",
400+
":stack_line_reader",
401+
":string_view",
402+
],
403+
)

0 commit comments

Comments
 (0)