-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
update_musl.py
executable file
·94 lines (75 loc) · 2.42 KB
/
update_musl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
# Copyright 2021 The Emscripten Authors. All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.
"""Simple script for updating musl from external git repo.
The upstream sources, along with our local changes, live at:
https://github.com/emscripten-core/musl
To update musl first make sure all changes from the emscripten repo
are present in the `emscripten` branch of the above repo. Then run
`git merge v<musl_version>` to pull in the latest musl changes from
a given musl version. Once any merge conflict are resolved those
change can then be copied back into emscripten using this script.
"""
import os
import sys
import shutil
script_dir = os.path.abspath(os.path.dirname(__file__))
local_src = os.path.join(script_dir, 'libc', 'musl')
emscripten_root = os.path.dirname(os.path.dirname(script_dir))
default_musl_dir = os.path.join(os.path.dirname(emscripten_root), 'musl')
exclude_dirs = (
# Top level directories we don't include
'tools', 'obj', 'lib', 'crt', 'musl', 'compat',
# Parts of src we don't build
'malloc',
# Arch-specific code we don't use
'arm', 'x32', 'sh', 'i386', 'x86_64', 'aarch64', 'riscv64',
's390x', 'mips', 'mips64', 'mipsn32', 'powerpc', 'powerpc64',
'm68k', 'microblaze', 'or1k')
exclude_files = (
'aio.h',
'sendfile.h',
'auxv.h',
'personality.h',
'klog.h',
'fanotify.h',
'vt.h',
'swap.h',
'reboot.h',
'quota.h',
'kd.h',
'io.h',
'fsuid.h',
'epoll.h',
'inotify.h',
'timerfd.h',
'timex.h',
'cachectl.h',
'soundcard.h',
'eventfd.h',
'signalfd.h',
'ptrace.h',
'prctl.h',
)
if len(sys.argv) > 1:
musl_dir = os.path.abspath(sys.argv[1])
else:
musl_dir = default_musl_dir
def should_ignore(name):
return name in exclude_dirs or name[0] == '.' or name in exclude_files
def ignore(dirname, contents):
return [c for c in contents if should_ignore(c)]
def main():
assert os.path.exists(musl_dir)
# Remove old version
shutil.rmtree(local_src)
# Copy new version into place
shutil.copytree(musl_dir, local_src, ignore=ignore)
# Create version.h
version = open(os.path.join(local_src, 'VERSION')).read().strip()
with open(os.path.join(local_src, 'src', 'internal', 'version.h'), 'w') as f:
f.write('#define VERSION "%s"\n' % version)
if __name__ == '__main__':
main()