xref: /aosp_15_r20/external/skia/bin/activate-emsdk (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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
8import os
9import subprocess
10import sys
11import sysconfig
12
13EMSDK_ROOT = os.path.join('third_party', 'externals', 'emsdk')
14
15EMSDK_PATH = os.path.join(EMSDK_ROOT, 'emsdk.py')
16
17EMSDK_VERSION = '3.1.44'
18
19def main():
20    if sysconfig.get_platform() in ['linux-aarch64', 'linux-arm64']:
21        # This platform cannot install emsdk at the provided version. See
22        # https://github.com/emscripten-core/emsdk/blob/main/emscripten-releases-tags.json#L5
23        # for the latest version
24        return
25    try:
26        subprocess.check_call([sys.executable, EMSDK_PATH, 'install', "--permanent", EMSDK_VERSION])
27    except subprocess.CalledProcessError:
28        print ('Failed to install emsdk')
29        return 1
30    try:
31        subprocess.check_call([sys.executable, EMSDK_PATH, 'activate', "--permanent", EMSDK_VERSION])
32    except subprocess.CalledProcessError:
33        print ('Failed to activate emsdk')
34        return 1
35
36
37if __name__ == '__main__':
38  sys.exit(main())
39