extract functions #194
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: macOS builds | |
on: [push, pull_request] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
CCACHE_DIR: "${{ github.workspace }}/.ccache" | |
CCACHE_MAXSIZE: "64M" | |
CCACHE_COMPRESS: "true" | |
CLAMDB_DIR: "/usr/local/Cellar/clamav" | |
jobs: | |
build_macos: | |
name: ${{ matrix.conf.name }} (${{ matrix.conf.arch }}) | |
runs-on: ${{ matrix.conf.host }} | |
if: github.event_name != 'pull_request' || contains('dreamer,kcgen,ant-222,Wengier,kklobe', github.actor) == false | |
strategy: | |
fail-fast: false | |
matrix: | |
conf: | |
- name: Clang (macos-10.15) | |
host: macos-10.15 | |
arch: x86_64 | |
needs_deps: true | |
packages: meson | |
build_flags: -Dunit_tests=disabled | |
max_warnings: 0 | |
- name: Clang | |
host: macos-latest | |
arch: x86_64 | |
needs_deps: true | |
packages: meson | |
build_flags: -Dunit_tests=disabled | |
max_warnings: 0 | |
- name: GCC 11 | |
host: macos-latest | |
arch: x86_64 | |
needs_deps: true | |
packages: gcc@11 | |
build_flags: -Dunit_tests=disabled --native-file=.github/meson/native-gcc-11.ini | |
max_warnings: 0 | |
- name: Clang, +tests | |
host: macos-latest | |
arch: x86_64 | |
needs_deps: true | |
run_tests: true | |
max_warnings: -1 | |
- name: Clang, +debugger | |
host: macos-latest | |
arch: x86_64 | |
needs_deps: true | |
build_flags: -Dunit_tests=disabled -Denable_debugger=normal | |
max_warnings: 0 | |
- name: Clang | |
host: [self-hosted, macOS, arm64, debug-builds] | |
arch: arm64 | |
needs_deps: false | |
packages: meson | |
build_flags: -Dunit_tests=disabled | |
max_warnings: 0 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Prepare brew and compiler caches | |
if: matrix.conf.needs_deps | |
id: prep-caches | |
shell: bash | |
run: | | |
set -eu | |
BREW_DIR="$(brew --cache)" | |
DISCARD_DIR="${{ github.workspace }}/discard" | |
mkdir -p "$DISCARD_DIR" | |
mv -f "$BREW_DIR"/* "$DISCARD_DIR" | |
mkdir -p "$CCACHE_DIR" | |
echo "::set-output name=brew_dir::$BREW_DIR" | |
echo "::set-output name=ccache_dir::$CCACHE_DIR" | |
echo "::set-output name=today::$(date +%F)" | |
echo "::set-output name=name_hash::$(echo '${{ matrix.conf.name }} ${{ matrix.conf.arch }}' | shasum | cut -b-8)" | |
- uses: actions/cache@v2 | |
if: matrix.conf.needs_deps | |
with: | |
path: ${{ steps.prep-caches.outputs.brew_dir }} | |
key: brew-cache-${{ matrix.conf.arch }}-${{ steps.prep-caches.outputs.today }}-1 | |
restore-keys: brew-cache-${{ matrix.conf.arch }}- | |
- name: Install C++ compiler and libraries | |
if: matrix.conf.needs_deps | |
run: | | |
arch -arch=${{ matrix.conf.arch }} brew install \ | |
${{ matrix.conf.packages }} \ | |
$(cat ./.github/packages/macos-latest-brew.txt) | |
- uses: actions/cache@v2 | |
if: matrix.conf.needs_deps | |
with: | |
path: ${{ steps.prep-caches.outputs.ccache_dir }} | |
key: ccache-macos-debug-${{ steps.prep-caches.outputs.name_hash }}-${{ steps.prep-caches.outputs.today }}-1 | |
restore-keys: | | |
ccache-macos-debug-${{ steps.prep-caches.outputs.name_hash }}- | |
ccache-macos-debug- | |
- name: Cache subprojects | |
uses: actions/cache@v2 | |
with: | |
path: subprojects/packagecache | |
key: subprojects-${{ hashFiles('subprojects/*.wrap') }} | |
- name: Log environment | |
run: arch -arch=${{ matrix.conf.arch }} ./scripts/log-env.sh | |
- run: arch -arch=${{ matrix.conf.arch }} meson setup ${{ matrix.conf.build_flags }} build | |
- name: Build | |
run: | | |
set -xo pipefail | |
arch -arch=${{ matrix.conf.arch }} meson compile -C build 2>&1 | tee build.log | |
- name: Run tests | |
if: matrix.conf.run_tests | |
run: arch -arch=${{ matrix.conf.arch }} meson test -C build --print-errorlogs | |
- name: Summarize warnings | |
if: matrix.conf.run_tests != true | |
env: | |
MAX_WARNINGS: ${{ matrix.conf.max_warnings }} | |
run: arch -arch=${{ matrix.conf.arch }} python3 ./scripts/count-warnings.py -lf build.log | |
build_macos_release: | |
name: Release build (${{ matrix.runner.arch }}) | |
runs-on: ${{ matrix.runner.host }} | |
if: github.event_name != 'pull_request' || contains('dreamer,kcgen,ant-222,Wengier,kklobe', github.actor) == false | |
env: | |
MIN_SUPPORTED_MACOSX_DEPLOYMENT_TARGET: ${{ matrix.runner.minimum_deployment }} | |
strategy: | |
matrix: | |
runner: | |
- host: macos-10.15 | |
arch: x86_64 | |
build_flags: --native-file=.github/meson/macos-10.15-deployment-target.ini | |
minimum_deployment: '10.15' | |
needs_deps: true | |
needs_libintl_workaround: true | |
- host: [self-hosted, macOS, arm64, release-builds] | |
arch: arm64 | |
minimum_deployment: '11.0' | |
needs_deps: false | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Prepare brew and compiler caches | |
if: matrix.runner.needs_deps | |
id: prep-caches | |
shell: bash | |
run: | | |
set -eu | |
BREW_DIR="$(brew --cache)" | |
DISCARD_DIR="${{ github.workspace }}/discard" | |
mkdir -p "$DISCARD_DIR" | |
mv -f "$BREW_DIR"/* "$DISCARD_DIR" | |
mkdir -p "$CCACHE_DIR" | |
echo "::set-output name=brew_dir::$BREW_DIR" | |
echo "::set-output name=ccache_dir::$CCACHE_DIR" | |
echo "::set-output name=today::$(date +%F)" | |
- uses: actions/cache@v2 | |
if: matrix.runner.needs_deps | |
with: | |
path: ${{ steps.prep-caches.outputs.brew_dir }} | |
key: brew-cache-${{ matrix.runner.arch }}-${{ steps.prep-caches.outputs.today }} | |
restore-keys: brew-cache-${{ matrix.runner.arch }}- | |
- name: Install C++ compiler and libraries | |
if: matrix.runner.needs_deps | |
run: >- | |
arch -arch=${{ matrix.runner.arch }} brew install librsvg tree | |
ccache libpng meson opusfile sdl2 sdl2_net | |
- uses: actions/cache@v2 | |
if: matrix.runner.needs_deps | |
with: | |
path: ${{ steps.prep-caches.outputs.ccache_dir }} | |
key: ccache-macos-release-${{ matrix.runner.arch }}-${{ steps.prep-caches.outputs.today }}-1 | |
restore-keys: ccache-macos-release-${{ matrix.runner.arch }}- | |
- name: Cache subprojects | |
uses: actions/cache@v2 | |
with: | |
path: subprojects/packagecache | |
key: subprojects-${{ hashFiles('subprojects/*.wrap') }} | |
- name: Log environment | |
run: arch -arch=${{ matrix.runner.arch }} ./scripts/log-env.sh | |
- name: Inject version string | |
run: | | |
set -x | |
git fetch --prune --unshallow | |
export VERSION=$(git describe --abbrev=5) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
# KLUDGE: Work-around for the scenario where glib's wrap links with libintl | |
# dynamically, which adds a dependency into a brew dynlib package (in /usr/local/..), | |
# which some users won't have. So we knockout libintl.dynlib (by removing gettext | |
# removal), however this also breaks git: so we do a mock-meson setup to fetch all the | |
# git wraps before knocking it. then we re-add gettext after the build, so git can work | |
# for subsequent steps. | |
# | |
- name: Fetch subprojects then remove libintl.8.dylib | |
if: matrix.runner.needs_libintl_workaround | |
run: | | |
set -ex | |
meson setup -Ddefault_library=static --wrap-mode=forcefallback -Dfluidsynth:try-static-deps=true build | |
git clone --depth 1 --branch "0.2" https://github.com/frida/proxy-libintl.git subprojects/proxy-libintl | |
brew uninstall -f --ignore-dependencies gettext | |
rm -rf build | |
- name: Setup release build | |
run: >- | |
arch -arch=${{ matrix.runner.arch }} meson setup | |
${{ matrix.conf.build_flags }} | |
--wrap-mode=forcefallback | |
-Dbuildtype=release | |
-Db_lto=true | |
-Db_asneeded=true | |
-Ddefault_library=static | |
-Dtry_static_libs=opusfile,sdl2,sdl2_net | |
-Dfluidsynth:try-static-deps=true | |
build | |
- name: Build | |
run: arch -arch=${{ matrix.runner.arch }} ninja -C build | |
- name: Reinstate libintl.8.dylib | |
if: matrix.runner.needs_libintl_workaround | |
run: brew install gettext | |
- name: Upload binary | |
uses: actions/upload-artifact@v2 | |
with: | |
name: dosbox-${{ matrix.runner.arch }} | |
path: build/dosbox | |
publish_universal_build: | |
name: Publish universal build | |
needs: build_macos_release | |
runs-on: macos-10.15 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Inject version string | |
run: | | |
set -x | |
git fetch --prune --unshallow | |
export VERSION=$(git describe --abbrev=5) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Install brew depedencies | |
run: brew install librsvg | |
- name: Download binaries | |
uses: actions/download-artifact@v2 | |
- name: Package | |
run: | | |
./scripts/create-package.sh \ | |
-p macos \ | |
-v "${{ env.VERSION }}" \ | |
-f \ | |
"$(pwd)" \ | |
"$(pwd)" | |
- name: Create dmg | |
run: | | |
ln -s /Applications dist/ | |
codesign -s "-" dist/dosbox-staging.app --force --deep -v | |
hdiutil create \ | |
-volname "dosbox-staging" \ | |
-srcfolder dist \ | |
-ov -format UDZO "dosbox-staging-macOS-${{ env.VERSION }}.dmg" | |
- name: Clam AV scan | |
id: prep-clamdb | |
shell: bash | |
run: | | |
brew install clamav | |
clamscan --heuristic-scan-precedence=yes --recursive --infected dist || true | |
- name: Upload disk image | |
uses: actions/upload-artifact@v2 | |
# GitHub automatically zips the artifacts, and there's no option | |
# to skip it or upload a file only. | |
with: | |
name: dosbox-staging-macOS-universal | |
path: dosbox-staging-macOS-${{ env.VERSION }}.dmg | |
# This job exists only to publish an artifact with version info when building | |
# from main branch, so snapshot build version will be visible on: | |
# https://dosbox-staging.github.io/downloads/devel/ | |
# | |
publish_additional_artifacts: | |
name: Publish additional artifacts | |
needs: build_macos_release | |
runs-on: macos-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Generate changelog | |
run: | | |
set +x | |
git fetch --unshallow | |
VERSION=$(git describe --abbrev=4) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
NEWEST_TAG=$(git describe --abbrev=0) | |
git log "$NEWEST_TAG..HEAD" > changelog-$VERSION.txt | |
- uses: actions/upload-artifact@v2 | |
with: | |
# Keep exactly this artifact name; it's being used to propagate | |
# version info via GitHub REST API | |
name: changelog-${{ env.VERSION }}.txt | |
path: changelog-${{ env.VERSION }}.txt |