From 90461de5cfbd7447f8b8880aa3cabbd6c48815ca Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Thu, 26 Mar 2020 01:04:56 -0700 Subject: [PATCH] ci: Create .app bundle for macOS --- .github/workflows/build.yml | 21 ++++++++---- build.sh | 67 ++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17dbd4d2a1..1b58542af6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -131,11 +131,11 @@ jobs: if "${{ matrix.configuration }}" == "Debug": print('Configuring for Debug') print('::set-env name=BUILD_PARAM::--debug') - print('::set-env name=ARTIFACT_NAME::xemu-macos-debug') + print('::set-env name=ARTIFACT_NAME::xemu-macos-debug.zip') else: print('Configuring for Release') print('::set-env name=BUILD_PARAM::') - print('::set-env name=ARTIFACT_NAME::xemu-macos-release') + print('::set-env name=ARTIFACT_NAME::xemu-macos-release.zip') - name: Clone Tree uses: actions/checkout@v2 - name: Install Dependencies @@ -143,12 +143,13 @@ jobs: brew update brew unlink python@2 brew install \ - pixman \ - sdl2 \ - libepoxy \ + ccache \ coreutils \ + dylibbundler \ + libepoxy \ + pixman \ pkg-config \ - ccache + sdl2 - name: Initialize Compiler Cache id: cache uses: actions/cache@v1 @@ -164,6 +165,14 @@ jobs: ./build.sh ${{ env.BUILD_PARAM }} echo -e "\nCompiler Cache Stats:" ccache -s -c + pushd dist + zip -r ../${{env.ARTIFACT_NAME}} xemu.app + popd + - name: Upload Build Artifact + uses: actions/upload-artifact@v1 + with: + name: dist + path: ${{env.ARTIFACT_NAME}} Release: runs-on: ubuntu-latest diff --git a/build.sh b/build.sh index cdba438e7b..5412f143cc 100755 --- a/build.sh +++ b/build.sh @@ -13,6 +13,70 @@ package_windows() { # Script to prepare the windows exe strip dist/xemuw.exe } +package_macos() { + # + # Create bundle + # + rm -rf dist + + # Copy in executable + mkdir -p dist/xemu.app/Contents/MacOS/ + cp i386-softmmu/qemu-system-i386 dist/xemu.app/Contents/MacOS/xemu + + # Copy in in executable dylib dependencies + mkdir -p dist/xemu.app/Contents/Frameworks + dylibbundler -cd -of -b -x dist/xemu.app/Contents/MacOS/xemu \ + -d dist/xemu.app/Contents/Frameworks/ \ + -p '@executable_path/../Frameworks/' + + # Copy in runtime resources + mkdir -p dist/xemu.app/Contents/Resources + cp -r data dist/xemu.app/Contents/Resources + + # Generate icon file + mkdir -p xemu.iconset + for r in 16 32 128 256 512; do cp ui/icons/xemu_${r}x${r}.png xemu.iconset/icon_${r}x${r}.png; done + iconutil --convert icns --output dist/xemu.app/Contents/Resources/xemu.icns xemu.iconset + + # Generate Info.plist file + cat < dist/xemu.app/Contents/Info.plist + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + xemu + CFBundleIconFile + xemu.icns + CFBundleIdentifier + xemu.app.0 + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + xemu + CFBundlePackageType + APPL + CFBundleShortVersionString + 1 + CFBundleSignature + xemu + CFBundleVersion + 1 + LSApplicationCategoryType + public.app-category.games + LSMinimumSystemVersion + 10.6 + NSPrincipalClass + NSApplication + NSHighResolutionCapable + + + +EOF +} + postbuild='' debug_opts='' user_opts='' @@ -48,7 +112,7 @@ case "$(uname -s)" in # Adjust compilation options based on platform ;; Darwin) echo 'Compiling for MacOS...' - sys_cflags='-march=native' + sys_cflags='-march=ivybridge' sys_opts='--disable-cocoa' # necessary to find libffi, which is required by gobject export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}/usr/local/opt/libffi/lib/pkgconfig" @@ -59,6 +123,7 @@ case "$(uname -s)" in # Adjust compilation options based on platform echo 'Could not find a GNU compatible readlink. Please install coreutils with homebrew' exit -1 fi + postbuild='package_macos' ;; CYGWIN*|MINGW*|MSYS*) echo 'Compiling for Windows...'