Skip to content

Commit 9bfae40

Browse files
committed
[Incomplete] Add web build
Also adds another workflow to build export templates with dlink enabled.
1 parent 20eaa00 commit 9bfae40

3 files changed

Lines changed: 141 additions & 19 deletions

File tree

.github/workflows/build.yml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,25 @@ 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 }}
24+
EM_VERSION: 4.0.9
25+
EM_CACHE_FOLDER: "emsdk-cache"
26+
2327
strategy:
2428
fail-fast: false
2529
matrix:
2630
target: [ template_debug, template_release ]
27-
identifier: [ windows, linux, macos, android, android_arm64 ]
31+
identifier: [ windows, linux, macos, android, android_arm64, web ]
2832

2933
include:
3034
# Defaults
3135
- runner: ubuntu-22.04
3236
- optimize: speed
3337
- arch: x86_64
38+
- scons_args:
3439

3540
# Debug build settings
3641
- target: template_debug
@@ -55,6 +60,11 @@ jobs:
5560
platform: android
5661
arch: arm64
5762

63+
- identifier: web
64+
platform: web
65+
arch: wasm32
66+
scons_args: threads=no
67+
5868
steps:
5969
- name: Check settings
6070
if: ${{ matrix.platform == '' || matrix.target == '' || matrix.runner == '' || matrix.optimize == '' || matrix.arch == ''}}
@@ -95,6 +105,20 @@ jobs:
95105
ndk-version: r23c
96106
link-to-sdk: true
97107

108+
- name: (Web) Set up Emscripten cache
109+
if: ${{ matrix.platform == 'web' }}
110+
uses: actions/cache@v4
111+
with:
112+
path: ${{env.EM_CACHE_FOLDER}}
113+
key: ${{env.EM_VERSION}}-${{ env.BUILD_ID }}
114+
115+
- name: (Web) Set up Emscripten
116+
if: ${{ matrix.platform == 'web' }}
117+
uses: mymindstorm/setup-emsdk@v14
118+
with:
119+
version: ${{env.EM_VERSION}}
120+
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
121+
98122
- name: Set up Python
99123
uses: actions/setup-python@v5
100124
with:
@@ -113,21 +137,6 @@ jobs:
113137
submodules: recursive
114138
ref: ${{ inputs.git-ref }}
115139

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-
131140
- name: Scons Cache
132141
id: scons-cache
133142
uses: actions/cache@v4
@@ -140,7 +149,7 @@ jobs:
140149
env:
141150
SCONS_CACHE: .scons-cache
142151
run: |
143-
scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' optimize=${{ matrix.optimize }} -j2
152+
scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' optimize=${{ matrix.optimize }} ${{ matrix.scons_args }} -j2
144153
ls -l demo/addons/*/bin/
145154
146155
- name: Prepare files for publish

.github/workflows/web-build.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Adapted from https://github.com/nathanfranke/gdextension/blob/main/.github/workflows/build.yml
2+
name: Web Export Template
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
git-ref:
7+
description: A commit, branch or tag to build.
8+
type: string
9+
required: true
10+
workflow_call:
11+
inputs:
12+
git-ref:
13+
description: A commit, branch or tag to build.
14+
type: string
15+
required: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-22.04
20+
name: Web ${{ matrix.target }} ${{ matrix.optimize }}
21+
22+
env:
23+
BUILD_ID: web-${{ matrix.target }}-${{ matrix.optimize }}-${{ matrix.threads }}
24+
EM_VERSION: 4.0.9
25+
EM_CACHE_FOLDER: "emsdk-cache"
26+
GODOT_REF: godot-4.4-stable
27+
SCONS_CACHE: .scons-cache
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
target: [ template_debug, template_release ]
33+
threads: [ yes, no ]
34+
35+
include:
36+
# Defaults
37+
- optimize: speed
38+
39+
# Debug build settings
40+
- target: template_debug
41+
optimize: speed_trace
42+
43+
steps:
44+
- name: Check settings
45+
if: ${{ matrix.platform == '' || matrix.target == '' || matrix.runner == '' || matrix.optimize == '' || matrix.arch == ''}}
46+
run: |
47+
echo "One of the matrix values is not set."
48+
exit 1
49+
50+
- name: (Web) Set up Emscripten cache
51+
if: ${{ matrix.platform == 'web' }}
52+
uses: actions/cache@v4
53+
with:
54+
path: ${{env.EM_CACHE_FOLDER}}
55+
key: ${{env.EM_VERSION}}-${{ env.BUILD_ID }}
56+
57+
- name: (Web) Set up Emscripten
58+
if: ${{ matrix.platform == 'web' }}
59+
uses: mymindstorm/setup-emsdk@v14
60+
with:
61+
version: ${{env.EM_VERSION}}
62+
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
63+
64+
- name: Set up Python
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: '3.10'
68+
69+
- name: Set up SCons
70+
shell: bash
71+
run: |
72+
python -c "import sys; print(sys.version)"
73+
python -m pip install scons==4.7.0
74+
scons --version
75+
76+
- name: Clone Godot
77+
uses: actions/checkout@v4
78+
with:
79+
repository: godotengine/godot
80+
ref: ${{ env.GODOT_REF }}
81+
82+
- name: Scons Cache
83+
id: scons-cache
84+
uses: actions/cache@v4
85+
with:
86+
path: ${{ env.SCONS_CACHE }}
87+
key: ${{ env.BUILD_ID }}
88+
89+
- name: Compile extension
90+
shell: sh
91+
run: |
92+
scons target='${{ matrix.target }}' platform=web optimize=${{ matrix.optimize }} -j2
93+
94+
- name: Upload artifact
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: godot-${{ env.BUILD_ID }}
98+
path: |
99+
${{ github.workspace }}/demo/
100+
merge:
101+
runs-on: ubuntu-latest
102+
needs: build
103+
steps:
104+
- name: Git describe
105+
id: ghd
106+
uses: proudust/gh-describe@v2
107+
- name: Merge Artifacts
108+
uses: actions/upload-artifact/merge@v4
109+
with:
110+
name: ${{ github.event.repository.name }}-${{ steps.ghd.outputs.describe }}
111+
pattern: godot-*

demo/addons/ropesim/libropesim.gdextension

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ 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"

0 commit comments

Comments
 (0)