Skip to content

Commit cafb15b

Browse files
committed
refactor: migrate build and runtime assets to project-local dist
Restructure build and release workflows so SPX artifacts are produced and consumed from `dist/` instead of `$GOPATH/bin`. This makes local builds and packaged goenv releases use the same layout. Build and packaging: - add `scripts/build.sh`, `scripts/setup-engines.sh`, `scripts/setup-web-template.sh`, and `scripts/verify-goenv.sh` - update `Makefile` to use `build`, `build-web`, `build-native`, `setup`, `setup-engines`, and `setup-web` - make `run-web` and `run-web-worker` fail fast when `build-web` fails Runtime and resource loading: - resolve `ShareDir` and `LibDir` from executable-relative paths - load engines from `dist/share/engines` and native libs from `dist/lib` - remove `spxrun` runtime auto-download and require pre-provisioned engines - track runtime versions with `pck_version` in `cmd/gox/template` and `cmd/spxrun/runner`, and `pck_release_tag` in `cmd/gox/template` Web export cleanup: - remove brotli-specific `.br` handling and `-build=fast` leftovers - remove `isWasmCompressed` leftovers and keep uncompressed wasm flow - improve error propagation in web export and worker merge paths CI and release: - switch cache namespace from `spx-godot-*` to `spx-assets-*` - make deps cache and setup arch-aware via `spx-arch` and `SPX_ARCH` - package goenv with `go/bin`, `go/share`, and `go/lib` from `dist` - re-enable release runtime verification with explicit success marker checks Documentation: - update `README.md` and `docs/zh/dev/engine/cmd_make.md` for the new `dist`-based workflow - refresh web-related docs under `docs/zh/dev/engine/` This is a breaking change. Existing installations that depend on `$GOPATH/bin` must migrate to the `dist/` layout. Signed-off-by: Aofei Sheng <aofei@aofeisheng.com>
1 parent 820818b commit cafb15b

42 files changed

Lines changed: 994 additions & 1354 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/deps/action.yml

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
description: 'Cache version for manual invalidation'
1414
required: false
1515
default: 'v2'
16+
spx-arch:
17+
description: 'Target runtime architecture for engine assets (x86_32|x86_64|arm64|arm32|auto)'
18+
required: false
19+
default: 'auto'
1620
runs:
1721
using: "composite"
1822
steps:
@@ -22,34 +26,53 @@ runs:
2226
go-version: ${{ inputs.go-version }}
2327
xgo-version: ${{ inputs.xgo-version }}
2428

25-
- name: Get GOPATH
26-
id: gopath
27-
run: echo "GOPATH=$(go env GOPATH)" >> $GITHUB_OUTPUT
28-
shell: bash
29-
30-
- name: Cache Godot engine files
31-
id: cache-godot
29+
- name: Cache spx assets
30+
id: cache-spx
3231
uses: actions/cache@v4
3332
with:
3433
path: |
35-
${{ steps.gopath.outputs.GOPATH }}/bin/gdspx*
36-
${{ steps.gopath.outputs.GOPATH }}/bin/gdspxrt*
37-
${{ steps.gopath.outputs.GOPATH }}/bin/runtime.gdextension
34+
dist
3835
~/.local/share/godot/export_templates
3936
~/Library/Application Support/Godot/export_templates
4037
~/AppData/Roaming/Godot/export_templates
41-
key: spx-godot-${{ inputs.cache-version }}-${{ runner.os }}-${{ hashFiles('cmd/gox/template/version', 'cmd/gox/**/*.go', 'cmd/gox/go.mod', 'cmd/gox/go.sum') }}
38+
key: spx-assets-${{ inputs.cache-version }}-${{ runner.os }}-${{ inputs.spx-arch }}-${{ hashFiles('cmd/gox/template/version', 'cmd/gox/template/pck_version', 'cmd/gox/template/pck_release_tag', 'cmd/gox/**/*.go', 'cmd/gox/go.mod', 'cmd/gox/go.sum', 'cmd/ispx/build.sh', 'cmd/ispx/**/*.go', 'cmd/ispx/web/**', 'cmd/ispxnative/build.sh', 'cmd/ispxnative/**/*.go', 'pkg/gdspx/tools/**/*.sh', 'scripts/build.sh', 'scripts/setup-engines.sh', 'scripts/setup-web-template.sh') }}
4239
restore-keys: |
43-
spx-godot-${{ inputs.cache-version }}-${{ runner.os }}-
40+
spx-assets-${{ inputs.cache-version }}-${{ runner.os }}-${{ inputs.spx-arch }}-
4441
4542
- name: Setup engine (cache miss)
46-
if: steps.cache-godot.outputs.cache-hit != 'true'
43+
if: steps.cache-spx.outputs.cache-hit != 'true'
4744
run: |
48-
make setup-web-full
45+
if [ "${{ inputs.spx-arch }}" != "auto" ]; then
46+
export SPX_ARCH="${{ inputs.spx-arch }}"
47+
echo "Using SPX_ARCH=$SPX_ARCH"
48+
fi
49+
if [ "${{ runner.os }}" = "Windows" ]; then
50+
bash ./scripts/build.sh --all
51+
bash ./scripts/setup-engines.sh
52+
bash ./scripts/setup-web-template.sh normal
53+
else
54+
make setup
55+
make setup-web MODE=normal
56+
fi
4957
shell: bash
5058

