| #!/usr/bin/env python3 | |
| # Copyright 2022 Google LLC | |
| # | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| import os | |
| import subprocess | |
| import sys | |
| import sysconfig | |
| THIS_DIR = os.path.dirname(__file__) | |
| SRC_ROOT_DIR = os.path.abspath(os.path.join(THIS_DIR, os.path.pardir)) | |
| EMSDK_ROOT = os.path.join(SRC_ROOT_DIR, 'third_party', 'externals', 'emsdk') | |
| EMSDK_PATH = os.path.join(EMSDK_ROOT, 'emsdk.py') | |
| # This should match what's in //MODULE.bazel | |
| EMSDK_VERSION = '4.0.7' | |
| def main(): | |
| if sysconfig.get_platform() in ['linux-aarch64', 'linux-arm64']: | |
| # This platform cannot install emsdk at the provided version. See | |
| # https://github.com/emscripten-core/emsdk/blob/main/emscripten-releases-tags.json#L5 | |
| # for the latest version | |
| return | |
| try: | |
| subprocess.check_call([sys.executable, EMSDK_PATH, 'install', "--permanent", EMSDK_VERSION]) | |
| except subprocess.CalledProcessError: | |
| print ('Failed to install emsdk') | |
| return 1 | |
| try: | |
| subprocess.check_call([sys.executable, EMSDK_PATH, 'activate', "--permanent", EMSDK_VERSION]) | |
| except subprocess.CalledProcessError: | |
| print ('Failed to activate emsdk') | |
| return 1 | |
| if __name__ == '__main__': | |
| sys.exit(main()) |