Path: blob/main/system/lib/update_libunwind.py
4150 views
#!/usr/bin/env python31# Copyright 2023 The Emscripten Authors. All rights reserved.2# Emscripten is available under two separate licenses, the MIT license and the3# University of Illinois/NCSA Open Source License. Both these licenses can be4# found in the LICENSE file.56import os7import sys8import shutil910script_dir = os.path.abspath(os.path.dirname(__file__))11emscripten_root = os.path.dirname(os.path.dirname(script_dir))12default_llvm_dir = os.path.join(os.path.dirname(emscripten_root), 'llvm-project')13local_root = os.path.join(script_dir, 'libunwind')14local_src = os.path.join(local_root, 'src')15local_inc = os.path.join(local_root, 'include')1617excludes = ('CMakeLists.txt',)18preserve_files = ()192021def clean_dir(dirname):22for f in os.listdir(dirname):23if f in preserve_files:24continue25full = os.path.join(dirname, f)26if os.path.isdir(full):27shutil.rmtree(full)28else:29os.remove(full)303132def copy_tree(upstream_dir, local_dir):33for f in os.listdir(upstream_dir):34full = os.path.join(upstream_dir, f)35if os.path.isdir(full):36shutil.copytree(full, os.path.join(local_dir, f))37elif f not in excludes:38shutil.copy2(full, os.path.join(local_dir, f))394041def main():42if len(sys.argv) > 1:43llvm_dir = os.path.join(os.path.abspath(sys.argv[1]))44else:45llvm_dir = default_llvm_dir46upstream_root = os.path.join(llvm_dir, 'libunwind')47upstream_src = os.path.join(upstream_root, 'src')48upstream_inc = os.path.join(upstream_root, 'include')49assert os.path.exists(upstream_inc)50assert os.path.exists(upstream_src)5152# Remove old version53clean_dir(local_src)54clean_dir(local_inc)5556copy_tree(upstream_src, local_src)57copy_tree(upstream_inc, local_inc)58shutil.copy2(os.path.join(upstream_root, 'LICENSE.TXT'), local_root)596061if __name__ == '__main__':62main()636465