Skip to content

Commit fbf65fe

Browse files
committed
Add web build
1 parent 20eaa00 commit fbf65fe

File tree

5 files changed

+44
-24
lines changed

5 files changed

+44
-24
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,26 @@ on:
1717
jobs:
1818
build:
1919
runs-on: ${{ matrix.runner }}
20-
name: ${{ matrix.platform }} ${{ matrix.target }} ${{ matrix.arch }} ${{ matrix.optimize }}
20+
name: ${{ matrix.platform }} ${{ matrix.target }} ${{ matrix.arch }} ${{ matrix.optimize }} ${{ matrix.scons_args }}
21+
2122
env:
22-
BUILD_ID: ${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.arch }}-${{ matrix.optimize }}
23+
BUILD_ID: ${{ matrix.platform }}-${{ matrix.target }}-${{ matrix.arch }}-${{ matrix.optimize }}${{ matrix.scons_args && '-' || ''}}${{ matrix.scons_args }}
24+
EM_VERSION: 3.1.64
25+
EM_CACHE_FOLDER: "emsdk-cache"
26+
SCONS_CACHE: .scons-cache
27+
2328
strategy:
2429
fail-fast: false
2530
matrix:
2631
target: [ template_debug, template_release ]
27-
identifier: [ windows, linux, macos, android, android_arm64 ]
32+
identifier: [ windows, linux, macos, android, android_arm64, web_threads, web_nothreads ]
2833

2934
include:
3035
# Defaults
3136
- runner: ubuntu-22.04
3237
- optimize: speed
3338
- arch: x86_64
39+
- scons_args:
3440

3541
# Debug build settings
3642
- target: template_debug
@@ -55,6 +61,16 @@ jobs:
5561
platform: android
5662
arch: arm64
5763

64+
- identifier: web_threads
65+
platform: web
66+
arch: wasm32
67+
scons_args: threads=yes
68+
69+
- identifier: web_nothreads
70+
platform: web
71+
arch: wasm32
72+
scons_args: threads=no
73+
5874
steps:
5975
- name: Check settings
6076
if: ${{ matrix.platform == '' || matrix.target == '' || matrix.runner == '' || matrix.optimize == '' || matrix.arch == ''}}
@@ -95,6 +111,20 @@ jobs:
95111
ndk-version: r23c
96112
link-to-sdk: true
97113

114+
- name: (Web) Set up Emscripten cache
115+
if: ${{ matrix.platform == 'web' }}
116+
uses: actions/cache@v4
117+
with:
118+
path: ${{env.EM_CACHE_FOLDER}}
119+
key: ${{env.EM_VERSION}}-${{ env.BUILD_ID }}
120+
121+
- name: (Web) Set up Emscripten
122+
if: ${{ matrix.platform == 'web' }}
123+
uses: mymindstorm/setup-emsdk@v14
124+
with:
125+
version: ${{env.EM_VERSION}}
126+
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
127+
98128
- name: Set up Python
99129
uses: actions/setup-python@v5
100130
with:
@@ -113,35 +143,18 @@ jobs:
113143
submodules: recursive
114144
ref: ${{ inputs.git-ref }}
115145

116-
# 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.
117-
# fetch-depth: 0 May be needed for cache. See: <https://github.com/actions/checkout/issues/468>.
118-
# - name: Set up SCons cache
119-
# uses: actions/cache@v3
120-
# with:
121-
# path: |
122-
# ${{ github.workspace }}/.scons-cache/
123-
# ${{ github.workspace }}/**/.sconsign.dblite
124-
# ${{ github.workspace }}/godot-cpp/gen/
125-
# key: ${{ matrix.platform }}-${{ github.ref }}-${{ github.sha }}
126-
# restore-keys: |
127-
# ${{ matrix.platform }}-${{ github.ref }}-${{ github.sha }}
128-
# ${{ matrix.platform }}-${{ github.ref }}
129-
# ${{ matrix.platform }}
130-
131146
- name: Scons Cache
132147
id: scons-cache
133148
uses: actions/cache@v4
134149
with:
135-
path: .scons-cache
150+
path: ${{ env.SCONS_CACHE }}
136151
key: ${{ env.BUILD_ID }}
137152

138153
- name: Compile extension
139154
shell: sh
140-
env:
141-
SCONS_CACHE: .scons-cache
142155
run: |
143-
scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' optimize=${{ matrix.optimize }} -j2
144-
ls -l demo/addons/*/bin/
156+
scons -j2 target=${{ matrix.target }} platform=${{ matrix.platform }} arch=${{ matrix.arch }} optimize=${{ matrix.optimize }} lto=full ${{ matrix.scons_args }}
157+
ls -l demo/addons/ropesim/bin/
145158
146159
- name: Prepare files for publish
147160
shell: sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ compile_commands.json
1111
*.exe
1212
*.dylib
1313
*.o
14+
*.wasm
1415

1516
# Godot-specific ignores
1617
.godot/

compile_debug.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/usr/bin/env bash
22

33
SCONS_CACHE="$PWD/.scons_cache_debug" scons compiledb=yes optimize=debug use_llvm=yes "$@"
4+
5+
# platform=web threads=no

demo/addons/ropesim/libropesim.gdextension

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ android.debug.x86_64 = "res://addons/ropesim/bin/libropesim.android.template_deb
1515
android.release.x86_64 = "res://addons/ropesim/bin/libropesim.android.template_release.x86_64.so"
1616
android.debug.arm64 = "res://addons/ropesim/bin/libropesim.android.template_debug.arm64.so"
1717
android.release.arm64 = "res://addons/ropesim/bin/libropesim.android.template_release.arm64.so"
18+
web.debug.wasm32 = "res://addons/ropesim/bin/libropesim.web.template_debug.wasm32.wasm"
19+
web.release.wasm32 = "res://addons/ropesim/bin/libropesim.web.template_release.wasm32.wasm"
20+
web.debug.wasm32.nothreads = "res://addons/ropesim/bin/libropesim.web.template_debug.wasm32.nothreads.wasm"
21+
web.release.wasm32.nothreads = "res://addons/ropesim/bin/libropesim.web.template_release.wasm32.nothreads.wasm"

godot-cpp

Submodule godot-cpp updated 138 files

0 commit comments

Comments
 (0)