Skip to content

Commit a279983

Browse files
committed
Support for zig compiler
1 parent 1a1eb18 commit a279983

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

.github/workflows/zig.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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: x86_64-macos
24+
steps:
25+
- name: Install NASM
26+
uses: ilammy/[email protected]
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
- name: Install zigcc
30+
uses: jiacai2050/[email protected]
31+
with:
32+
zig-version: 0.14.0
33+
- name: Create toolchain
34+
shell: bash
35+
run: |
36+
ZIGCC=`which zigcc`
37+
ZIGCXX=`which zigcxx`
38+
cat <<EOF > ./toolchain.cmake
39+
set(CMAKE_C_COMPILER $(cygpath -w "${ZIGCC}"))
40+
set(CMAKE_C_COMPILER_TARGET ${{ matrix.os.target }})
41+
set(CMAKE_CXX_COMPILER $(cygpath -w "${ZIGXX}"))
42+
set(CMAKE_CXX_COMPILER_TARGET ${{ matrix.os.target }})
43+
set(CMAKE_GENERATOR "Ninja")
44+
set(DISABLE_GO ON)
45+
set(DISABLE_PERL ON)
46+
set(CMAKE_VERBOSE_MAKEFILE ON)
47+
set(CMAKE_MESSAGE_LOG_LEVEL TRACE)
48+
EOF
49+
- name: Setup CMake
50+
shell: bash
51+
run: |
52+
printenv | sort
53+
which zigcc
54+
which zigcxx
55+
cat ./toolchain.cmake
56+
cmake '.' -B ./build -DCMAKE_TOOLCHAIN_FILE=./toolchain.cmake -DCMAKE_BUILD_TYPE=Release
57+
- name: Build Project
58+
shell: bash
59+
run: |
60+
cmake --build ./build --target all

CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ if(GCC OR CLANG)
400400
else()
401401
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra")
402402
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -fvisibility=hidden -fno-common")
403-
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wno-newline-eof")
403+
if(NOT CMAKE_C_COMPILER MATCHES "zig")
404+
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wno-newline-eof")
405+
endif()
404406
endif()
405407
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow")
406408
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wwrite-strings -Wformat-security -Wunused-result -Wno-overlength-strings")
@@ -428,7 +430,7 @@ if(GCC OR CLANG)
428430
endif()
429431
endif()
430432

431-
if(MINGW)
433+
if(MINGW AND NOT CMAKE_C_COMPILER MATCHES "zig")
432434
# Some MinGW compilers set _WIN32_WINNT to an older version (Windows Server 2003)
433435
# See: https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
434436
# Support Windows 7 and later.

0 commit comments

Comments
 (0)