From f3a7e23e96e5330798c21c2867f340d852f735bf Mon Sep 17 00:00:00 2001 From: Andrew Duffy Date: Mon, 18 Nov 2024 11:02:26 -0500 Subject: [PATCH] chore: use `zig cc` to cross-compile for several platforms (#1) * use zig cc to cross compile for all targets * chore: use `zig cc` to cross-compile for several platforms --- .github/workflows/pr.yml | 35 +++++++++++++++++++++++----- .github/workflows/publish.yml | 44 +++++++++++++++++++++++++---------- Makefile | 2 +- scripts/ci-build.sh | 2 +- 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a038431..0a12156 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -9,22 +9,45 @@ on: jobs: - publish-linux: - name: Build Linux amd64 + build-aarch64-linux-gnu: + name: Build aarch64-linux-gnu runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 - name: Build run: | - ./scripts/ci-build.sh + ./scripts/ci-build.sh "aarch64-linux-gnu" - publish-macos: - name: Build macOS + build-x86_64-linux-gnu: + name: Build x86_64-linux-gnu + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 + - name: Build + run: | + ./scripts/ci-build.sh "x86_64-linux-gnu" + + build-aarch64-macos: + name: Build aarch64-macos + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 + - name: Build + run: | + ./scripts/ci-build.sh "aarch64-macos" + + + build-x86_64-macos: + name: Build x86_64-macos runs-on: macos-latest steps: - uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 - name: Build run: | - ./scripts/ci-build.sh + ./scripts/ci-build.sh "x86_64-macos" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 75da6bb..2b07e01 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,28 +9,48 @@ on: jobs: - publish-linux: - name: Publish Linux amd64 + publish-aarch64-linux-gnu: + name: Publish aarch64-linux-gnu runs-on: ubuntu-latest - env: - GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 - name: Build run: | - ./scripts/ci-build.sh - ./scripts/ci-release.sh "${{ github.ref_name }}" linux + ./scripts/ci-build.sh "aarch64-linux-gnu" + ./scripts/ci-release.sh "aarch64-linux-gnu" - publish-macos: - name: Publish macOS + publish-x86_64-linux-gnu: + name: Publish x86_64-linux-gnu + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 + - name: Build + run: | + ./scripts/ci-build.sh "x86_64-linux-gnu" + ./scripts/ci-release.sh "x86_64-linux-gnu" + + publish-aarch64-macos: + name: publish aarch64-macos runs-on: macos-latest - env: - GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 - name: Build run: | - ./scripts/ci-build.sh - ./scripts/ci-release.sh "${{ github.ref_name }}" macos + ./scripts/ci-build.sh "aarch64-macos" + ./scripts/ci-release.sh "aarch64-macos" + publish-x86_64-macos: + name: Publish x86_64-macos + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 + - name: Build + run: | + ./scripts/ci-build.sh "x86_64-macos" + ./scripts/ci-release.sh "x86_64-macos" + diff --git a/Makefile b/Makefile index e690071..2e3bfab 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ ################ ## CHANGE NAME OF ANSI COMPILER HERE ################ -CC = gcc +CC = zig cc -target $(TARGET) # Current values for DATABASE are: INFORMIX, DB2, TDAT (Teradata) # SQLSERVER, SYBASE, ORACLE, VECTORWISE # Current values for MACHINE are: ATT, DOS, HP, IBM, ICL, MVS, diff --git a/scripts/ci-build.sh b/scripts/ci-build.sh index 65abb07..286160a 100755 --- a/scripts/ci-build.sh +++ b/scripts/ci-build.sh @@ -1,4 +1,4 @@ echo "making dbgen..." -make -j dbgen +make TARGET="$1" -j dbgen