|
| 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.config.host }} |
| 14 | + env: |
| 15 | + CFLAGS: "-fno-sanitize=all" |
| 16 | + CXXFLAGS: "-fno-sanitize=all" |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + config: |
| 21 | + - host: windows-latest |
| 22 | + target_arch: x86_64 |
| 23 | + target_system: Windows |
| 24 | + - host: ubuntu-latest |
| 25 | + target_arch: x86_64 |
| 26 | + target_system: Linux |
| 27 | + - host: macos-latest |
| 28 | + target_arch: aarch64 |
| 29 | + target_system: Darwin |
| 30 | + steps: |
| 31 | + - name: Install NASM |
| 32 | + |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + - name: Install ninja-build tool |
| 36 | + uses: seanmiddleditch/gha-setup-ninja@v4 |
| 37 | + - uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: '3.13' |
| 40 | + - uses: actions/setup-go@v4 |
| 41 | + with: |
| 42 | + go-version: '>= 1.18' |
| 43 | + - name: Install zigcc |
| 44 | + uses: jiacai2050/my-works@main |
| 45 | + with: |
| 46 | + zig-version: 0.15.1 |
| 47 | + - name: Locate zig not on Windows |
| 48 | + if: matrix.os.name != 'windows-latest' |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + echo "ZIGCC=${PWD}/util/zig-cc" >> $GITHUB_ENV |
| 52 | + echo "ZIGCXX=${PWD}/util/zig-c++" >> $GITHUB_ENV |
| 53 | + - name: Locate zig on Windows |
| 54 | + if: matrix.os.name == 'windows-latest' |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + ZIGCC="python3 $(cygpath -m $(which zigcc))" |
| 58 | + ZIGCXX="python3 $(cygpath -m $(which zigcxx))" |
| 59 | + echo "ZIGCC=${ZIGCC}" >> $GITHUB_ENV |
| 60 | + echo "ZIGCXX=${ZIGCXX}" >> $GITHUB_ENV |
| 61 | + - name: Create toolchain |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + cat <<EOF > ./toolchain.cmake |
| 65 | + set(CMAKE_C_COMPILER ${ZIGCC}) |
| 66 | + set(CMAKE_SYSTEM_NAME ${{ matrix.config.target_system }}) |
| 67 | + set(CMAKE_SYSTEM_PROCESSOR ${{ matrix.config.target_arch }}) |
| 68 | + set(CMAKE_CXX_COMPILER ${ZIGCXX}) |
| 69 | + set(CMAKE_ASM_COMPILER ${ZIGCC}) |
| 70 | + set(CMAKE_VERBOSE_MAKEFILE ON) |
| 71 | + set(CMAKE_MESSAGE_LOG_LEVEL DEBUG) |
| 72 | + EOF |
| 73 | + - name: Setup CMake |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + printenv | sort |
| 77 | + which zigcc |
| 78 | + which zigcxx |
| 79 | + cat ./toolchain.cmake |
| 80 | + cmake '.' -B ./build -G Ninja -DCMAKE_TOOLCHAIN_FILE=./toolchain.cmake -DCMAKE_BUILD_TYPE=Release |
| 81 | + - name: Build Project |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + cmake --build ./build --target run_tests --verbose |
0 commit comments