Debian Codegraph @

bin/activate-emsdk

raw
1 #!/usr/bin/env python3
2
3 # Copyright 2022 Google LLC
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8 import os
9 import subprocess
10 import sys
11 import sysconfig
12
13 EMSDK_ROOT = os.path.join('third_party', 'externals', 'emsdk')
14
15 EMSDK_PATH = os.path.join(EMSDK_ROOT, 'emsdk.py')
16
17 # This should match what's in //MODULE.bazel
18 EMSDK_VERSION = '4.0.7'
19
20 def main():
21 if sysconfig.get_platform() in ['linux-aarch64', 'linux-arm64']:
22 # This platform cannot install emsdk at the provided version. See
23 # https://github.com/emscripten-core/emsdk/blob/main/emscripten-releases-tags.json#L5
24 # for the latest version
25 return
26 try:
27 subprocess.check_call([sys.executable, EMSDK_PATH, 'install', "--permanent", EMSDK_VERSION])
28 except subprocess.CalledProcessError:
29 print ('Failed to install emsdk')
30 return 1
31 try:
32 subprocess.check_call([sys.executable, EMSDK_PATH, 'activate', "--permanent", EMSDK_VERSION])
33 except subprocess.CalledProcessError:
34 print ('Failed to activate emsdk')
35 return 1
36
37
38 if __name__ == '__main__':
39 sys.exit(main())