Improve the implementation of hs_mkdir()
on windows to correctly ha…
#254
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 | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
windows: | |
name: Windows x64 (Portable Archive) | |
runs-on: windows-latest | |
defaults: | |
run: | |
shell: msys2 {0} | |
steps: | |
- name: Fetch Source Code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Dependencies | |
uses: msys2/setup-msys2@v2 | |
with: | |
install: make mingw-w64-x86_64-meson mingw-w64-x86_64-ninja mingw-w64-x86_64-pkg-config mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2 mingw-w64-x86_64-glew mingw-w64-x86_64-libarchive | |
- name: Build Hades | |
run: | | |
meson --buildtype=release build -Dstatic_executable=true | |
cd build | |
ninja | |
- name: Test Hades | |
run: | | |
./build/Hades.exe --help | |
- name: Collect Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hades-win64 | |
path: build/Hades.exe | |
if-no-files-found: error | |
mac-os: | |
name: MacOS arm64/x64 (DMG Installer) | |
runs-on: macos-14 | |
steps: | |
- name: Fetch Source Code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Dependencies | |
run: | | |
export BREW_X86_64_ROOT="$HOME/x86_64-brew/" | |
mkdir -p "$BREW_X86_64_ROOT" | |
echo "Downloading x86_64 brew" | |
curl -Ls https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C "$BREW_X86_64_ROOT" | |
echo "Installing arm64 dependencies" | |
brew install meson ninja create-dmg sdl2 glew libarchive | |
echo "Installing x86_64 dependencies" | |
for dependency in pkg-config libb2 lz4 xz zstd sdl2 glew libarchive; do | |
echo "Fetching $dependency" | |
"$BREW_X86_64_ROOT/bin/brew" fetch --deps --force --bottle-tag=monterey "$dependency" | |
echo "Installing $dependency" | |
"$BREW_X86_64_ROOT/bin/brew" install $(brew --cache --bottle-tag=monterey "$dependency") | |
done | |
- name: Build Hades for arm64 | |
run: | | |
export BREW_ARM64_ROOT="/opt/homebrew/" | |
# Circumvent a bug with meson that fails to find static dependencies of dependencies by providing | |
# a directory containing only the static archives (.a), without the .dylib next to them. | |
mkdir libs-arm64 | |
cp $BREW_ARM64_ROOT/lib/*.a ./libs-arm64/ | |
export PKG_CONFIG_PATH="$BREW_ARM64_ROOT/opt/libarchive/lib/pkgconfig" | |
export PATH="$BREW_ARM64_ROOT/bin:$PATH" | |
export LDFLAGS="-L$(pwd)/libs-arm64/" | |
rm -rf /tmp/build-arm64/ | |
mkdir -p /tmp/build-arm64/Hades.app | |
meson --buildtype=release --prefix=/tmp/build-arm64/Hades.app --bindir=Contents/MacOS build-arm64 --werror -Dstatic_dependencies=true | |
ninja -C build-arm64 install | |
- name: Build Hades for x86_64 | |
run: | | |
export BREW_X86_64_ROOT="$HOME/x86_64-brew/" | |
# Circumvent a bug with meson that fails to find static dependencies of dependencies by providing | |
# a directory containing only the static archives (.a), without the .dylib next to them. | |
mkdir libs-x86_64 | |
cp -v $BREW_X86_64_ROOT/lib/*.a ./libs-x86_64/ | |
export PKG_CONFIG_PATH="$BREW_X86_64_ROOT/opt/libarchive/lib/pkgconfig" | |
export PATH="$BREW_X86_64_ROOT/bin:$PATH" | |
cat > x86_64-apple-macos << EOF | |
[host_machine] | |
system = 'darwin' | |
cpu_family = 'x86_64' | |
cpu = 'x86_64' | |
endian = 'little' | |
[binaries] | |
c = ['clang'] | |
cpp = ['clang++'] | |
objc = ['clang'] | |
objcpp = ['clang++'] | |
ar = ['ar'] | |
strip = ['strip'] | |
pkg-config = ['$BREW_X86_64_ROOT/bin/pkg-config'] | |
[constants] | |
target_flags = ['-target', 'x86_64-apple-macos12'] | |
include_flags = ['-I$BREW_X86_64_ROOT/include'] | |
link_flags = ['-L$PWD/libs-x86_64', '-L$BREW_X86_64_ROOT/lib'] | |
[built-in options] | |
c_args = target_flags + include_flags | |
cpp_args = target_flags + include_flags | |
objc_args = target_flags + include_flags | |
objcpp_args = target_flags + include_flags | |
c_link_args = target_flags + link_flags | |
cpp_link_args = target_flags + link_flags | |
objc_link_args = target_flags + link_flags | |
objcpp_link_args = target_flags + link_flags | |
EOF | |
rm -rf /tmp/build-x86_64/ | |
mkdir -p /tmp/build-x86_64/Hades.app | |
meson --cross-file ./x86_64-apple-macos --buildtype=release --prefix=/tmp/build-x86_64/Hades.app --bindir=Contents/MacOS build-x86_64 --werror -Dstatic_dependencies=true | |
ninja -C build-x86_64 install | |
- name: Build Hades Universal App | |
run: | | |
export BREW_X86_64_ROOT="$HOME/x86_64-brew/" | |
export BREW_ARM64_ROOT="/opt/homebrew/" | |
echo "Hades arm64 Dependencies" | |
otool -L /tmp/build-arm64/Hades.app/Contents/MacOS/hades | grep /opt/homebrew/ && false | |
echo "Hades x86_64 Dependencies" | |
otool -L /tmp/build-x86_64/Hades.app/Contents/MacOS/hades | grep /x86-64-brew/ && false | |
# Copy the application & remove all binaries | |
cp -r /tmp/build-arm64/ /tmp/build | |
rm -rf /tmp/build/Hades.app/Contents/MacOS/hades | |
rm -rf /tmp/build/Hades.app/Contents/MacOS/*.dylib | |
# Create the universal Hades binary | |
lipo -create -output /tmp/build/Hades.app/Contents/MacOS/hades /tmp/build-arm64/Hades.app/Contents/MacOS/hades /tmp/build-x86_64/Hades.app/Contents/MacOS/hades | |
echo "Hades (Universal) Dependencies:" | |
otool -L /tmp/build/Hades.app/Contents/MacOS/hades | |
echo "End of dependencies" | |
# Set permissions | |
chmod +x /tmp/build/Hades.app/Contents/MacOS/hades | |
- name: Test Hades App | |
run: | | |
/tmp/build/Hades.app/Contents/MacOS/hades --help | |
- name: Sign Hades App | |
# Only run if a certificate is set | |
if: ${{ env.MACOS_CODESIGN_CRT != '' && env.MACOS_CODESIGN_CRT_IDENTITY != '' }} | |
run: | | |
# Create keychain with certificate to use to sign the binaries. | |
echo "$MACOS_CODESIGN_CRT" | base64 -d > certificate.p12 | |
security create-keychain -p test123 build.keychain | |
security default-keychain -s build.keychain | |
security unlock-keychain -p test123 build.keychain | |
security import certificate.p12 -k build.keychain -P "$MACOS_CODESIGN_CRT_PWD" -T /usr/bin/codesign | |
# Delete certificate to avoid leaking it to next steps | |
rm certificate.p12 | |
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k test123 build.keychain | |
echo "Signing file /tmp/build/Hades.app" | |
/usr/bin/codesign --deep --force -s "$MACOS_CODESIGN_CRT_IDENTITY" --options runtime "/tmp/build/Hades.app" -v | |
# Get rid of the keychain containing certificate to avoid leaking it | |
# to next steps. | |
security lock-keychain build.keychain | |
security default-keychain -s | |
security delete-keychain build.keychain | |
env: | |
MACOS_CODESIGN_CRT: ${{ secrets.MACOS_CODESIGN_CRT }} | |
MACOS_CODESIGN_CRT_PWD: ${{ secrets.MACOS_CODESIGN_CRT_PWD }} | |
MACOS_CODESIGN_CRT_IDENTITY: ${{ secrets.MACOS_CODESIGN_CRT_IDENTITY }} | |
- name: Create Hades DMG | |
run: | | |
create-dmg \ | |
--volname "Hades Installer" \ | |
--volicon ./resource/macos/hades.icns \ | |
--background ./resource/macos/background.png \ | |
--window-pos 200 120 \ | |
--window-size 575 360 \ | |
--icon-size 100 \ | |
--icon Hades.app 150 225 \ | |
--hide-extension Hades.app \ | |
--app-drop-link 425 225 \ | |
Hades-Installer.dmg \ | |
/tmp/build/ | |
- name: Notarize Hades DMG | |
if: ${{ env.MACOS_APPLE_USERNAME != '' }} | |
run: | | |
echo "Notarizing file $file" | |
xcrun notarytool submit --apple-id "$MACOS_APPLE_USERNAME" --password "$MACOS_APPLE_PASSWORD" --team-id "$MACOS_APPLE_TEAMID" --wait "Hades-Installer.dmg" | |
xcrun stapler staple -v "Hades-Installer.dmg" | |
env: | |
MACOS_APPLE_USERNAME: ${{ secrets.MACOS_APPLE_USERNAME }} | |
MACOS_APPLE_PASSWORD: ${{ secrets.MACOS_APPLE_PASSWORD }} | |
MACOS_APPLE_TEAMID: ${{ secrets.MACOS_APPLE_TEAMID }} | |
- name: Collect Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hades-macos | |
path: Hades-Installer.dmg | |
if-no-files-found: error | |
linux-appimage: | |
name: Linux x64 (AppImage) | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Fetch Source Code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
meson \ | |
ninja-build \ | |
libfuse2 \ | |
libsdl2-dev \ | |
libglew-dev \ | |
libgtk-3-dev \ | |
libarchive-dev | |
- name: Build Hades | |
run: | | |
meson --buildtype=release --prefix=/usr build --werror | |
DESTDIR=$(pwd)/AppDir ninja -C build install | |
- name: Package Hades | |
uses: AppImageCrafters/build-appimage@master | |
with: | |
recipe: "./resource/linux/AppImageBuilder.yml" | |
- name: Test Hades | |
run: | | |
sudo chown --reference=. *.AppImage | |
mv -v *.AppImage hades.AppImage | |
./hades.AppImage --help | |
- name: Collect Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hades-linux-appimage | |
path: hades.AppImage | |
if-no-files-found: error | |
linux-ubuntu: | |
name: Linux x64 (Ubuntu ${{ matrix.version }}) | |
runs-on: ubuntu-${{ matrix.version }} | |
strategy: | |
matrix: | |
version: ["20.04", "22.04"] | |
include: | |
- dependency-glew: libglew2.1 | |
version: "20.04" | |
- dependency-glew: libglew2.2 | |
version: "22.04" | |
steps: | |
- name: Fetch Source Code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
meson \ | |
ninja-build \ | |
libsdl2-dev \ | |
libglew-dev \ | |
libgtk-3-dev \ | |
libarchive-dev | |
- name: Build Hades | |
run: | | |
meson --buildtype=release --prefix=/usr build --werror | |
DESTDIR=$(pwd)/pkg-root ninja -C build install | |
- name: Package Hades | |
uses: jiro4989/build-deb-action@v3 | |
with: | |
package: hades | |
package_root: pkg-root | |
maintainer: The Hades Authors | |
version: 1.0.0 | |
arch: 'amd64' | |
depends: 'libsdl2-2.0-0, libarchive13, libgtk-3-0, ${{ matrix.dependency-glew }}' | |
desc: 'A Nintendo Game Boy Advance Emulator.' | |
- name: Test Hades | |
run: | | |
sudo chown --reference=. *.deb | |
mv -v *.deb hades.deb | |
sudo apt install -y ./hades.deb | |
/usr/bin/hades --help | |
- name: Collect Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hades-linux-ubuntu-${{ matrix.version }} | |
path: hades.deb | |
if-no-files-found: error |