| #!/usr/bin/env python3 |
| |
| # Copyright 2025 Google LLC |
| # |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import argparse |
| import os |
| import subprocess |
| import sys |
| import sysconfig |
| import textwrap |
| |
| EMSDK_ROOT = os.path.join('third_party', 'emsdk') |
| |
| EMSDK_PATH = os.path.join(EMSDK_ROOT, 'emsdk.py') |
| EMSDK_CONFIG_PATH = os.path.join(EMSDK_ROOT, '.emscripten') |
| |
| EMSDK_VERSION = '4.0.8' |
| |
| def main(args): |
| parser = argparse.ArgumentParser() |
| parser.add_argument('--get-emsdk-version', help='Print emsdk version and exit.', action='store_true') |
| options = parser.parse_args() |
| |
| if options.get_emsdk_version: |
| print(EMSDK_VERSION) |
| return 0 |
| |
| # Install and activate the default dependencies for emsdk. |
| try: |
| subprocess.check_call([sys.executable, EMSDK_PATH, 'install', EMSDK_VERSION]) |
| except subprocess.CalledProcessError: |
| print ('Failed to install emsdk') |
| return 1 |
| try: |
| subprocess.check_call([sys.executable, EMSDK_PATH, 'activate', EMSDK_VERSION]) |
| except subprocess.CalledProcessError: |
| print ('Failed to activate emsdk') |
| return 1 |
| |
| # If we ever need to override the Python, Node, and LLVM binaries used by Emscripten, do that |
| # here. See https://dawn-review.googlesource.com/c/dawn/+/238814/4..5 which removed support. |
| |
| if __name__ == '__main__': |
| sys.exit(main(sys.argv)) |