Skip to content

Commit 075d43b

Browse files
Update GH action
1 parent b4eebe2 commit 075d43b

4 files changed

Lines changed: 82 additions & 19 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ jobs:
4040
python -m pip install -r requirements-build.txt
4141
4242
- name: Compiler les sources francais
43-
run: |
44-
mkdir -p public/generated
45-
python -m multilingualprogramming compile src/automate_universel.ml > public/generated/automate_universel.py
46-
python -m multilingualprogramming build-wasm-bundle src/automate_packed_wasm.ml --out-dir public/generated/automate_packed
47-
cp public/generated/automate_packed/host_shim.js public/generated/automate_packed/host_shim.mjs
43+
run: python scripts/build_wasm_bundle.py
4844

4945
- name: Verifier les artefacts de compilation
5046
run: |

.github/workflows/monitor-multilingual.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ jobs:
7070
PY
7171
7272
- name: Compiler les sources francais
73-
run: |
74-
mkdir -p public/generated
75-
python -m multilingualprogramming compile src/automate_universel.ml > public/generated/automate_universel.py
76-
python -m multilingualprogramming build-wasm-bundle src/automate_packed_wasm.ml --out-dir public/generated/automate_packed
77-
cp public/generated/automate_packed/host_shim.js public/generated/automate_packed/host_shim.mjs
73+
run: python scripts/build_wasm_bundle.py
7874

7975
- name: Verifier la syntaxe JavaScript
8076
run: |

scripts/build-stage4.ps1

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
$ErrorActionPreference = "Stop"
22

3-
$generatedDir = "public\generated"
4-
New-Item -ItemType Directory -Force $generatedDir | Out-Null
5-
6-
$compiled = multilingual compile src\automate_universel.ml
7-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
8-
$compiled | Out-File -Encoding utf8 public\generated\automate_universel.py
9-
10-
multilingual build-wasm-bundle src\automate_packed_wasm.ml --out-dir public\generated\automate_packed
3+
python scripts\build_wasm_bundle.py
114
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
12-
Copy-Item -Force public\generated\automate_packed\host_shim.js public\generated\automate_packed\host_shim.mjs
135

146
Write-Host "Stage 4 generated artifacts refreshed."

scripts/build_wasm_bundle.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""Build Automaginarium's generated Multilingual artifacts."""
2+
3+
from __future__ import annotations
4+
5+
import argparse
6+
import shutil
7+
import subprocess
8+
import sys
9+
from pathlib import Path
10+
11+
from wasmtime import wat2wasm
12+
13+
14+
ROOT = Path(__file__).resolve().parents[1]
15+
GENERATED = ROOT / "public" / "generated"
16+
PACKED = GENERATED / "automate_packed"
17+
18+
19+
def run(command: list[str]) -> None:
20+
"""Run a build command from the repository root."""
21+
subprocess.run(command, cwd=ROOT, check=True)
22+
23+
24+
def build_french_core() -> None:
25+
"""Compile the rich French core to generated Python."""
26+
GENERATED.mkdir(parents=True, exist_ok=True)
27+
result = subprocess.run(
28+
[
29+
sys.executable,
30+
"-m",
31+
"multilingualprogramming",
32+
"compile",
33+
"src/automate_universel.ml",
34+
],
35+
cwd=ROOT,
36+
check=True,
37+
text=True,
38+
capture_output=True,
39+
)
40+
(GENERATED / "automate_universel.py").write_text(result.stdout, encoding="utf-8")
41+
42+
43+
def build_packed_wasm() -> None:
44+
"""Build the narrow browser ABI and write WASM from the generated WAT."""
45+
run(
46+
[
47+
sys.executable,
48+
"-m",
49+
"multilingualprogramming",
50+
"build-wasm-bundle",
51+
"src/automate_packed_wasm.ml",
52+
"--out-dir",
53+
str(PACKED),
54+
]
55+
)
56+
57+
wat_path = PACKED / "module.wat"
58+
wasm_path = PACKED / "module.wasm"
59+
if not wat_path.is_file():
60+
raise FileNotFoundError(f"generated WAT missing: {wat_path}")
61+
wasm_path.write_bytes(wat2wasm(wat_path.read_text(encoding="utf-8")))
62+
63+
shim_js = PACKED / "host_shim.js"
64+
shim_mjs = PACKED / "host_shim.mjs"
65+
if not shim_js.is_file():
66+
raise FileNotFoundError(f"generated host shim missing: {shim_js}")
67+
shutil.copyfile(shim_js, shim_mjs)
68+
69+
70+
def main() -> None:
71+
"""Build all generated artifacts used by CI and GitHub Pages."""
72+
parser = argparse.ArgumentParser()
73+
parser.parse_args()
74+
build_french_core()
75+
build_packed_wasm()
76+
77+
78+
if __name__ == "__main__":
79+
main()

0 commit comments

Comments
 (0)