From 1c516cf029624966cf15b40f4554ca6e4d328a61 Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Sat, 18 Jan 2025 22:08:45 +0300 Subject: [PATCH] WebAssembly: build both the multithreaded and non-multithreaded versions in parallel --- .github/workflows/cmake.yml | 16 ++--- .github/workflows/make.yml | 119 ++++++++++++++++++------------------ .github/workflows/msvc.yml | 84 ++++++++++--------------- 3 files changed, 99 insertions(+), 120 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b772924aa76..980642cbcac 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -9,7 +9,7 @@ jobs: cmake: strategy: matrix: - config: + include: - name: Linux SDL2 os: ubuntu-latest dependencies: libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev gettext ninja-build @@ -20,8 +20,8 @@ jobs: os: macos-latest dependencies: sdl2 sdl2_mixer sdl2_image ninja dylibbundler options: -DMACOS_APP_BUNDLE=ON - name: CMake (${{ matrix.config.name }}) - runs-on: ${{ matrix.config.os }} + name: CMake (${{ matrix.name }}) + runs-on: ${{ matrix.os }} timeout-minutes: 30 defaults: run: @@ -29,21 +29,21 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install dependencies (Linux) - if: ${{ startsWith( matrix.config.os, 'ubuntu-' ) }} + if: ${{ startsWith( matrix.os, 'ubuntu-' ) }} run: | sudo apt-get -y update - sudo apt-get -y install ${{ matrix.config.dependencies }} + sudo apt-get -y install ${{ matrix.dependencies }} - name: Install dependencies (macOS) - if: ${{ startsWith( matrix.config.os, 'macos-' ) }} + if: ${{ startsWith( matrix.os, 'macos-' ) }} run: | - brew install ${{ matrix.config.dependencies }} + brew install ${{ matrix.dependencies }} env: # Do not update outdated dependencies of installed packages HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: ON - name: Build run: | cmake -B build -G Ninja -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug -DENABLE_STRICT_COMPILATION=ON \ - -DENABLE_IMAGE=ON -DENABLE_TOOLS=ON ${{ matrix.config.options }} + -DENABLE_IMAGE=ON -DENABLE_TOOLS=ON ${{ matrix.options }} cmake --build build - name: Install run: | diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index fbcac67e406..f3676850a2d 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -10,9 +10,10 @@ jobs: make: strategy: matrix: - config: + include: - name: Linux x86-64 SDL2 Release - os: ubuntu-20.04 + on: [ 'pull_request', 'push' ] + os: ubuntu-22.04 dependencies: libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev gettext env: FHEROES2_STRICT_COMPILATION: ON @@ -45,6 +46,7 @@ jobs: release_name: Ubuntu x86-64 (Linux) build with SDL2 (latest commit) release_tag: fheroes2-linux-sdl2_dev - name: Linux x86-64 SDL2 Debug + on: [ 'pull_request' ] os: ubuntu-latest dependencies: libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev gettext env: @@ -54,6 +56,7 @@ jobs: FHEROES2_WITH_DEBUG: ON FHEROES2_WITH_ASAN: ON - name: Linux ARM64 SDL2 Release + on: [ 'pull_request', 'push' ] os: ubuntu-22.04-arm dependencies: libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev gettext env: @@ -87,6 +90,7 @@ jobs: release_name: Ubuntu ARM64 (Linux) build with SDL2 (latest commit) release_tag: fheroes2-linux-arm-sdl2_dev - name: Linux ARM64 SDL2 Debug + on: [ 'pull_request' ] os: ubuntu-24.04-arm dependencies: libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev gettext env: @@ -96,6 +100,7 @@ jobs: FHEROES2_WITH_DEBUG: ON FHEROES2_WITH_TSAN: ON - name: macOS SDL2 + on: [ 'pull_request', 'push' ] os: macos-13 dependencies: sdl2 sdl2_mixer sdl2_image env: @@ -129,82 +134,69 @@ jobs: release_name: macOS x86-64 build with SDL2 (latest commit) release_tag: fheroes2-osx-sdl2_dev - name: macOS SDL2 App Bundle + on: [ 'pull_request' ] os: macos-latest dependencies: sdl2 sdl2_mixer dylibbundler env: FHEROES2_STRICT_COMPILATION: ON FHEROES2_WITH_TOOLS: ON FHEROES2_MACOS_APP_BUNDLE: ON - name: Make (${{ matrix.config.name }}) - runs-on: ${{ matrix.config.os }} + name: Make (${{ matrix.name }}) + runs-on: ${{ matrix.os }} timeout-minutes: 30 defaults: run: shell: bash steps: - uses: actions/checkout@v4 + if: ${{ contains( matrix.on, github.event_name ) }} - name: Install dependencies (Linux) - if: ${{ startsWith( matrix.config.os, 'ubuntu-' ) }} + if: ${{ contains( matrix.on, github.event_name ) && startsWith( matrix.os, 'ubuntu-' ) }} run: | sudo apt-get -y update - sudo apt-get -y install ${{ matrix.config.dependencies }} + sudo apt-get -y install ${{ matrix.dependencies }} - name: Install dependencies (macOS) - if: ${{ startsWith( matrix.config.os, 'macos-' ) }} + if: ${{ contains( matrix.on, github.event_name ) && startsWith( matrix.os, 'macos-' ) }} run: | - brew install ${{ matrix.config.dependencies }} + brew install ${{ matrix.dependencies }} env: # Do not update outdated dependencies of installed packages HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: ON - name: Build (Linux) - if: ${{ startsWith( matrix.config.os, 'ubuntu-' ) }} + if: ${{ contains( matrix.on, github.event_name ) && startsWith( matrix.os, 'ubuntu-' ) }} run: | make -j "$(nproc)" - env: ${{ matrix.config.env }} + env: ${{ matrix.env }} - name: Build (MacOS) - if: ${{ startsWith( matrix.config.os, 'macos-' ) }} + if: ${{ contains( matrix.on, github.event_name ) && startsWith( matrix.os, 'macos-' ) }} run: | make -j "$(sysctl -n hw.logicalcpu)" - env: ${{ matrix.config.env }} - - name: Create package - if: ${{ matrix.config.package_name != '' && matrix.config.package_files != '' }} - run: | - 7z a -bb1 -tzip -- ${{ matrix.config.package_name }} ${{ matrix.config.package_files }} - - name: Create tools package - if: ${{ matrix.config.tools_package_name != '' && matrix.config.tools_package_files != '' }} + env: ${{ matrix.env }} + - name: Create packages + if: ${{ contains( matrix.on, github.event_name ) && matrix.package_name != '' && matrix.tools_package_name != '' }} run: | - 7z a -bb1 -tzip -- ${{ matrix.config.tools_package_name }} ${{ matrix.config.tools_package_files }} + 7z a -bb1 -tzip -- ${{ matrix.package_name }} ${{ matrix.package_files }} + 7z a -bb1 -tzip -- ${{ matrix.tools_package_name }} ${{ matrix.tools_package_files }} - uses: actions/upload-artifact@v4 - if: ${{ github.event_name == 'pull_request' && matrix.config.package_name != '' }} + if: ${{ contains( matrix.on, github.event_name ) && github.event_name == 'pull_request' && matrix.package_name != '' }} with: - name: ${{ matrix.config.package_name }} - path: ${{ matrix.config.package_name }} + name: ${{ matrix.package_name }} + path: ${{ matrix.package_name }} if-no-files-found: error - uses: actions/upload-artifact@v4 - if: ${{ github.event_name == 'pull_request' && matrix.config.tools_package_name != '' }} + if: ${{ contains( matrix.on, github.event_name ) && github.event_name == 'pull_request' && matrix.tools_package_name != '' }} with: - name: ${{ matrix.config.tools_package_name }} - path: ${{ matrix.config.tools_package_name }} + name: ${{ matrix.tools_package_name }} + path: ${{ matrix.tools_package_name }} if-no-files-found: error - uses: ncipollo/release-action@v1 - if: ${{ github.event_name == 'push' && matrix.config.package_name != '' && matrix.config.tools_package_name == '' && matrix.config.release_name != '' && matrix.config.release_tag != '' }} - with: - artifacts: ${{ matrix.config.package_name }} - body: ${{ github.event.head_commit.message }} - token: ${{ secrets.GITHUB_TOKEN }} - name: ${{ matrix.config.release_name }} - tag: ${{ matrix.config.release_tag }} - allowUpdates: true - artifactErrorsFailBuild: true - prerelease: true - replacesArtifacts: true - - uses: ncipollo/release-action@v1 - if: ${{ github.event_name == 'push' && matrix.config.package_name != '' && matrix.config.tools_package_name != '' && matrix.config.release_name != '' && matrix.config.release_tag != '' }} + if: ${{ contains( matrix.on, github.event_name ) && github.event_name == 'push' }} with: - artifacts: ${{ matrix.config.package_name }}, ${{ matrix.config.tools_package_name }} + artifacts: ${{ matrix.package_name }}, ${{ matrix.tools_package_name }} body: ${{ github.event.head_commit.message }} token: ${{ secrets.GITHUB_TOKEN }} - name: ${{ matrix.config.release_name }} - tag: ${{ matrix.config.release_tag }} + name: ${{ matrix.release_name }} + tag: ${{ matrix.release_tag }} allowUpdates: true artifactErrorsFailBuild: true prerelease: true @@ -327,7 +319,21 @@ jobs: prerelease: true replacesArtifacts: true make-emscripten: - name: Make (Emscripten) + strategy: + matrix: + include: + - name: Emscripten + on: [ 'pull_request' ] + env: + FHEROES2_STRICT_COMPILATION: ON + package_name: fheroes2_emscripten.zip + - name: Emscripten Multithreaded + on: [ 'pull_request' ] + env: + FHEROES2_STRICT_COMPILATION: ON + FHEROES2_WITH_THREADS: ON + package_name: fheroes2_emscripten_mt.zip + name: Make (${{ matrix.name }}) runs-on: ubuntu-latest container: emscripten/emsdk:3.1.74 timeout-minutes: 30 @@ -336,11 +342,14 @@ jobs: shell: bash steps: - uses: actions/checkout@v4 + if: ${{ contains( matrix.on, github.event_name ) }} - name: Install dependencies + if: ${{ contains( matrix.on, github.event_name ) }} run: | sudo apt-get -y update sudo apt-get -y install gettext p7zip-full - name: Apply temporary patch + if: ${{ contains( matrix.on, github.event_name ) }} run: | patch -d / -p0 -f <