Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kgotlinux authored Sep 23, 2023
2 parents d898d1a + ec7d390 commit def797f
Show file tree
Hide file tree
Showing 42 changed files with 2,245 additions and 415 deletions.
13 changes: 9 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Project Files unneeded by docker
cmake/ci/Makefile
cmake/ci/docker
cmake/ci/doc
cmake/ci/cache
.git
.gitignore
.github
Expand All @@ -16,6 +12,15 @@ CONTRIBUTORS
LICENSE
README.md

bazel/ci/Makefile
bazel/ci/docker
bazel/ci/doc

cmake/ci/Makefile
cmake/ci/docker
cmake/ci/doc
cmake/ci/cache

build/
cmake_build/
build_cross/
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
FROM alpine:edge
# Install system build dependencies
RUN apk add --no-cache git clang-extra-tools
RUN git config --global --add safe.directory /repo
26 changes: 26 additions & 0 deletions .github/workflows/aarch64_linux_bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: AArch64 Linux Bazel

on:
push:
pull_request:
schedule:
# min hours day(month) month day(week)
- cron: '0 0 7,22 * *'

jobs:
# Building using the github runner environement directly.
bazel:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Check docker
run: |
docker info
docker buildx ls
- name: Build
run: make --directory=bazel/ci arm64_build
- name: Test
run: make --directory=bazel/ci arm64_test
2 changes: 1 addition & 1 deletion .github/workflows/amd64_freebsd_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
# Only MacOS hosted runner provides virtualisation with vagrant/virtualbox installed.
# see: https://github.com/actions/virtual-environments/tree/main/images/macos
make:
runs-on: macos-10.15
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: vagrant version
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/amd64_linux_bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Install Bazel
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Check docker
run: |
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
sudo apt-get update
sudo apt-get install bazel
bazel --version
docker info
docker buildx ls
- name: Build
run: make --directory=bazel/ci amd64_build
- name: Test
run: bazel test -s --verbose_failures //...
run: make --directory=bazel/ci amd64_test
35 changes: 35 additions & 0 deletions .github/workflows/amd64_macos_bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: amd64 MacOS Bazel

on:
push:
pull_request:
schedule:
# min hours day(month) month day(week)
- cron: '0 0 7,22 * *'

jobs:
# Building using the github runner environement directly.
bazel:
runs-on: macos-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Bazel
run: |
brew update
brew unlink bazelisk
brew install bazel
- name: Check Bazel
run: bazel version
- name: Build
run: >
bazel build
-c opt
--subcommands=true
...
- name: Test
run: >
bazel test
-c opt
--test_output=errors
...
2 changes: 1 addition & 1 deletion .github/workflows/clang_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch origin/main
run: git fetch origin main
- name: List of changed file(s)
Expand Down
90 changes: 79 additions & 11 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# cpu_features, a cross platform C99 library to get cpu features at runtime.