51-
- name: Setup web engine (cache hit)
52-
if: steps.cache-godot.outputs.cache-hit == 'true'
59+
- name: Build spx (cache hit)
60+
if: steps.cache-spx.outputs.cache-hit == 'true'
61+
run: |
62+
if [ "${{ runner.os }}" = "Windows" ]; then
63+
bash ./scripts/build.sh
64+
else
65+
make build
66+
fi
67+
shell: bash
68+
69+
- name: Export dist bin to PATH
5370
run: |
54-
make setup-web MODE=normal
71+
DIST_BIN="$(pwd)/dist/bin"
72+
if [ "${{ runner.os }}" = "Windows" ]; then
73+
echo "SPX_BIN=$DIST_BIN/spx.exe" >> $GITHUB_ENV
74+
else
75+
echo "SPX_BIN=$DIST_BIN/spx" >> $GITHUB_ENV
76+
fi
77+
echo "PATH=$DIST_BIN:$PATH" >> $GITHUB_ENV
5578
shell: bash

.github/actions/project-test/action.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@ description: Run the test Godot project.
33
runs:
44
using: "composite"
55
steps:
6+
- name: Setup cgo toolchain
7+
if: runner.os == 'Windows'
8+
shell: bash
9+
run: |
10+
GCC_BIN="$(command -v gcc || true)"
11+
if [ -z "$GCC_BIN" ]; then
12+
echo "Error: gcc not found in PATH"
13+
exit 1
14+
fi
15+
16+
if command -v cygpath >/dev/null 2>&1; then
17+
GCC_BIN="$(cygpath -w "$GCC_BIN")"
18+
fi
19+
20+
echo "CC=$GCC_BIN" >> "$GITHUB_ENV"
21+
echo "CGO_ENABLED=1" >> "$GITHUB_ENV"
22+
echo "Using CC=$GCC_BIN"
23+
624
- name: GenGo
725
shell: bash
8-
run: xgo go ./...
26+
run: CGO_ENABLED=1 xgo go ./...
927

1028
- name: Run test demo
1129
shell: bash
12-
run: spx run -path="test/CI" -headless=true 2>&1 | tee cilog.txt
30+
run: ${SPX_BIN:-spx} run -path="test/CI" -headless=true 2>&1 | tee cilog.txt
1331

1432
- name: Check test result
1533
shell: bash
@@ -27,7 +45,7 @@ runs:
2745
- name: Run test demo in interpreted mode
2846
shell: bash
2947
run: |
30-
spx runi -path="test/CI" -headless=true 2>&1 | tee cilog_interpreted_mode.txt
48+
${SPX_BIN:-spx} runi -path="test/CI" -headless=true 2>&1 | tee cilog_interpreted_mode.txt
3149
3250
- name: Check test result in interpreted mode
3351
shell: bash

.github/actions/replace-version/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ runs:
4141
echo "----------------------------------------"
4242
echo ""
4343
echo "✅ Successfully updated $FILE with version $VERSION"
44-
echo "reinstall spx"
45-
make install
44+
echo "rebuild spx"
45+
make build

.github/actions/verify-release/action.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ runs:
4747
cd "$CURRENT_DIR"
4848
echo "✓ Package extracted"
4949
50+
echo ""
51+
echo "Verifying goenv structure..."
52+
bash scripts/verify-goenv.sh rlcheck "${{ inputs.platform }}"
53+
echo "✓ goenv structure verified"
54+
5055
# Verify extracted structure
5156
echo ""
5257
echo "📂 Extracted structure:"
@@ -88,10 +93,16 @@ runs:
8893
echo "Command: $SPX_BIN run --ixgogen --goenv=$CURRENT_DIR/rlcheck --path=$CURRENT_DIR/rlcheck/test/CI"
8994
echo ""
9095
91-
cd rlcheck
92-
# Skip the check since the real version hasn't been released yet.
93-
# "$CURRENT_DIR/$SPX_BIN" run --ixgogen --goenv="$CURRENT_DIR/rlcheck" --path="$CURRENT_DIR/rlcheck/test/CI"
94-
cd "$CURRENT_DIR"
96+
"$CURRENT_DIR/$SPX_BIN" run --ixgogen --goenv="$CURRENT_DIR/rlcheck" --path="$CURRENT_DIR/rlcheck/test/CI" -headless=true 2>&1 | tee "$CURRENT_DIR/rlcheck_test.log"
97+
98+
if grep -q "===>SpxCIRunSucc" "$CURRENT_DIR/rlcheck_test.log"; then
99+
echo "✓ Runtime verification marker found"
100+
else
101+
echo "❌ Error: runtime verification marker not found"
102+
cat "$CURRENT_DIR/rlcheck_test.log"
103+
exit 1
104+
fi
105+
rm -f "$CURRENT_DIR/rlcheck_test.log"
95106
96107
echo ""
97108
echo "=========================================="

