feat: Update build system and fix include paths #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
install_cmd: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
autoconf \ | |
automake \ | |
libtool \ | |
pkg-config \ | |
wget \ | |
tar \ | |
clang-format \ | |
libsdl2-dev \ | |
libvulkan-dev \ | |
vulkan-tools \ | |
vulkan-validationlayers-dev \ | |
spirv-tools | |
# Set up environment variables | |
echo "SDL2_CFLAGS=-I/usr/include/SDL2" >> $GITHUB_ENV | |
echo "SDL2_LIBS=-lSDL2" >> $GITHUB_ENV | |
echo "VULKAN_SDK=/usr" >> $GITHUB_ENV | |
echo "VULKAN_CFLAGS=-I/usr/include" >> $GITHUB_ENV | |
echo "VULKAN_LIBS=-lvulkan" >> $GITHUB_ENV | |
# Add pkg-config paths | |
echo "PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig" >> $GITHUB_ENV | |
# Add additional include paths | |
echo "CPATH=/usr/include/SDL2:/usr/include/vulkan" >> $GITHUB_ENV | |
echo "C_INCLUDE_PATH=/usr/include/SDL2:/usr/include/vulkan" >> $GITHUB_ENV | |
echo "CPLUS_INCLUDE_PATH=/usr/include/SDL2:/usr/include/vulkan" >> $GITHUB_ENV | |
- os: windows-latest | |
install_cmd: | | |
# Install build tools | |
choco install -y ` | |
autoconf ` | |
automake ` | |
libtool ` | |
pkgconfig ` | |
wget ` | |
tar ` | |
llvm ` | |
mingw ` | |
make | |
# Download and install Vulkan SDK | |
$vulkanSdkUrl = "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe" | |
Invoke-WebRequest -Uri $vulkanSdkUrl -OutFile vulkan-sdk.exe | |
Start-Process -FilePath "vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command" -Wait | |
# Download and extract SDL2 | |
$sdl2Version = "2.28.5" | |
$sdl2Url = "https://github.com/libsdl-org/SDL/releases/download/release-$sdl2Version/SDL2-devel-$sdl2Version-mingw.tar.gz" | |
Invoke-WebRequest -Uri $sdl2Url -OutFile SDL2.tar.gz | |
tar xf SDL2.tar.gz | |
Move-Item -Path "SDL2-$sdl2Version" -Destination "C:\SDL2" | |
# Set up environment variables | |
echo "SDL2_CFLAGS=-IC:/SDL2/include/SDL2" | Out-File -FilePath $env:GITHUB_ENV -Append | |
echo "SDL2_LIBS=-LC:/SDL2/lib -lSDL2" | Out-File -FilePath $env:GITHUB_ENV -Append | |
echo "VULKAN_SDK=C:/VulkanSDK/latest" | Out-File -FilePath $env:GITHUB_ENV -Append | |
echo "VULKAN_CFLAGS=-IC:/VulkanSDK/latest/Include" | Out-File -FilePath $env:GITHUB_ENV -Append | |
echo "VULKAN_LIBS=-LC:/VulkanSDK/latest/Lib -lvulkan-1" | Out-File -FilePath $env:GITHUB_ENV -Append | |
# Add pkg-config paths | |
echo "PKG_CONFIG_PATH=C:/SDL2/lib/pkgconfig;C:/VulkanSDK/latest/lib/pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append | |
# Add additional include paths | |
echo "INCLUDE=C:/SDL2/include/SDL2;C:/VulkanSDK/latest/Include" | Out-File -FilePath $env:GITHUB_ENV -Append | |
echo "C_INCLUDE_PATH=C:/SDL2/include/SDL2;C:/VulkanSDK/latest/Include" | Out-File -FilePath $env:GITHUB_ENV -Append | |
echo "CPLUS_INCLUDE_PATH=C:/SDL2/include/SDL2;C:/VulkanSDK/latest/Include" | Out-File -FilePath $env:GITHUB_ENV -Append | |
# Add to PATH | |
echo "C:\SDL2\bin" | Out-File -FilePath $env:GITHUB_PATH -Append | |
echo "C:\VulkanSDK\latest\Bin" | Out-File -FilePath $env:GITHUB_PATH -Append | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Dependencies | |
shell: pwsh | |
run: ${{ matrix.install_cmd }} | |
- name: Cache Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
C:/SDL2 | |
C:/VulkanSDK | |
key: ${{ runner.os }}-deps-${{ hashFiles('**/*.yml') }} | |
restore-keys: | | |
${{ runner.os }}-deps- | |
- name: Check Code Format | |
run: | | |
./format_code.sh | |
git diff --exit-code || (echo "Code formatting issues found. Run ./format_code.sh locally and commit changes." && exit 1) | |
- name: Build | |
shell: pwsh | |
env: | |
CFLAGS: "${{ matrix.os == 'ubuntu-latest' && '-I/usr/include/SDL2 -I/usr/include/vulkan' || '-IC:/SDL2/include/SDL2 -IC:/VulkanSDK/latest/Include' }}" | |
CXXFLAGS: "${{ matrix.os == 'ubuntu-latest' && '-I/usr/include/SDL2 -I/usr/include/vulkan' || '-IC:/SDL2/include/SDL2 -IC:/VulkanSDK/latest/Include' }}" | |
run: | | |
./autogen.sh | |
./configure | |
make | |
- name: Run Tests | |
if: ${{ matrix.os == 'ubuntu-latest' }} # Only run tests on Linux for now | |
run: make check | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: doom_pp-${{ matrix.os }} | |
path: | | |
doom_pp | |
doom_pp.exe | |
if-no-files-found: ignore |