Skip to content

Commit f1a5336

Browse files
committed
Move version into global variable
1 parent 4513656 commit f1a5336

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Tools/wasm/emscripten/__main__.py

Lines changed: 14 additions & 12 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_FILE = EMSCRIPTEN_DIR / "emscripten_version.txt"
25+
EMSCRIPTEN_VERSION = "4.0.12"
2626

2727
CROSS_BUILD_DIR = CHECKOUT / "cross-build"
2828
NATIVE_BUILD_DIR = CROSS_BUILD_DIR / "build"
@@ -37,29 +37,21 @@
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-
4640
@functools.cache
4741
def get_emsdk_activate_path(emsdk_cache):
48-
required_version = get_required_emscripten_version()
49-
return Path(emsdk_cache) / required_version / "emsdk_env.sh"
42+
return Path(emsdk_cache) / EMSCRIPTEN_VERSION / "emsdk_env.sh"
5043

5144

5245
def validate_emsdk_version(emsdk_cache):
5346
"""Validate that the emsdk cache contains the required emscripten version."""
54-
required_version = get_required_emscripten_version()
5547
emsdk_env = get_emsdk_activate_path(emsdk_cache)
5648
if not emsdk_env.is_file():
5749
print(
58-
f"Required emscripten version {required_version} not found in {emsdk_cache}",
50+
f"Required emscripten version {EMSCRIPTEN_VERSION} not found in {emsdk_cache}",
5951
file=sys.stderr,
6052
)
6153
sys.exit(1)
62-
print(f"✅ Emscripten version {required_version} found in {emsdk_cache}")
54+
print(f"✅ Emscripten version {EMSCRIPTEN_VERSION} found in {emsdk_cache}")
6355

6456

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

430422

423+
def print_emscripten_version(context):
424+
"""Print the required emscripten version."""
425+
print(EMSCRIPTEN_VERSION)
426+
427+
431428
def main():
432429
default_host_runner = "node"
433430

@@ -458,6 +455,9 @@ def main():
458455
clean = subcommands.add_parser(
459456
"clean", help="Delete files and directories created by this script"
460457
)
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,6 +467,7 @@ def main():
467467
configure_host,
468468
make_host,
469469
clean,
470+
emscripten_version_cmd,
470471
):
471472
subcommand.add_argument(
472473
"--quiet",
@@ -520,6 +521,7 @@ def main():
520521
"make-host": make_emscripten_python,
521522
"build": build_all,
522523
"clean": clean_contents,
524+
"emscripten-version": print_emscripten_version,
523525
}
524526

525527
if not context.subcommand:

0 commit comments

Comments
 (0)