Skip to content

Commit

Permalink
WebAssembly: build both the multithreaded and non-multithreaded versi…
Browse files Browse the repository at this point in the history
…ons in parallel
  • Loading branch information
oleg-derevenetz committed Jan 18, 2025
1 parent a154d7c commit 1c516cf
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 120 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,30 +20,30 @@ 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:
shell: bash
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: |
Expand Down
119 changes: 58 additions & 61 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 <<EOF
--- emsdk/upstream/emscripten/tools/ports/sdl2_mixer.py
Expand Down Expand Up @@ -381,30 +390,18 @@ jobs:
includes = [
EOF
- name: Build
if: ${{ contains( matrix.on, github.event_name ) }}
run: |
emmake make -f Makefile.emscripten -j "$(nproc)"
env:
FHEROES2_STRICT_COMPILATION: ON
FHEROES2_WITH_THREADS: ON
env: ${{ matrix.env }}
- name: Create package
if: ${{ contains( matrix.on, github.event_name ) }}
run: |
# Translations and H2D files are already included in fheroes2.data
7z a -bb1 -tzip -- fheroes2_emscripten.zip LICENSE changelog.txt fheroes2.data fheroes2.js fheroes2.wasm ./docs/README.txt ./files/emscripten/*
7z a -bb1 -tzip -- ${{ matrix.package_name }} LICENSE changelog.txt fheroes2.data fheroes2.js fheroes2.wasm ./docs/README.txt ./files/emscripten/*
- uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'pull_request' }}
if: ${{ contains( matrix.on, github.event_name ) }}
with:
name: fheroes2_emscripten.zip
path: fheroes2_emscripten.zip
name: ${{ matrix.package_name }}
path: ${{ matrix.package_name }}
if-no-files-found: error
- uses: ncipollo/release-action@v1
if: ${{ github.event_name == 'push' }}
with:
artifacts: fheroes2_emscripten.zip
body: ${{ github.event.head_commit.message }}
token: ${{ secrets.GITHUB_TOKEN }}
name: Emscripten build (latest commit)
tag: fheroes2-emscripten-sdl2_dev
allowUpdates: true
artifactErrorsFailBuild: true
prerelease: true
replacesArtifacts: true
Loading

0 comments on commit 1c516cf

Please sign in to comment.