mirror of
https://github.com/python/cpython.git
synced 2026-10-28 10:25:05 +08:00
Adds the ability to build Emscripten statically, so that it can be linked in as an embedded library. Includes a test of the embedding case. --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
84 lines
3.3 KiB
YAML
84 lines
3.3 KiB
YAML
name: Reusable Emscripten
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
FORCE_COLOR: 1
|
|
|
|
jobs:
|
|
build-emscripten-reusable:
|
|
name: 'build and test'
|
|
runs-on: ubuntu-26.04
|
|
timeout-minutes: 40
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
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@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
with:
|
|
node-version: ${{ steps.emscripten-config.outputs.node-version }}
|
|
- name: "Cache Emscripten SDK"
|
|
id: emsdk-cache
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
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@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
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: "Display build info of the build Python"
|
|
run: python3 Platforms/emscripten pythoninfo-build
|
|
- name: "Make dependencies"
|
|
run: >-
|
|
python3 Platforms/emscripten make-dependencies
|
|
${{ steps.emsdk-cache.outputs.cache-hit == 'true' && '--check-up-to-date' || '' }}
|
|
- name: "Configure host/Emscripten Python"
|
|
run: python3 Platforms/emscripten configure-host --host-runner node -- --config-cache
|
|
- name: "Make host/Emscripten Python"
|
|
run: python3 Platforms/emscripten make-host
|
|
- name: "Display build info of the host/Emscripten Python"
|
|
run: python3 Platforms/emscripten pythoninfo-host
|
|
- name: "Test"
|
|
run: python3 Platforms/emscripten run --test
|
|
- name: "Test Repl"
|
|
run: Platforms/emscripten/browser_test/run_test.sh
|
|
- name: "Test embedding"
|
|
run: Platforms/emscripten/web_embed_test/run_test.sh
|