comparison third_party/emsdk/scripts/get_emscripten_revision_info.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
3 import json
4 import os
5 import subprocess
6 import sys
7
8 EMSCRIPTEN_RELEASES_GIT = 'https://chromium.googlesource.com/emscripten-releases'
9 TAGFILE = 'emscripten-releases-tags.json'
10
11
12 def get_latest_hash(tagfile):
13 with open(tagfile) as f:
14 versions = json.load(f)
15 latest = versions['aliases']['latest']
16 return versions['releases'][latest]
17
18
19 def get_latest_emscripten(tagfile):
20 latest = get_latest_hash(tagfile)
21 if not os.path.isdir('emscripten-releases'):
22 subprocess.run(['git', 'clone', EMSCRIPTEN_RELEASES_GIT, '--depth',
23 '100'], check=True)
24 # This will fail if the 'latest' revision is not within the most recent
25 # 100 commits; but that shouldn't happen because this script is intended
26 # to be run right after a release is added.
27 info = subprocess.run(['emscripten-releases/src/release-info.py',
28 'emscripten-releases', latest],
29 stdout=subprocess.PIPE, check=True, text=True).stdout
30 for line in info.split('\n'):
31 tokens = line.split()
32 if len(tokens) and tokens[0] == 'emscripten':
33 return tokens[2]
34
35
36 if __name__ == '__main__':
37 emscripten_hash = get_latest_emscripten(TAGFILE)
38 print('Emscripten revision ' + emscripten_hash)
39 if 'GITHUB_ENV' in os.environ:
40 with open(os.environ['GITHUB_ENV'], 'a') as f:
41 f.write(f'EMSCRIPTEN_HASH={emscripten_hash}')
42 sys.exit(0)
43 print('Not a GitHub Action')
44 sys.exit(1)