Skip to content

Commit e2a1aff

Browse files
committed
Revert "Move version into global variable"
This reverts commit f1a5336.
1 parent f1a5336 commit e2a1aff

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Tools/wasm/emscripten/__main__.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
EMSCRIPTEN_DIR = Path(__file__).parent
2424
CHECKOUT = EMSCRIPTEN_DIR.parent.parent.parent
25-
EMSCRIPTEN_VERSION = "4.0.12"
25+
EMSCRIPTEN_VERSION_FILE = EMSCRIPTEN_DIR / "emscripten_version.txt"
2626

2727
CROSS_BUILD_DIR = CHECKOUT / "cross-build"
2828
NATIVE_BUILD_DIR = CROSS_BUILD_DIR / "build"
@@ -37,21 +37,29 @@
3737
LOCAL_SETUP_MARKER = b"# Generated by Tools/wasm/emscripten.py\n"
3838

3939

40+
@functools.cache
41+
def get_required_emscripten_version():
42+
"""Read the required emscripten version from emscripten_version.txt."""
43+
return EMSCRIPTEN_VERSION_FILE.read_text().strip()
44+
45+
4046
@functools.cache
4147
def get_emsdk_activate_path(emsdk_cache):
42-
return Path(emsdk_cache) / EMSCRIPTEN_VERSION / "emsdk_env.sh"
48+
required_version = get_required_emscripten_version()
49+
return Path(emsdk_cache) / required_version / "emsdk_env.sh"
4350

4451

4552
def validate_emsdk_version(emsdk_cache):
4653
"""Validate that the emsdk cache contains the required emscripten version."""
54+
required_version = get_required_emscripten_version()
4755
emsdk_env = get_emsdk_activate_path(emsdk_cache)
4856
if not emsdk_env.is_file():
4957
print(
50-
f"Required emscripten version {EMSCRIPTEN_VERSION} not found in {emsdk_cache}",
58+
f"Required emscripten version {required_version} not found in {emsdk_cache}",
5159
file=sys.stderr,
5260
)
5361
sys.exit(1)
54-
print(f"✅ Emscripten version {EMSCRIPTEN_VERSION} found in {emsdk_cache}")
62+
print(f"✅ Emscripten version {required_version} found in {emsdk_cache}")
5563

5664

5765
def updated_env(updates, emsdk_cache):
@@ -420,11 +428,6 @@ def clean_contents(context):
420428
print(f"🧹 Deleting generated {LOCAL_SETUP} ...")
421429

422430

423-
def print_emscripten_version(context):
424-
"""Print the required emscripten version."""
425-
print(EMSCRIPTEN_VERSION)
426-
427-
428431
def main():
429432
default_host_runner = "node"
430433

@@ -455,9 +458,6 @@ def main():
455458
clean = subcommands.add_parser(
456459
"clean", help="Delete files and directories created by this script"
457460
)
458-
emscripten_version_cmd = subcommands.add_parser(
459-
"emscripten-version", help="Print the required emscripten version"
460-
)
461461
for subcommand in (
462462
build,
463463
configure_build,
@@ -467,7 +467,6 @@ def main():
467467
configure_host,
468468
make_host,
469469
clean,
470-
emscripten_version_cmd,
471470
):
472471
subcommand.add_argument(
473472
"--quiet",
@@ -521,7 +520,6 @@ def main():
521520
"make-host": make_emscripten_python,
522521
"build": build_all,
523522
"clean": clean_contents,
524-
"emscripten-version": print_emscripten_version,
525523
}
526524

527525
if not context.subcommand:

0 commit comments

Comments
 (0)