Skip to content

Commit

Permalink
CI: Add webassembly build
Browse files Browse the repository at this point in the history
  • Loading branch information
syyyr committed Apr 18, 2024
1 parent 9cc6650 commit e6c40c1
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 12 deletions.
48 changes: 36 additions & 12 deletions .github/actions/cmake/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
description: "Specify Qt version to use"
required: true
qt_arch:
description: "Specify Qt version to use"
description: "Specify Qt arch to use"
default: "gcc_64"
use_qt6:
description: "Specify whether we're using Qt 5 or Qt 6"
Expand All @@ -16,6 +16,9 @@ inputs:
additional_cmake_args:
description: "Additional args to pass to CMake"
default: ""
emsdk_cache_dir:
description: "Where to store emsdk cache"
default: "emsdk-cache"

runs:
using: "composite"
Expand Down Expand Up @@ -45,6 +48,26 @@ runs:
arch: ${{ inputs.qt_arch }}
install-deps: false
modules: ${{ inputs.modules }}
extra: --autodesktop

- name: WASM-specific stuff
if: inputs.qt_arch == 'wasm_singlethread'
run: |
echo cmake_extra_args="'-DBUILD_SHARED_LIBS=OFF' '-DQT_HOST_PATH=$(realpath ${Qt6_DIR}/../gcc_64)'" >> "$GITHUB_ENV"
shell: bash

- name: Setup emsdk cache
id: cache-system-libraries
uses: actions/cache@v2
with:
key: emsdk-cache
path: ${{ inputs.emsdk_cache_dir }}

- uses: mymindstorm/setup-emsdk@v14
if: inputs.qt_arch == 'wasm_singlethread'
with:
version: 3.1.37
actions-cache-folder: ${{ inputs.emsdk_cache_dir }}

- name: ccache
uses: hendrikmuhs/[email protected]
Expand All @@ -53,17 +76,18 @@ runs:

- name: Configure CMake
run: |
chmod +x "${Qt6_DIR}/bin/qt-cmake"
CFLAGS="-Werror ${CFLAGS}" \
CXXFLAGS="-Werror ${CXXFLAGS}" \
cmake \
-S '${{github.workspace}}' \
-B '${{github.workspace}}/build' \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DSHVSPY_USE_QT6=${{ inputs.use_qt6 }} \
${{ env.cmake_extra_args }} \
${{ inputs.additional_cmake_args }}
qt-cmake \
-S '${{github.workspace}}' \
-B '${{github.workspace}}/build' \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DSHVSPY_USE_QT6=${{ inputs.use_qt6 }} \
${{ env.cmake_extra_args }} \
${{ inputs.additional_cmake_args }}
shell: bash
54 changes: 54 additions & 0 deletions .github/workflows/webassembly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: WebAssembly

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
pages: write

jobs:
ubuntu-qt6-wasm:
name: Qt 6.6.3 / Ubuntu 22.04
runs-on: ubuntu-22.04
steps:
- name: Clone the repository
uses: actions/checkout@v3
with:
submodules: true

- name: Setup CMake
uses: ./.github/actions/cmake
with:
qt_version: 6.6.3
qt_arch: wasm_singlethread
use_qt6: ON
modules: qtwebsockets
additional_cmake_args: -DCMAKE_INSTALL_PREFIX='${{ github.workspace }}/install-shvspy'

- name: Build
run: cmake --build '${{github.workspace}}/build' --parallel "$(nproc)"
shell: bash

- name: Consolidate WebAssembly artifacts
run: |
mkdir gh-sources
cp '${{github.workspace}}'/build/shvspy/*.js '${{github.workspace}}'/build/shvspy/*.wasm '${{github.workspace}}'/build/shvspy/*.html gh-sources/
shell: bash

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: 'gh-sources/'

- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v2

0 comments on commit e6c40c1

Please sign in to comment.