From e4aec1478d78030fdc1c170eb2c6c2e19e5673a7 Mon Sep 17 00:00:00 2001 From: Ben McAvoy Date: Wed, 27 Nov 2024 22:59:59 +0000 Subject: [PATCH] ci: build workflow --- .github/workflows/build.yml | 47 +++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 5 +++- windows.sh | 12 ++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml create mode 100644 windows.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..951fce4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: build +on: [push, pull_request, workflow_dispatch] + +jobs: + windows: + runs-on: ubuntu-latest + steps: + - name: Checkout exgine + uses: actions/checkout@v4 + with: + path: exgine + submodules: 'recursive' + - name: Install Dependencies + run: | + sudo apt update + sudo apt install -y build-essential cmake + sudo apt install libwayland-dev libxkbcommon-dev xorg-dev + sudo apt install -y mingw-w64 mingw-w64-tools ninja-build + - name: Build + run: (cd exgine && bash windows.sh) + - uses: actions/upload-artifact@v4 + with: + name: exgine_windows-x64 + path: | + build/starter.exe + linux: + runs-on: ubuntu-latest + steps: + - name: Checkout exgine + uses: actions/checkout@v4 + with: + path: exgine + submodules: 'recursive' + - name: Install Dependencies + run: | + sudo apt update + sudo apt install -y build-essential cmake + sudo apt install libwayland-dev libxkbcommon-dev xorg-dev + - name: Configure + run: cmake -Bbuild -Hexgine -DCMAKE_INSTALL_PREFIX=$PWD/install + - name: Build + run: cmake --build build --config Release -j2 + - uses: actions/upload-artifact@v4 + with: + name: exgine_linux-x64 + path: | + build/starter diff --git a/CMakeLists.txt b/CMakeLists.txt index 98b8654..6e04803 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,10 @@ set (CMAKE_CXX_STANDARD_REQUIRED ON) # Project declaration project(ExgineRoot) -if (WIN32) +# we need to check if we're actually on windows, not just cross-compiling +if (WIN32 AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + message(STATUS "Not on Windows, not enabling unicode support") +elseif (WIN32) message(STATUS "Manually enabling unicode support") add_compile_options(/utf-8) endif() diff --git a/windows.sh b/windows.sh new file mode 100644 index 0000000..8ec8ab4 --- /dev/null +++ b/windows.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +cmake -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SYSTEM_NAME=Windows \ + -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \ + -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \ + -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++ -static" \ + -DCMAKE_EXE_LINKER_FLAGS="-static" \ + -B build \ + -G Ninja + +cmake --build build --config Release