Skip to content

Commit dbcfac4

Browse files
committed
Add musl update script. NFC.
I'm in the process of updateing musl using a git mirror that holds both upstream musl and our local emscripten changes. This scripte can be used to copy new versions into place.
1 parent 72d6ae3 commit dbcfac4

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

system/lib/update_musl.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
"""Simple script for updating musl from external git repo.
8+
9+
The upstream sources, along with our local changes, live at:
10+
11+
https://github.com/emscripten-core/musl
12+
13+
To update musl first make sure all changes from the emscripten repo
14+
are present in the `emscripten` branch or the above repo. Then run
15+
`git merge v<musl_version>` to pull in the latest musl changes from
16+
a given musl version. Once any merge conflict are resolved those
17+
change can then be copied back into emscripten using this script.
18+
"""
19+
20+
import os
21+
import sys
22+
import shutil
23+
import subprocess
24+
25+
script_dir = os.path.abspath(os.path.dirname(__file__))
26+
local_src = os.path.join(script_dir, 'libc', 'musl')
27+
exclude_dirs = (
28+
# Top level directories we don't include
29+
'tools', 'obj', 'lib', 'crt', 'musl', 'compat',
30+
# Parts of src we don't build
31+
'malloc',
32+
# Arch-specific code we don't use
33+
'arm', 'x32', 'sh', 'i386', 'x86_64', 'aarch64', 'riscv64',
34+
's390x', 'mips', 'mips64', 'mipsn32', 'powerpc', 'powerpc64',
35+
'm68k', 'microblaze', 'or1k', 'generic')
36+
37+
38+
musl_dir = os.path.abspath(sys.argv[1])
39+
40+
41+
def should_ignore(name):
42+
return name in exclude_dirs or name[0] == '.'
43+
44+
45+
def ignore(dirname, contents):
46+
return [c for c in contents if should_ignore(c)]
47+
48+
49+
def main():
50+
assert os.path.exists(musl_dir)
51+
52+
# Remove old version
53+
shutil.rmtree(local_src)
54+
55+
# Copy new version into place
56+
shutil.copytree(musl_dir, local_src, ignore=ignore)
57+
58+
59+
if __name__ == '__main__':
60+
main()

0 commit comments

Comments
 (0)