load("@bazel_skylib//lib:selects.bzl", "selects")
load("//:bazel/platforms.bzl", "PLATFORM_CPU_ARM", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_MIPS", "PLATFORM_CPU_PPC", "PLATFORM_CPU_X86_64")
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")
load("//:bazel/platforms.bzl", "PLATFORM_OS_MACOS", "PLATFORM_OS_LINUX", "PLATFORM_OS_FREEBSD", "PLATFORM_OS_ANDROID")

package(
default_visibility = ["//visibility:public"],
Expand Down Expand Up @@ -168,9 +169,19 @@ cc_library(

cc_library(
name = "hwcaps",
srcs = ["src/hwcaps.c"],
srcs = [
"src/hwcaps.c",
"src/hwcaps_freebsd.c",
"src/hwcaps_linux_or_android.c",
],
copts = C99_FLAGS,
defines = ["HAVE_STRONG_GETAUXVAL"],
defines = selects.with_or({
PLATFORM_OS_MACOS: ["HAVE_DLFCN_H"],
PLATFORM_OS_FREEBSD: ["HAVE_STRONG_ELF_AUX_INFO"],
PLATFORM_OS_LINUX: ["HAVE_STRONG_GETAUXVAL"],
PLATFORM_OS_ANDROID: ["HAVE_STRONG_GETAUXVAL"],
"//conditions:default": [],
}),
includes = INCLUDES,
textual_hdrs = ["include/internal/hwcaps.h"],
deps = [
Expand All @@ -185,6 +196,8 @@ cc_library(
testonly = 1,
srcs = [
"src/hwcaps.c",
"src/hwcaps_freebsd.c",
"src/hwcaps_linux_or_android.c",
"test/hwcaps_for_testing.cc",
],
hdrs = [
Expand Down Expand Up @@ -213,26 +226,47 @@ cc_library(
"src/impl_x86_windows.c",
],
PLATFORM_CPU_ARM: ["src/impl_arm_linux_or_android.c"],
PLATFORM_CPU_ARM64: ["src/impl_aarch64_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.c",
],
PLATFORM_CPU_MIPS: ["src/impl_mips_linux_or_android.c"],
PLATFORM_CPU_PPC: [
"src/impl_ppc_freebsd.c",
"src/impl_ppc_linux.c",
],
PLATFORM_CPU_RISCV32: ["src/impl_riscv_linux.c"],
PLATFORM_CPU_RISCV64: ["src/impl_riscv_linux.c"],
}),
copts = C99_FLAGS,
includes = INCLUDES,
textual_hdrs = selects.with_or({
hdrs = selects.with_or({
PLATFORM_CPU_X86_64: [
"src/impl_x86__base_implementation.inl",
"include/cpuinfo_x86.h",
"include/internal/cpuid_x86.h",
"include/internal/windows_utils.h",
],
PLATFORM_CPU_ARM: ["include/cpuinfo_arm.h"],
PLATFORM_CPU_ARM64: ["include/cpuinfo_aarch64.h"],
PLATFORM_CPU_ARM64: [
"include/cpuinfo_aarch64.h",
"include/internal/cpuid_aarch64.h",
],
PLATFORM_CPU_MIPS: ["include/cpuinfo_mips.h"],
PLATFORM_CPU_PPC: ["include/cpuinfo_ppc.h"],
PLATFORM_CPU_RISCV32: ["include/cpuinfo_riscv.h"],
PLATFORM_CPU_RISCV64: ["include/cpuinfo_riscv.h"],
}),
copts = C99_FLAGS,
defines = selects.with_or({
PLATFORM_OS_MACOS: ["HAVE_SYSCTLBYNAME"],
"//conditions:default": [],
}),
includes = INCLUDES,
textual_hdrs = selects.with_or({
PLATFORM_CPU_X86_64: ["src/impl_x86__base_implementation.inl"],
PLATFORM_CPU_ARM64: ["src/impl_aarch64__base_implementation.inl"],
"//conditions:default": [],
}) + [
"src/define_introspection.inl",
"src/define_introspection_and_hwcaps.inl",
Expand Down Expand Up @@ -260,12 +294,20 @@ cc_library(
"src/impl_x86_windows.c",
],
PLATFORM_CPU_ARM: ["src/impl_arm_linux_or_android.c"],
PLATFORM_CPU_ARM64: ["src/impl_aarch64_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.c",
],
PLATFORM_CPU_MIPS: ["src/impl_mips_linux_or_android.c"],
PLATFORM_CPU_PPC: [
"src/impl_ppc_freebsd.c",
"src/impl_ppc_linux.c",
],
PLATFORM_CPU_RISCV32: ["src/impl_riscv_linux.c"],
PLATFORM_CPU_RISCV64: ["src/impl_riscv_linux.c"],
}),
hdrs = selects.with_or({
PLATFORM_CPU_X86_64: [
Expand All @@ -274,18 +316,27 @@ cc_library(
"include/internal/windows_utils.h",
],
PLATFORM_CPU_ARM: ["include/cpuinfo_arm.h"],
PLATFORM_CPU_ARM64: ["include/cpuinfo_aarch64.h"],
PLATFORM_CPU_ARM64: [
"include/cpuinfo_aarch64.h",
"include/internal/cpuid_aarch64.h"
],
PLATFORM_CPU_MIPS: ["include/cpuinfo_mips.h"],
PLATFORM_CPU_PPC: ["include/cpuinfo_ppc.h"],
PLATFORM_CPU_RISCV32: ["include/cpuinfo_riscv.h"],
PLATFORM_CPU_RISCV64: ["include/cpuinfo_riscv.h"],
}),
copts = C99_FLAGS,
defines = selects.with_or({
PLATFORM_CPU_X86_64: ["CPU_FEATURES_MOCK_CPUID_X86"],
"//conditions:default": [],
}) + selects.with_or({
PLATFORM_OS_MACOS: ["HAVE_SYSCTLBYNAME"],
"//conditions:default": [],
}),
includes = INCLUDES,
textual_hdrs = selects.with_or({
PLATFORM_CPU_X86_64: ["src/impl_x86__base_implementation.inl"],
PLATFORM_CPU_ARM64: ["src/impl_aarch64__base_implementation.inl"],
"//conditions:default": [],
}) + [
"src/define_introspection.inl",
Expand All @@ -310,6 +361,8 @@ cc_test(
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_RISCV32: ["test/cpuinfo_riscv_test.cc"],
PLATFORM_CPU_RISCV64: ["test/cpuinfo_riscv_test.cc"],
PLATFORM_CPU_X86_64: ["test/cpuinfo_x86_test.cc"],
}),
includes = INCLUDES,
Expand All @@ -333,3 +386,18 @@ cc_binary(
":cpuinfo",
],
)

cc_library(
name = "ndk_compat",
srcs = ["ndk_compat/cpu-features.c"],
copts = C99_FLAGS,
includes = INCLUDES + ["ndk_compat"],
textual_hdrs = ["ndk_compat/cpu-features.h"],
deps = [
":cpu_features_macros",
":cpuinfo",
":filesystem",
":stack_line_reader",
":string_view",
],
)
Loading

0 comments on commit def797f

Please sign in to comment.