Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Move version into global variable"
This reverts commit f1a5336.
  • Loading branch information
hoodmane committed Mar 4, 2026
commit e2a1afff9be741398641ffc5ad9bfc4ec7ecbe07
26 changes: 12 additions & 14 deletions Tools/wasm/emscripten/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

EMSCRIPTEN_DIR = Path(__file__).parent
CHECKOUT = EMSCRIPTEN_DIR.parent.parent.parent
EMSCRIPTEN_VERSION = "4.0.12"
EMSCRIPTEN_VERSION_FILE = EMSCRIPTEN_DIR / "emscripten_version.txt"

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


@functools.cache
def get_required_emscripten_version():
"""Read the required emscripten version from emscripten_version.txt."""
return EMSCRIPTEN_VERSION_FILE.read_text().strip()


@functools.cache
def get_emsdk_activate_path(emsdk_cache):
return Path(emsdk_cache) / EMSCRIPTEN_VERSION / "emsdk_env.sh"
required_version = get_required_emscripten_version()
return Path(emsdk_cache) / required_version / "emsdk_env.sh"


def validate_emsdk_version(emsdk_cache):
"""Validate that the emsdk cache contains the required emscripten version."""
required_version = get_required_emscripten_version()
emsdk_env = get_emsdk_activate_path(emsdk_cache)
if not emsdk_env.is_file():
print(
f"Required emscripten version {EMSCRIPTEN_VERSION} not found in {emsdk_cache}",
f"Required emscripten version {required_version} not found in {emsdk_cache}",
file=sys.stderr,
)
sys.exit(1)
print(f"✅ Emscripten version {EMSCRIPTEN_VERSION} found in {emsdk_cache}")
print(f"✅ Emscripten version {required_version} found in {emsdk_cache}")


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


def print_emscripten_version(context):
"""Print the required emscripten version."""
print(EMSCRIPTEN_VERSION)


def main():
default_host_runner = "node"

Expand Down Expand Up @@ -455,9 +458,6 @@ def main():
clean = subcommands.add_parser(
"clean", help="Delete files and directories created by this script"
)
emscripten_version_cmd = subcommands.add_parser(
"emscripten-version", help="Print the required emscripten version"
)
for subcommand in (
build,
configure_build,
Expand All @@ -467,7 +467,6 @@ def main():
configure_host,
make_host,
clean,
emscripten_version_cmd,
):
subcommand.add_argument(
"--quiet",
Expand Down Expand Up @@ -521,7 +520,6 @@ def main():
"make-host": make_emscripten_python,
"build": build_all,
"clean": clean_contents,
"emscripten-version": print_emscripten_version,
}

if not context.subcommand:
Expand Down
Loading