Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/push_llvm_changes.py
4150 views
1
#!/usr/bin/env python3
2
# Copyright 2021 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
# Copy local llvm library changes into the upstream llvm tree.
8
# This is the logical inverse of update_compiler_rt.py, update_libcxx.py
9
# and update_libcxxabi.py which copy changes form the upstream llvm
10
# into emscripten.
11
12
import glob
13
import os
14
import sys
15
import shutil
16
17
script_dir = os.path.abspath(os.path.dirname(__file__))
18
emscripten_root = os.path.dirname(os.path.dirname(script_dir))
19
default_llvm_dir = os.path.join(os.path.dirname(emscripten_root), 'llvm-project')
20
copy_dirs = [
21
('compiler-rt', 'compiler-rt'),
22
('libcxx', 'libcxx'),
23
('libcxxabi', 'libcxxabi'),
24
('libunwind', 'libunwind'),
25
('llvm-libc', 'libc'),
26
]
27
28
29
def main():
30
if len(sys.argv) > 1:
31
upstream_root = os.path.join(os.path.abspath(sys.argv[1]))
32
else:
33
upstream_root = default_llvm_dir
34
if not os.path.exists(upstream_root):
35
print(f'llvm tree not found: {upstream_root}')
36
return 1
37
38
for _, upstream_name in copy_dirs:
39
assert os.path.exists(os.path.join(upstream_root, upstream_name))
40
41
for local_name, upstream_name in copy_dirs:
42
local_dir = os.path.join(script_dir, local_name)
43
upstream_dir = os.path.join(upstream_root, upstream_name)
44
print(f'copying {local_dir} -> {upstream_dir}')
45
shutil.copytree(local_dir, upstream_dir, dirs_exist_ok=True)
46
47
48
if __name__ == '__main__':
49
main()
50
51