.github/workflows/build_android.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ jobs:
8383
- name: Download Android engine templates
8484
run: |
8585
echo "Downloading Android engine templates..."
86-
make download-engine PLATFORM=android
86+
./pkg/gdspx/tools/build_engine.sh -p android -g
8787
echo "Listing downloaded templates:"
8888
ls -la ~/.local/share/godot/export_templates/
8989
9090
- name: Run test demo
9191
shell: bash
92-
run: cd tutorial/00-Hello && spx exportapk 2>&1 | tee build_apk.txt || true
92+
run: cd tutorial/00-Hello && ${SPX_BIN:-spx} exportapk 2>&1 | tee build_apk.txt || true
9393

9494
- name: Check build result
9595
shell: bash
@@ -130,4 +130,4 @@ jobs:
130130
with:
131131
name: android-build-log
132132
path: tutorial/00-Hello/build_apk.txt
133-
if-no-files-found: warn
133+
if-no-files-found: warn

.github/workflows/build_ios.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- name: Download iOS engine templates
6161
run: |
6262
echo "Downloading iOS engine templates..."
63-
make download-engine PLATFORM=ios
63+
./pkg/gdspx/tools/build_engine.sh -p ios -g
6464
echo "Listing downloaded templates:"
6565
ls -la ~/Library/Application\ Support/Godot/export_templates/
6666
@@ -79,7 +79,7 @@ jobs:
7979
8080
- name: Export Xcode project
8181
shell: bash
82-
run: make install && cd tutorial/00-Hello && spx exportios 2>&1 | tee build_ios.txt || true
82+
run: make build && cd tutorial/00-Hello && ${SPX_BIN:-spx} exportios 2>&1 | tee build_ios.txt || true
8383

8484
- name: Copy MoltenVK framework to Xcode project
8585
shell: bash

.github/workflows/release_linux.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333

3434
- name: Setup go/xgo & engine
3535
uses: ./.github/actions/deps
36+
with:
37+
spx-arch: ${{ matrix.arch == '386' && 'x86_32' || matrix.arch == 'amd64' && 'x86_64' || matrix.arch == 'arm64' && 'arm64' || 'auto' }}
3638

