comparison third_party/emsdk/scripts/update_node.py @ 179:8d17f6e6e290

[ThirdParty] Added emsdk bazel rules that can be supported by bazel 9.0.0
author MrJuneJune <me@mrjunejune.com>
date Thu, 22 Jan 2026 21:23:17 -0800
parents
children
comparison
equal deleted inserted replaced
178:94705b5986b3 179:8d17f6e6e290
1 #!/usr/bin/env python3
2 # Copyright 2020 The Emscripten Authors. All rights reserved.
3 # Emscripten is available under two separate licenses, the MIT license and the
4 # University of Illinois/NCSA Open Source License. Both these licenses can be
5 # found in the LICENSE file.
6
7 """Updates the node binaries that we cache store at
8 http://storage.google.com/webassembly.
9
10 For the windows version we also alter the directory layout to add the 'bin'
11 directory.
12 """
13
14 import os
15 import shutil
16 import subprocess
17 import sys
18 import urllib.request
19
20 from zip import unzip_cmd, zip_cmd
21
22 # When adjusting this version, visit
23 # https://github.com/nodejs/node/blob/v24.x/BUILDING.md#platform-list
24 # to verify minimum supported OS versions. Replace "v24.x" in the URL
25 # with the version field.
26 version = '24.7.0'
27 base = f'https://nodejs.org/dist/v{version}/'
28 upload_base = 'gs://webassembly/emscripten-releases-builds/deps/'
29
30 suffixes = [
31 '-win-x64.zip',
32 '-win-arm64.zip',
33 '-darwin-x64.tar.gz',
34 '-darwin-arm64.tar.gz',
35 '-linux-x64.tar.xz',
36 '-linux-arm64.tar.xz',
37 '-linux-s390x.tar.gz',
38 ]
39
40 for suffix in suffixes:
41 filename = 'node-v%s%s' % (version, suffix)
42 download_url = base + filename
43 print('Downloading: ' + download_url)
44 urllib.request.urlretrieve(download_url, filename)
45
46 if '-win-' in suffix:
47 subprocess.check_call(unzip_cmd() + [filename])
48 dirname = os.path.splitext(os.path.basename(filename))[0]
49 shutil.move(dirname, 'bin')
50 os.mkdir(dirname)
51 shutil.move('bin', dirname)
52 os.remove(filename)
53 subprocess.check_call(zip_cmd() + [filename, dirname])
54 shutil.rmtree(dirname)
55
56 if '--upload' in sys.argv:
57 upload_url = upload_base + filename
58 print('Uploading: ' + upload_url)
59 cmd = ['gsutil', 'cp', '-n', filename, upload_url]
60 print(' '.join(cmd))
61 subprocess.check_call(cmd)
62 os.remove(filename)