Skip to content

Commit 1d0fd99

Browse files
committed
Support zig compiler
1 parent 1a1eb18 commit 1d0fd99

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

.github/workflows/zig.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Zig compiler
2+
on:
3+
push:
4+
branches: [ '*' ]
5+
pull_request:
6+
branches: [ '*' ]
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref_name }}
9+
cancel-in-progress: true
10+
jobs:
11+
zig:
12+
if: github.repository_owner == 'aws'
13+
runs-on: ${{ matrix.os.name }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os:
18+
- name: windows-latest
19+
target: x86_64-windows
20+
- name: ubuntu-latest
21+
target: x86_64-linux
22+
- name: macos-latest
23+
target: aarch64-macos
24+
steps:
25+
- name: Install NASM
26+
uses: ilammy/[email protected]
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
- name: Install ninja-build tool
30+
uses: seanmiddleditch/gha-setup-ninja@v4
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.13'
34+
- name: Install zigcc
35+
uses: jiacai2050/[email protected]
36+
with:
37+
zig-version: 0.14.0
38+
- name: Locate zig not on Windows
39+
if: matrix.os.name != 'windows-latest'
40+
shell: bash
41+
run: |
42+
echo "ZIGCC=`which zigcc`" >> $GITHUB_ENV
43+
echo "ZIGCXX=`which zigcxx`" >> $GITHUB_ENV
44+
- name: Locate zig on Windows
45+
if: matrix.os.name == 'windows-latest'
46+
shell: bash
47+
run: |
48+
ZIGCC="python3 $(cygpath -m $(which zigcc))"
49+
ZIGCXX="python3 $(cygpath -m $(which zigcxx))"
50+
echo "ZIGCC=${ZIGCC}" >> $GITHUB_ENV
51+
echo "ZIGCXX=${ZIGCXX}" >> $GITHUB_ENV
52+
- name: Create toolchain
53+
shell: bash
54+
run: |
55+
cat <<EOF > ./toolchain.cmake
56+
set(CMAKE_C_COMPILER ${ZIGCC})
57+
set(CMAKE_C_COMPILER_TARGET ${{ matrix.os.target }})
58+
set(CMAKE_CXX_COMPILER ${ZIGCXX})
59+
set(CMAKE_CXX_COMPILER_TARGET ${{ matrix.os.target }})
60+
set(CMAKE_ASM_COMPILER ${ZIGCC})
61+
set(CMAKE_ASM_COMPILER_TARGET ${{ matrix.os.target }})
62+
set(DISABLE_GO ON)
63+
set(DISABLE_PERL ON)
64+
set(CMAKE_VERBOSE_MAKEFILE ON)
65+
set(CMAKE_MESSAGE_LOG_LEVEL DEBUG)
66+
EOF
67+
- name: Setup CMake
68+
shell: bash
69+
run: |
70+
printenv | sort
71+
which zigcc
72+
which zigcxx
73+
cat ./toolchain.cmake
74+
cmake '.' -B ./build -G Ninja -DCMAKE_TOOLCHAIN_FILE=./toolchain.cmake -DCMAKE_BUILD_TYPE=Release
75+
- name: Build Project
76+
shell: bash
77+
run: |
78+
cmake --build ./build --target all --verbose

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ if(GCC OR CLANG)
428428
endif()
429429
endif()
430430

431-
if(MINGW)
431+
if(MINGW AND NOT CLANG)
432432
# Some MinGW compilers set _WIN32_WINNT to an older version (Windows Server 2003)
433433
# See: https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
434434
# Support Windows 7 and later.

0 commit comments

Comments
 (0)