3739
- name: Download and extract Go toolchain
3840
run: |
@@ -48,18 +50,16 @@ jobs:
4850
# Set up mod cache directory (no build cache needed)
4951
mkdir -p goenv/.cache/mod
5052
51-
# IMPORTANT: Copy binaries BEFORE running spx to collect dependencies
52-
# Without these, spx run will fail and won't download dependencies
53+
# Prepare goenv workspace directories
5354
mkdir -p goenv/go/bin
54-
cp $HOME/go/bin/gdspxrt* goenv/go/bin/ || true
55-
cp $HOME/go/bin/runtime.gdextension goenv/go/bin/ || true
56-
cp $HOME/go/bin/spx goenv/go/bin/
55+
mkdir -p goenv/go/share
56+
mkdir -p goenv/go/lib
5757
5858
# Set environment to use our mod cache location
5959
export GOMODCACHE=$(pwd)/goenv/.cache/mod
6060
6161
# Add current spx source to mod cache so users can use offline
62-
SPX_VERSION="v2.0.0-$(git rev-parse --short HEAD)"
62+
SPX_VERSION="v${{ inputs.version }}"
6363
DEST="$GOMODCACHE/github.com/goplus/spx/v2@$SPX_VERSION"
6464
6565
echo "Installing spx source to mod cache: $SPX_VERSION"
@@ -71,7 +71,7 @@ jobs:
7171
7272
# Run test/CI demo to collect other dependencies
7373
cd test/CI
74-
$HOME/go/bin/spx run --goenv=../../goenv --path=. --headless || true
74+
./../../dist/bin/spx run --goenv=../../goenv --path=. --headless || true
7575
cd ../..
7676
7777
echo "Module cache collection completed"
@@ -87,7 +87,16 @@ jobs:
8787
run: |
8888
# After replace-version rebuilds spx with the new version,
8989
# update the binary in goenv to match
90-
cp $HOME/go/bin/spx goenv/go/bin/spx
90+
cp dist/bin/spx goenv/go/bin/spx
91+
cp dist/bin/spxrun goenv/go/bin/spxrun
92+
93+
- name: Copy dist to goenv structure
94+
run: |
95+
mkdir -p goenv/go/share
96+
mkdir -p goenv/go/lib
97+
98+
cp -r dist/share/* goenv/go/share/
99+
cp -r dist/lib/* goenv/go/lib/
91100
92101
- name: Package goenv
93102
run: |

.github/workflows/release_macos.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828

2929
- name: Setup go/xgo & engine
3030
uses: ./.github/actions/deps
31+
with:
32+
spx-arch: ${{ matrix.arch == 'amd64' && 'x86_64' || 'arm64' }}
3133

3234
- name: Download and extract Go toolchain
3335
run: |
@@ -43,18 +45,16 @@ jobs:
4345
# Set up mod cache directory (no build cache needed)
4446
mkdir -p goenv/.cache/mod
4547
46-
# IMPORTANT: Copy binaries BEFORE running spx to collect dependencies
47-
# Without these, spx run will fail and won't download dependencies
48+
# Prepare goenv workspace directories
4849
mkdir -p goenv/go/bin
49-
cp $HOME/go/bin/gdspxrt* goenv/go/bin/ || true
50-
cp $HOME/go/bin/runtime.gdextension goenv/go/bin/ || true
51-
cp $HOME/go/bin/spx goenv/go/bin/
50+
mkdir -p goenv/go/share
51+
mkdir -p goenv/go/lib
5252
5353
# Set environment to use our mod cache location
5454
export GOMODCACHE=$(pwd)/goenv/.cache/mod
5555
5656
# Add current spx source to mod cache so users can use offline
57-
SPX_VERSION="v2.0.0-$(git rev-parse --short HEAD)"
57+
SPX_VERSION="v${{ inputs.version }}"
5858
DEST="$GOMODCACHE/github.com/goplus/spx/v2@$SPX_VERSION"
5959
6060
echo "Installing spx source to mod cache: $SPX_VERSION"
@@ -66,7 +66,7 @@ jobs:
6666
6767
# Run test/CI demo to collect other dependencies
6868
cd test/CI
69-
$HOME/go/bin/spx run --goenv=../../goenv --path=. --headless || true
69+
./../../dist/bin/spx run --goenv=../../goenv --path=. --headless || true
7070
cd ../..
7171
7272
echo "Module cache collection completed"
@@ -82,7 +82,16 @@ jobs:
8282
run: |
8383
# After replace-version rebuilds spx with the new version,
8484
# update the binary in goenv to match
85-
cp $HOME/go/bin/spx goenv/go/bin/spx
85+
cp dist/bin/spx goenv/go/bin/spx
86+
cp dist/bin/spxrun goenv/go/bin/spxrun
87+
88+
- name: Copy dist to goenv structure
89+
run: |
90+
mkdir -p goenv/go/share
91+
mkdir -p goenv/go/lib
92+
93+
cp -r dist/share/* goenv/go/share/
94+
cp -r dist/lib/* goenv/go/lib/
8695
8796
- name: Package goenv
8897
run: |

.github/workflows/release_web.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ jobs:
2020
matrix:
2121
include:
2222
- mode: normal
23-
zip_file: spx_web.zip
23+
zip_file: spx-web.zip
2424
artifact_name: web-release
2525
display_name: Web Release
2626
- mode: worker
27-
zip_file: spx_web_worker.zip
27+
zip_file: spx-web-worker.zip
2828
artifact_name: web-worker-release
2929
display_name: Web Worker Release
3030
- mode: minigame
31-
zip_file: spx_web_minigame.zip
31+
zip_file: spx-web-minigame.zip
3232
artifact_name: web-minigame-release
3333
display_name: Web Minigame Release
3434
- mode: miniprogram
35-
zip_file: spx_web_miniprogram.zip
35+
zip_file: spx-web-miniprogram.zip
3636
artifact_name: web-miniprogram-release
3737
display_name: Web Miniprogram Release
3838
steps:
@@ -47,12 +47,8 @@ jobs:
4747

4848
- name: Build release pack
4949
run: |
50-
if [ "${{ matrix.mode }}" != "normal" ]; then
51-
make setup-web MODE=${{ matrix.mode }}
52-
make export-web MODE=${{ matrix.mode }}
53-
else
54-
make export-web
55-
fi
50+
make setup-web MODE=${{ matrix.mode }}
51+
make export-web MODE=${{ matrix.mode }}
5652
if [ ! -f "${{ matrix.zip_file }}" ]; then
5753
echo "${{ matrix.zip_file }} not found"
5854
exit 1
@@ -72,4 +68,4 @@ jobs:
7268
files: ${{ matrix.zip_file }}
7369
tag_name: ${{ github.event.release.tag_name }}
7470
env:
75-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)