1
0
mirror of https://github.com/google/cpu_features.git synced 2025-04-27 15:12:30 +02:00

ci: Add amd64 macos bazel workflow (#324)

* ci: Add amd64 MacOS Bazel job

* bazel: Fix MacOS build

* add amd64_macos_bazel badge
This commit is contained in:
Mizux 2023-08-30 17:17:34 +02:00 committed by GitHub
parent e2d0f2ca21
commit 2a3ef54701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 3 deletions

35
.github/workflows/amd64_macos_bazel.yml vendored Normal file
View File

@ -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
...

View File

@ -2,6 +2,7 @@
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_RISCV32", "PLATFORM_CPU_RISCV64", "PLATFORM_CPU_X86_64")
load("//:bazel/platforms.bzl", "PLATFORM_OS_MACOS")
package(
default_visibility = ["//visibility:public"],
@ -170,7 +171,10 @@ cc_library(
name = "hwcaps",
srcs = ["src/hwcaps.c"],
copts = C99_FLAGS,
defines = ["HAVE_STRONG_GETAUXVAL"],
defines = selects.with_or({
PLATFORM_OS_MACOS: ["HAVE_DLFCN_H"],
"//conditions:default": ["HAVE_STRONG_GETAUXVAL"],
}),
includes = INCLUDES,
textual_hdrs = ["include/internal/hwcaps.h"],
deps = [
@ -237,6 +241,10 @@ cc_library(
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"],
@ -296,6 +304,9 @@ cc_library(
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({

View File

@ -9,7 +9,7 @@ instructions) at runtime.
| | Linux | FreeBSD | MacOS | Windows |
| :-- | --: | --: | --: | --: |
| amd64 | [![][i1a0]][l1a0]<br/>[![][i1a1]][l1a1] | [![][i2a0]][l2a0]<br/>![][d1] | [![][i3a0]][l3a0]<br/>![][d1] | [![][i4a0]][l4a0]<br/>![][d1] |
| amd64 | [![][i1a0]][l1a0]<br/>[![][i1a1]][l1a1] | [![][i2a0]][l2a0]<br/>![][d1] | [![][i3a0]][l3a0]<br/>[![][i3a1]][l3a1] | [![][i4a0]][l4a0]<br/>![][d1] |
| AArch64 | [![][i1b0]][l1b0]<br/>[![][i1b1]][l1b1] | ![][d0]<br/>![][d1] | ![][d0]<br/>![][d1] | ![][d0]<br/>![][d1] |
| ARM | [![][i1c0]][l1c0]<br/>![][d1] | ![][d0]<br/>![][d1] | ![][d0]<br/>![][d1] | ![][d0]<br/>![][d1] |
| MIPS | [![][i1d0]][l1d0]<br/>![][d1] | ![][d0]<br/>![][d1] | ![][d0]<br/>![][d1] | ![][d0]<br/>![][d1] |
@ -31,6 +31,7 @@ instructions) at runtime.
[i1h0]: https://img.shields.io/github/actions/workflow/status/google/cpu_features/s390x_linux_cmake.yml?branch=main&event=push&label=&logo=cmake
[i2a0]: https://img.shields.io/github/actions/workflow/status/google/cpu_features/amd64_freebsd_cmake.yml?branch=main&event=push&label=&logo=cmake
[i3a0]: https://img.shields.io/github/actions/workflow/status/google/cpu_features/amd64_macos_cmake.yml?branch=main&event=push&label=&logo=cmake
[i3a1]: https://img.shields.io/github/actions/workflow/status/google/cpu_features/amd64_macos_bazel.yml?branch=main&event=push&label=&logo=data:image/svg%2bxml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNiAuMTZsNS43ODYgNS43ODZMNiAxMS43MzIuMjE0IDUuOTQ2IDYgLjE2MXpNMCA2LjIxNFYxMmw1Ljc4NiA1Ljc4NlYxMkwwIDYuMjE0ek0xOCAuMTZsNS43ODYgNS43ODZMMTggMTEuNzMybC01Ljc4Ni01Ljc4NkwxOCAuMTYxek0yNCA2LjIxNFYxMmwtNS43ODYgNS43ODZWMTJMMjQgNi4yMTR6TTEyIDYuMTZsNS43ODYgNS43ODZMMTIgMTcuNzMybC01Ljc4Ni01Ljc4NkwxMiA2LjE2MXpNMTEuODQgMTguMDU0djUuNzg1bC01Ljc4Ni01Ljc4NXYtNS43ODZsNS43ODUgNS43ODZ6TTEyLjE2IDE4LjA1NGw1Ljc4Ni01Ljc4NnY1Ljc4NmwtNS43ODUgNS43ODV2LTUuNzg1eiIgc3Ryb2tlPSJ0cmFuc3BhcmVudCIgZmlsbD0id2hpdGUiLz48L3N2Zz4=
[i4a0]: https://img.shields.io/github/actions/workflow/status/google/cpu_features/amd64_windows_cmake.yml?branch=main&event=push&label=&logo=cmake
[l1a0]: https://github.com/google/cpu_features/actions/workflows/amd64_linux_cmake.yml
[l1a1]: https://github.com/google/cpu_features/actions/workflows/amd64_linux_bazel.yml
@ -43,6 +44,7 @@ instructions) at runtime.
[l1h0]: https://github.com/google/cpu_features/actions/workflows/s390x_linux_cmake.yml
[l2a0]: https://github.com/google/cpu_features/actions/workflows/amd64_freebsd_cmake.yml
[l3a0]: https://github.com/google/cpu_features/actions/workflows/amd64_macos_cmake.yml
[l3a1]: https://github.com/google/cpu_features/actions/workflows/amd64_macos_bazel.yml
[l4a0]: https://github.com/google/cpu_features/actions/workflows/amd64_windows_cmake.yml
## Table of Contents

View File

@ -13,3 +13,6 @@ PLATFORM_CPU_PPC = ("@platforms//cpu:ppc")
PLATFORM_CPU_RISCV32 = ("@platforms//cpu:riscv32")
PLATFORM_CPU_RISCV64 = ("@platforms//cpu:riscv64")
PLATFORM_OS_MACOS = ("@platforms//os:macos")

View File

@ -78,7 +78,8 @@ const:
case BuildSystem.CMake:
return os == Os.Linux || cpu == Cpu.amd64;
case BuildSystem.Bazel:
return os == Os.Linux && (cpu == Cpu.amd64 || cpu == Cpu.AArch64);
return (os == Os.Linux && (cpu == Cpu.amd64 || cpu == Cpu.AArch64))
|| (os == Os.MacOS && cpu == Cpu.amd64);
}
}