-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
74 lines (70 loc) · 2.77 KB
/
reusable-emscripten.yml
File metadata and controls
74 lines (70 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Reusable Emscripten
on:
workflow_call:
env:
FORCE_COLOR: 1
jobs:
build-emscripten-reusable:
name: 'build and test'
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: "Read Emscripten config"
id: emscripten-config
shell: python
run: |
import hashlib
import json
import os
import tomllib
from pathlib import Path
config = tomllib.loads(Path("Platforms/emscripten/config.toml").read_text())
h = hashlib.sha256()
h.update(json.dumps(config["dependencies"], sort_keys=True).encode())
h.update(Path("Platforms/emscripten/make_libffi.sh").read_bytes())
h.update(b'1') # Update to explicitly bust cache
emsdk_cache = Path(os.environ["RUNNER_TEMP"]) / "emsdk-cache"
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"emscripten-version={config['emscripten-version']}\n")
f.write(f"node-version={config['node-version']}\n")
f.write(f"deps-hash={h.hexdigest()}\n")
with open(os.environ["GITHUB_ENV"], "a") as f:
f.write(f"EMSDK_CACHE={emsdk_cache}\n")
- name: "Install Node.js"
uses: actions/setup-node@v6
with:
node-version: ${{ steps.emscripten-config.outputs.node-version }}
- name: "Cache Emscripten SDK"
id: emsdk-cache
uses: actions/cache@v5
with:
path: ${{ env.EMSDK_CACHE }}
key: emsdk-${{ steps.emscripten-config.outputs.emscripten-version }}-${{ steps.emscripten-config.outputs.deps-hash }}
restore-keys: emsdk-${{ steps.emscripten-config.outputs.emscripten-version }}
- name: "Install Python"
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: "Runner image version"
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: "Install Emscripten"
run: python3 Platforms/emscripten install-emscripten
- name: "Configure build Python"
run: python3 Platforms/emscripten configure-build-python -- --config-cache --with-pydebug
- name: "Make build Python"
run: python3 Platforms/emscripten make-build-python
- name: "Make dependencies"
run: >-
python3 Platforms/emscripten make-dependencies
${{ steps.emsdk-cache.outputs.cache-hit == 'true' && '--check-up-to-date' || '' }}
- name: "Configure host Python"
run: python3 Platforms/emscripten configure-host --host-runner node -- --config-cache
- name: "Make host Python"
run: python3 Platforms/emscripten make-host
- name: "Display build info"
run: python3 Platforms/emscripten run --pythoninfo
- name: "Test"
run: python3 Platforms/emscripten run --test