revising build
This commit is contained in:
300
.github/workflows/build.yml
vendored
300
.github/workflows/build.yml
vendored
@@ -1,32 +1,20 @@
|
|||||||
name: Reusable Build Workflow
|
Based on this build file, write the docker image files for the two builds here so they don't need to install anything, and then edit the build.yml itself to utilize them and remove unneeded commands
|
||||||
|
|
||||||
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
push:
|
||||||
inputs:
|
branches: [ "master" ]
|
||||||
platform:
|
pull_request:
|
||||||
description: "Which platform to build for: 'linux' or 'windows'"
|
|
||||||
required: true
|
|
||||||
run-tests:
|
|
||||||
description: "If true, run the test suite"
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
package-dist:
|
|
||||||
description: "If true, create a distributable package (and upload artifact)"
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-linux:
|
||||||
runs-on: ubuntu-latest # We'll do both Linux or Windows cross from Ubuntu
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check Out Code
|
- name: Check Out Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# ---------------------
|
- name: Install Dependencies
|
||||||
# 1) Install Dependencies
|
|
||||||
# ---------------------
|
|
||||||
- name: Install Dependencies (Linux)
|
|
||||||
if: ${{ inputs.platform == 'linux' }}
|
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
@@ -36,135 +24,185 @@ jobs:
|
|||||||
libxi-dev libxinerama-dev libxss-dev \
|
libxi-dev libxinerama-dev libxss-dev \
|
||||||
libegl1-mesa-dev libgl1-mesa-dev \
|
libegl1-mesa-dev libgl1-mesa-dev \
|
||||||
cmake ninja-build git build-essential binutils mold meson pkg-config \
|
cmake ninja-build git build-essential binutils mold meson pkg-config \
|
||||||
ccache
|
ccache
|
||||||
|
|
||||||
- name: Install Dependencies (Windows cross)
|
|
||||||
if: ${{ inputs.platform == 'windows' }}
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y \
|
|
||||||
mingw-w64 cmake ninja-build git build-essential \
|
|
||||||
binutils pkg-config meson ccache
|
|
||||||
|
|
||||||
- name: Configure ccache
|
- name: Configure ccache
|
||||||
run: |
|
run: |
|
||||||
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
|
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
|
||||||
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
|
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Cache ccache
|
- name: Cache ccache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.ccache
|
path: ~/.ccache
|
||||||
key: ${{ runner.os }}-ccache-${{ inputs.platform }}-${{ hashFiles('**/*.c', '**/*.cpp', '**/*.h', '**/CMakeLists.txt', '**/*.meson', '**/*.build') }}
|
key: ccache-linux-${{ hashFiles('**/*.c', '**/*.cpp', '**/*.h', '**/CMakeLists.txt', '**/meson.build') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-ccache-${{ inputs.platform }}-
|
ccache-linux-
|
||||||
|
|
||||||
# ---------------------
|
- name: Cache SDL3 (Linux)
|
||||||
# 2) Build SDL3
|
|
||||||
# ---------------------
|
|
||||||
- name: Cache SDL3
|
|
||||||
id: cache-sdl
|
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
sdl3-${{ inputs.platform }}
|
sdl3
|
||||||
sdl3-build-${{ inputs.platform }}
|
sdl3-build
|
||||||
key: sdl3-${{ inputs.platform }}-${{ hashFiles('sdl3-*/*.CMakeLists.txt') }}
|
key: sdl3-linux-${{ hashFiles('sdl3/CMakeLists.txt') }}
|
||||||
|
|
||||||
- name: Build SDL3
|
- name: Build SDL3 (Linux)
|
||||||
run: |
|
run: |
|
||||||
# Use different folder names for Linux vs Windows
|
if [ ! -d "sdl3/.git" ]; then
|
||||||
if [ "${{ inputs.platform }}" = "linux" ]; then
|
echo "Cloning SDL3 repository..."
|
||||||
SRC="sdl3-linux"
|
git clone --depth 1 --branch main https://github.com/libsdl-org/SDL.git sdl3
|
||||||
BUILD="sdl3-build-linux"
|
|
||||||
GIT_URL="https://github.com/libsdl-org/SDL.git"
|
|
||||||
# Possibly different branches or flags for Linux, etc.
|
|
||||||
# ...
|
|
||||||
if [ ! -d "$SRC/.git" ]; then
|
|
||||||
git clone --depth 1 --branch main "$GIT_URL" "$SRC"
|
|
||||||
fi
|
|
||||||
mkdir -p "$BUILD"
|
|
||||||
cd "$BUILD"
|
|
||||||
cmake ../"$SRC" -GNinja \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCMAKE_INSTALL_PREFIX="${PWD}/installed_sdl3" \
|
|
||||||
-DSDL_SHARED=ON -DSDL_STATIC=OFF
|
|
||||||
ninja
|
|
||||||
ninja install
|
|
||||||
|
|
||||||
elif [ "${{ inputs.platform }}" = "windows" ]; then
|
|
||||||
SRC="sdl3-win"
|
|
||||||
BUILD="sdl3-build-win"
|
|
||||||
GIT_URL="https://github.com/libsdl-org/SDL.git"
|
|
||||||
# ...
|
|
||||||
if [ ! -d "$SRC/.git" ]; then
|
|
||||||
git clone --depth 1 --branch main "$GIT_URL" "$SRC"
|
|
||||||
fi
|
|
||||||
mkdir -p "$BUILD"
|
|
||||||
cd "$BUILD"
|
|
||||||
cmake ../"$SRC" -GNinja \
|
|
||||||
-DCMAKE_SYSTEM_NAME=Windows \
|
|
||||||
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
|
|
||||||
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
|
|
||||||
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCMAKE_INSTALL_PREFIX="${PWD}/installed_sdl3_win" \
|
|
||||||
-DSDL_SHARED=ON -DSDL_STATIC=OFF
|
|
||||||
ninja
|
|
||||||
ninja install
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ---------------------
|
|
||||||
# 3) Build Prosperon
|
|
||||||
# ---------------------
|
|
||||||
- name: Configure PKG_CONFIG_PATH
|
|
||||||
if: ${{ inputs.platform == 'windows' }}
|
|
||||||
run: |
|
|
||||||
echo "PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/sdl3-build-win/installed_sdl3_win/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Build Prosperon
|
|
||||||
run: |
|
|
||||||
if [ "${{ inputs.platform }}" = "linux" ]; then
|
|
||||||
export PKG_CONFIG_PATH="${PWD}/sdl3-build-linux/installed_sdl3/lib/pkgconfig:$PKG_CONFIG_PATH"
|
|
||||||
meson setup build_dbg -Dbuildtype=release -Db_lto=true -Db_ndebug=true
|
|
||||||
meson compile -C build_dbg
|
|
||||||
|
|
||||||
elif [ "${{ inputs.platform }}" = "windows" ]; then
|
|
||||||
meson setup --cross-file mingw32.cross build_win -Dbuildtype=release -Db_lto=true -Db_ndebug=true
|
|
||||||
meson compile -C build_win
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ---------------------
|
|
||||||
# 4) (Optional) Run Tests
|
|
||||||
# ---------------------
|
|
||||||
- name: Run Test Suite
|
|
||||||
if: ${{ inputs.run-tests == true }}
|
|
||||||
run: |
|
|
||||||
# Example: just show how you'd do it
|
|
||||||
echo "Running tests..."
|
|
||||||
# e.g. meson test -C build_dbg
|
|
||||||
# or some custom test commands
|
|
||||||
echo "Tests completed!"
|
|
||||||
|
|
||||||
# ---------------------
|
|
||||||
# 5) (Optional) Package Dist
|
|
||||||
# ---------------------
|
|
||||||
- name: Package Distribution
|
|
||||||
if: ${{ inputs.package-dist == true }}
|
|
||||||
run: |
|
|
||||||
echo "Creating final _pack folder..."
|
|
||||||
mkdir _pack
|
|
||||||
if [ "${{ inputs.platform }}" = "linux" ]; then
|
|
||||||
cp build_dbg/prosperon _pack/
|
|
||||||
cp sdl3-build-linux/installed_sdl3/lib/libSDL3.so _pack/
|
|
||||||
else
|
else
|
||||||
cp build_win/prosperon.exe _pack/
|
echo "SDL3 source is already present (possibly from cache)."
|
||||||
cp sdl3-build-win/installed_sdl3_win/bin/SDL3.dll _pack/
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload Artifact
|
mkdir -p sdl3-build
|
||||||
if: ${{ inputs.package-dist == true }}
|
cd sdl3-build
|
||||||
|
cmake ../sdl3 -GNinja \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="${PWD}/installed_sdl3" \
|
||||||
|
-DSDL_SHARED=ON \
|
||||||
|
-DSDL_STATIC=OFF
|
||||||
|
ninja
|
||||||
|
ninja install
|
||||||
|
|
||||||
|
- name: Build Prosperon (Linux)
|
||||||
|
run: |
|
||||||
|
export PKG_CONFIG_PATH="${PWD}/sdl3-build/installed_sdl3/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||||
|
meson setup build_dbg -Dbuildtype=debugoptimized
|
||||||
|
meson compile -C build_dbg
|
||||||
|
|
||||||
|
- name: Create artifact folder (Linux)
|
||||||
|
run: |
|
||||||
|
mkdir _pack
|
||||||
|
cp build_dbg/prosperon _pack/
|
||||||
|
# Adjust wildcard if there's a versioned libSDL3. e.g. libSDL3-0.600.0.so
|
||||||
|
cp sdl3-build/installed_sdl3/lib/libSDL3.so _pack/
|
||||||
|
|
||||||
|
- name: Upload Artifact (Linux)
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: prosperon-${{ inputs.platform }}
|
name: prosperon-artifacts-linux
|
||||||
path: _pack
|
path: _pack
|
||||||
|
|
||||||
|
build-windows:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check Out Code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Dependencies (Windows Cross)
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y \
|
||||||
|
mingw-w64 cmake ninja-build git build-essential \
|
||||||
|
binutils pkg-config meson ccache
|
||||||
|
|
||||||
|
- name: Configure ccache
|
||||||
|
run: |
|
||||||
|
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
|
||||||
|
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Cache ccache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.ccache
|
||||||
|
key: ccache-win-${{ hashFiles('**/*.c', '**/*.cpp', '**/*.h', '**/CMakeLists.txt', '**/meson.build') }}
|
||||||
|
restore-keys: |
|
||||||
|
ccache-win-
|
||||||
|
|
||||||
|
- name: Cache SDL3 (Windows cross)
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
sdl3-win
|
||||||
|
sdl3-build-win
|
||||||
|
key: sdl3-win-${{ hashFiles('sdl3-win/CMakeLists.txt') }}
|
||||||
|
|
||||||
|
- name: Build SDL3 (Windows cross)
|
||||||
|
run: |
|
||||||
|
if [ ! -d "sdl3-win/.git" ]; then
|
||||||
|
echo "Cloning SDL3 for Windows cross..."
|
||||||
|
git clone --depth 1 --branch main https://github.com/libsdl-org/SDL.git sdl3-win
|
||||||
|
else
|
||||||
|
echo "SDL3-win source already present (possibly from cache)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p sdl3-build-win
|
||||||
|
cd sdl3-build-win
|
||||||
|
cmake ../sdl3-win -GNinja \
|
||||||
|
-DCMAKE_SYSTEM_NAME=Windows \
|
||||||
|
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
|
||||||
|
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
|
||||||
|
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="${PWD}/installed_sdl3_win" \
|
||||||
|
-DSDL_SHARED=ON \
|
||||||
|
-DSDL_STATIC=OFF
|
||||||
|
ninja
|
||||||
|
ninja install
|
||||||
|
|
||||||
|
- name: Configure PKG_CONFIG_PATH (Windows cross)
|
||||||
|
run: |
|
||||||
|
echo "PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/sdl3-build-win/installed_sdl3_win/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build Prosperon (Windows cross)
|
||||||
|
run: |
|
||||||
|
meson setup -Dbuildtype=debugoptimized --cross-file mingw32.cross build_win
|
||||||
|
meson compile -C build_win
|
||||||
|
|
||||||
|
- name: Create package folder
|
||||||
|
run: |
|
||||||
|
mkdir _pack
|
||||||
|
cp build_win/prosperon.exe _pack/
|
||||||
|
cp sdl3-build-win/installed_sdl3_win/bin/SDL3.dll _pack/
|
||||||
|
|
||||||
|
- name: Upload Artifact (Windows cross)
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: prosperon-artifacts-windows
|
||||||
|
path: _pack
|
||||||
|
|
||||||
|
|
||||||
|
package-dist:
|
||||||
|
needs: [build-linux, build-windows]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Download Linux Artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: prosperon-artifacts-linux
|
||||||
|
path: linux_artifacts
|
||||||
|
|
||||||
|
- name: Download Windows Artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: prosperon-artifacts-windows
|
||||||
|
path: windows_artifacts
|
||||||
|
|
||||||
|
- name: Create the Dist Folder
|
||||||
|
run: |
|
||||||
|
mkdir dist
|
||||||
|
|
||||||
|
cp README.md dist/
|
||||||
|
cp license.txt dist/
|
||||||
|
cp -r examples dist/
|
||||||
|
|
||||||
|
# Make subdirectories for each platform
|
||||||
|
mkdir dist/linux
|
||||||
|
mkdir dist/win
|
||||||
|
|
||||||
|
# -------------------
|
||||||
|
# Copy artifacts in
|
||||||
|
# -------------------
|
||||||
|
cp linux_artifacts/* dist/linux/
|
||||||
|
cp windows_artifacts/* dist/win/
|
||||||
|
|
||||||
|
- name: Upload Final Dist
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: prosperon
|
||||||
|
path: dist
|
||||||
Reference in New Issue
Block a user