macOS: Fix SDL2 not being found when installed via MacPorts instead o… #417
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: Build Mesen | |
on: [push] | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
jobs: | |
windows: | |
strategy: | |
matrix: | |
platform: [ | |
{netversion: 6.x, targetframework: net6.0, aot: false, singleFile: true, aotString: ""}, | |
{netversion: 8.x, targetframework: net8.0, aot: false, singleFile: true, aotString: ""}, | |
{netversion: 8.x, targetframework: net8.0, aot: true, singleFile: false, aotString: " - AoT"} | |
] | |
fail-fast: false | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ matrix.platform.netversion }} | |
- name: Setup MSBuild.exe | |
uses: microsoft/setup-msbuild@v2 | |
with: | |
msbuild-architecture: x64 | |
- name: Restore packages | |
run: dotnet restore -p:TargetFramework="${{ matrix.platform.targetframework }}" -r win-x64 -p:PublishAot="${{ matrix.platform.aot }}" | |
- name: Build Mesen | |
run: msbuild -nologo -v:d -clp:ForceConsoleColor -m -p:Configuration=Release -p:Platform=x64 -t:Clean,UI -p:TargetFramework="${{ matrix.platform.targetframework }}" | |
- name: Publish Mesen | |
run: dotnet publish --no-restore -c Release -p:PublishAot="${{ matrix.platform.aot }}" -p:SelfContained="${{ matrix.platform.aot }}" -p:PublishSingleFile="${{ matrix.platform.singleFile }}" -p:OptimizeUi="true" -p:Platform="Any CPU" -p:TargetFramework="${{ matrix.platform.targetframework }}" -r win-x64 Mesen.sln /p:PublishProfile=UI\Properties\PublishProfiles\Release.pubxml | |
- name: Upload Mesen | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Mesen (Windows - ${{ matrix.platform.targetframework }}${{ matrix.platform.aotString }}) | |
path: | | |
build/TmpReleaseBuild/Mesen.exe | |
linux: | |
strategy: | |
matrix: | |
compiler: [gcc, clang, clang_aot] | |
os: [ubuntu-22.04, ubuntu-20.04] | |
exclude: | |
# This currently fails to build. | |
- os: ubuntu-20.04 | |
compiler: gcc | |
# Don't need 2 separate AoT builds | |
- os: ubuntu-22.04 | |
compiler: clang_aot | |
include: | |
- compiler: gcc | |
make_flags: "USE_GCC=true" | |
- compiler: clang | |
make_flags: "" | |
- compiler: clang_aot | |
make_flags: "USE_AOT=true" | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Install dependencies | |
run: | | |
sudo apt-get update -qy | |
sudo apt-get install -qy libsdl2-dev # The compilers are already installed on GitHub's runners. | |
# stderr is not detected as a TTY, so diagnostics are by default printed without colours; | |
# forcing colours makes the log a little nicer to read. | |
- name: Build Mesen | |
run: | | |
make -j$(nproc) -O ${{ matrix.make_flags }} LTO=true STATICLINK=true SYSTEM_LIBEVDEV=false | |
- name: Upload Mesen | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Mesen (Linux - ${{ matrix.os }} - ${{ matrix.compiler }}) | |
path: bin/linux-x64/Release/linux-x64/publish/Mesen | |
appimage: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Install dependencies | |
run: | | |
sudo apt-get update -qy | |
sudo apt-get install -qy libsdl2-dev libfuse2 # The compilers are already installed on GitHub's runners. | |
- name: Build Mesen (AppImage) | |
run: | | |
Linux/appimage/appimage.sh | |
- name: Upload Mesen (AppImage) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Mesen (Linux x64 - AppImage) | |
path: Mesen.AppImage | |
macos: | |
strategy: | |
matrix: | |
compiler: [clang, clang_aot] | |
platform: [ | |
{os: macos-12, arch: x64}, | |
{os: macos-14, arch: arm64} | |
] | |
include: | |
- compiler: clang | |
make_flags: "" | |
- compiler: clang_aot | |
make_flags: "USE_AOT=true" | |
fail-fast: false | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: Install dependencies | |
run: | | |
brew install sdl2 | |
# stderr is not detected as a TTY, so diagnostics are by default printed without colours; | |
# forcing colours makes the log a little nicer to read. | |
- name: Build Mesen | |
run: | | |
${{ matrix.make_flags }} make -j$(sysctl -n hw.logicalcpu) | |
- name: Sign binary | |
env: | |
APP_NAME: bin/osx-${{ matrix.platform.arch }}/Release/osx-${{ matrix.platform.arch }}/publish/Mesen.app | |
CERT_DATA: ${{ secrets.MACOS_CERTIFICATE }} | |
CERT_PASS: ${{ secrets.MACOS_CERTIFICATE_PWD }} | |
ENTITLEMENTS: UI/Mesen.entitlements | |
SIGNING_IDENTITY: Mesen | |
run: | | |
# Export certs | |
echo "$CERT_DATA" | base64 --decode > /tmp/certs.p12 | |
# Create keychain | |
security create-keychain -p actions macos-build.keychain | |
security default-keychain -s macos-build.keychain | |
security unlock-keychain -p actions macos-build.keychain | |
security set-keychain-settings -t 3600 -u macos-build.keychain | |
# Import certs to keychain | |
security import /tmp/certs.p12 -k ~/Library/Keychains/macos-build.keychain -P "$CERT_PASS" -T /usr/bin/codesign -T /usr/bin/productsign | |
# Key signing | |
security set-key-partition-list -S apple-tool:,apple: -s -k actions macos-build.keychain | |
# print identities | |
security find-identity -v macos-build.keychain | |
echo "[INFO] Signing app file" | |
codesign --force --deep --timestamp --keychain macos-build.keychain --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$APP_NAME" | |
- name: Zip Mesen.app | |
run: | | |
ditto -c -k --sequesterRsrc --keepParent bin/osx-${{ matrix.platform.arch }}/Release/osx-${{ matrix.platform.arch }}/publish/Mesen.app bin/osx-${{ matrix.platform.arch }}/Release/Mesen.app.zip | |
- name: Upload Mesen | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Mesen (macOS - ${{ matrix.platform.os }} - ${{ matrix.compiler }}) | |
path: bin/osx-${{ matrix.platform.arch }}/Release/Mesen.app.zip |