diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2e1742..db614c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,20 +17,25 @@ on: jobs: build: runs-on: ${{ matrix.runner }} - name: ${{ matrix.platform }} ${{ matrix.target }} ${{ matrix.arch }} ${{ matrix.optimize }} + name: ${{ matrix.platform }} ${{ matrix.target }} ${{ matrix.arch }} ${{ matrix.optimize }} ${{ matrix.scons_args }} + env: - BUILD_ID: ${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.arch }}-${{ matrix.optimize }} + BUILD_ID: ${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.arch }}-${{ matrix.optimize }}-${{ matrix.scons_args }} + EM_VERSION: 4.0.9 + EM_CACHE_FOLDER: "emsdk-cache" + strategy: fail-fast: false matrix: target: [ template_debug, template_release ] - identifier: [ windows, linux, macos, android, android_arm64 ] + identifier: [ windows, linux, macos, android, android_arm64, web ] include: # Defaults - runner: ubuntu-22.04 - optimize: speed - arch: x86_64 + - scons_args: # Debug build settings - target: template_debug @@ -55,6 +60,11 @@ jobs: platform: android arch: arm64 + - identifier: web + platform: web + arch: wasm32 + scons_args: threads=no + steps: - name: Check settings if: ${{ matrix.platform == '' || matrix.target == '' || matrix.runner == '' || matrix.optimize == '' || matrix.arch == ''}} @@ -95,6 +105,20 @@ jobs: ndk-version: r23c link-to-sdk: true + - name: (Web) Set up Emscripten cache + if: ${{ matrix.platform == 'web' }} + uses: actions/cache@v4 + with: + path: ${{env.EM_CACHE_FOLDER}} + key: ${{env.EM_VERSION}}-${{ env.BUILD_ID }} + + - name: (Web) Set up Emscripten + if: ${{ matrix.platform == 'web' }} + uses: mymindstorm/setup-emsdk@v14 + with: + version: ${{env.EM_VERSION}} + actions-cache-folder: ${{env.EM_CACHE_FOLDER}} + - name: Set up Python uses: actions/setup-python@v5 with: @@ -113,21 +137,6 @@ jobs: submodules: recursive ref: ${{ inputs.git-ref }} -# TODO: Cache doesn't work yet. SCons rebuilds the objects even if they already exist. Could be caused by modification dates or extension_api.json. -# fetch-depth: 0 May be needed for cache. See: . -# - name: Set up SCons cache -# uses: actions/cache@v3 -# with: -# path: | -# ${{ github.workspace }}/.scons-cache/ -# ${{ github.workspace }}/**/.sconsign.dblite -# ${{ github.workspace }}/godot-cpp/gen/ -# key: ${{ matrix.platform }}-${{ github.ref }}-${{ github.sha }} -# restore-keys: | -# ${{ matrix.platform }}-${{ github.ref }}-${{ github.sha }} -# ${{ matrix.platform }}-${{ github.ref }} -# ${{ matrix.platform }} - - name: Scons Cache id: scons-cache uses: actions/cache@v4 @@ -140,7 +149,7 @@ jobs: env: SCONS_CACHE: .scons-cache run: | - scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' optimize=${{ matrix.optimize }} -j2 + scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' optimize=${{ matrix.optimize }} ${{ matrix.scons_args }} -j2 ls -l demo/addons/*/bin/ - name: Prepare files for publish diff --git a/.github/workflows/web-build.yml b/.github/workflows/web-build.yml new file mode 100644 index 0000000..fcb7fe6 --- /dev/null +++ b/.github/workflows/web-build.yml @@ -0,0 +1,111 @@ +# Adapted from https://github.com/nathanfranke/gdextension/blob/main/.github/workflows/build.yml +name: Web Export Template +on: + workflow_dispatch: + inputs: + git-ref: + description: A commit, branch or tag to build. + type: string + required: true + workflow_call: + inputs: + git-ref: + description: A commit, branch or tag to build. + type: string + required: true + +jobs: + build: + runs-on: ubuntu-22.04 + name: Web ${{ matrix.target }} ${{ matrix.optimize }} + + env: + BUILD_ID: web-${{ matrix.target }}-${{ matrix.optimize }}-${{ matrix.threads }} + EM_VERSION: 4.0.9 + EM_CACHE_FOLDER: "emsdk-cache" + GODOT_REF: godot-4.4-stable + SCONS_CACHE: .scons-cache + + strategy: + fail-fast: false + matrix: + target: [ template_debug, template_release ] + threads: [ yes, no ] + + include: + # Defaults + - optimize: speed + + # Debug build settings + - target: template_debug + optimize: speed_trace + + steps: + - name: Check settings + if: ${{ matrix.platform == '' || matrix.target == '' || matrix.runner == '' || matrix.optimize == '' || matrix.arch == ''}} + run: | + echo "One of the matrix values is not set." + exit 1 + + - name: (Web) Set up Emscripten cache + if: ${{ matrix.platform == 'web' }} + uses: actions/cache@v4 + with: + path: ${{env.EM_CACHE_FOLDER}} + key: ${{env.EM_VERSION}}-${{ env.BUILD_ID }} + + - name: (Web) Set up Emscripten + if: ${{ matrix.platform == 'web' }} + uses: mymindstorm/setup-emsdk@v14 + with: + version: ${{env.EM_VERSION}} + actions-cache-folder: ${{env.EM_CACHE_FOLDER}} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Set up SCons + shell: bash + run: | + python -c "import sys; print(sys.version)" + python -m pip install scons==4.7.0 + scons --version + + - name: Clone Godot + uses: actions/checkout@v4 + with: + repository: godotengine/godot + ref: ${{ env.GODOT_REF }} + + - name: Scons Cache + id: scons-cache + uses: actions/cache@v4 + with: + path: ${{ env.SCONS_CACHE }} + key: ${{ env.BUILD_ID }} + + - name: Compile extension + shell: sh + run: | + scons target='${{ matrix.target }}' platform=web optimize=${{ matrix.optimize }} -j2 + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: godot-${{ env.BUILD_ID }} + path: | + ${{ github.workspace }}/demo/ + merge: + runs-on: ubuntu-latest + needs: build + steps: + - name: Git describe + id: ghd + uses: proudust/gh-describe@v2 + - name: Merge Artifacts + uses: actions/upload-artifact/merge@v4 + with: + name: ${{ github.event.repository.name }}-${{ steps.ghd.outputs.describe }} + pattern: godot-* diff --git a/demo/addons/ropesim/libropesim.gdextension b/demo/addons/ropesim/libropesim.gdextension index fb89e6d..c1c9d89 100644 --- a/demo/addons/ropesim/libropesim.gdextension +++ b/demo/addons/ropesim/libropesim.gdextension @@ -15,3 +15,5 @@ android.debug.x86_64 = "res://addons/ropesim/bin/libropesim.android.template_deb android.release.x86_64 = "res://addons/ropesim/bin/libropesim.android.template_release.x86_64.so" android.debug.arm64 = "res://addons/ropesim/bin/libropesim.android.template_debug.arm64.so" android.release.arm64 = "res://addons/ropesim/bin/libropesim.android.template_release.arm64.so" +web.debug.wasm32 = "res://addons/ropesim/bin/libropesim.web.template_debug.wasm32.wasm" +web.release.wasm32 = "res://addons/ropesim/bin/libropesim.web.template_release.wasm32.wasm"