From eb25dbed2b7939b456a5e61df36adaeb0935ec9d Mon Sep 17 00:00:00 2001 From: SpiralP Date: Sat, 6 Nov 2021 16:13:32 -0700 Subject: [PATCH] add GitHub Actions ci workflow for test-building linux, windows, and mac --- .github/workflows/build.yml | 130 ++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..ab9ca7fa6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,130 @@ +name: Build + +on: [push, pull_request] + +jobs: + build_on_ubuntu: + name: Build ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) on Ubuntu + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + config: + - { plat: "Linux", bits: 64 } + - { plat: "Linux", bits: 32 } + - { plat: "Windows", bits: 64 } + - { plat: "Windows", bits: 32 } + + steps: + - uses: actions/checkout@v2 + + - name: Install Shared Dependencies + run: | + sudo apt-get -y update && + sudo apt-get -y install build-essential + + # Install platform specific dependencies + - name: Install Dependencies for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Linux' && matrix.config.bits == 64 + run: | + sudo apt-get -y install libx11-dev libxi-dev libgl1-mesa-dev + + - name: Install Dependencies for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Linux' && matrix.config.bits == 32 + run: | + sudo dpkg --add-architecture i386 \ + && sudo apt-get -y update \ + && sudo apt-get -y install gcc-multilib libx11-dev:i386 libxi-dev:i386 libgl1-mesa-dev:i386 + + - name: Install Dependencies for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Windows' && matrix.config.bits == 64 + run: | + sudo apt-get -y install gcc-mingw-w64-x86-64 + + - name: Install Dependencies for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Windows' && matrix.config.bits == 32 + run: | + sudo apt-get -y install gcc-mingw-w64-i686 + + # Build + - name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Linux' + run: | + cd src + gcc *.c -m${{ matrix.config.bits }} -o ClassiCube -rdynamic -lm -lpthread -lX11 -lXi -lGL -ldl + + - name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Windows' && matrix.config.bits == 64 + run: | + cd src + x86_64-w64-mingw32-gcc *.c -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 + + - name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Windows' && matrix.config.bits == 32 + run: | + cd src + i686-w64-mingw32-gcc *.c -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 + + build_on_windows: + name: Build ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) on Windows + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + config: + - { plat: "Windows", bits: 64 } + - { plat: "Windows", bits: 32 } + + steps: + - uses: actions/checkout@v2 + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.1 + + # Build + - name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Windows' && matrix.config.bits == 64 + run: | + msbuild src\ClassiCube.vcxproj ` + -property:Configuration=Debug -property:Platform=x64 ` + -property:WindowsTargetPlatformVersion=10 -property:PlatformToolset=v142 + + - name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Windows' && matrix.config.bits == 32 + run: | + msbuild src\ClassiCube.vcxproj ` + -property:Configuration=Debug -property:Platform=Win32 ` + -property:WindowsTargetPlatformVersion=10 -property:PlatformToolset=v142 + + build_on_mac: + name: Build ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) on Mac + runs-on: macOS-latest + + strategy: + fail-fast: false + matrix: + config: + - { plat: "Mac", bits: 64 } + # "ld: warning: ignoring file ..., missing required architecture i386 in file ..." + # "Undefined symbols for architecture i386" + # - { plat: "Mac", bits: 32 } + + steps: + - uses: actions/checkout@v2 + + # Build + - name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Mac' && matrix.config.bits == 64 + run: | + cd src + # fix for "error: implicit declaration of function 'CGDisplayBitsPerPixel'" + sed -i '' 's|#include |&\'$'\nextern size_t CGDisplayBitsPerPixel(CGDirectDisplayID display);|' interop_cocoa.m + gcc *.c interop_cocoa.m -o ClassiCube -framework Cocoa -framework OpenGL -framework IOKit -lobjc + + - name: Build for ${{ matrix.config.plat }} (${{ matrix.config.bits }} bit) + if: matrix.config.plat == 'Mac' && matrix.config.bits == 32 + run: | + cd src + cc *.c -o ClassiCube -framework Carbon -framework AGL -framework OpenGL -framework IOKit