blob: 09852629c753f4777bb6f7a48203e92ae3f610b2 (
plain)
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
|
#!/usr/bin/env python3
import os
import re
import subprocess
import sys
STATIC_LIBS_RE = re.compile(
b"note: native-static-libs: ([^\\n]+)\\n"
)
def main():
# If you need to change the values here, be sure to update the values in
# the README. Alternatively, it is possible that adding new libraries to
# link against was a mistake that should be reverted or worked around.
if sys.platform.startswith("darwin"):
want = "-framework Security -liconv -lSystem -lc -lm"
elif sys.platform.startswith("linux"):
want = "-lgcc_s -lutil -lrt -lpthread -lm -ldl -lc"
elif sys.platform.startswith("win32"):
want = (
"advapi32.lib credui.lib kernel32.lib secur32.lib "
"kernel32.lib advapi32.lib userenv.lib "
"kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib "
"legacy_stdio_definitions.lib"
)
else:
want = ""
build = subprocess.run(
["cargo", "build"],
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
env=dict(os.environ, RUSTFLAGS="--print native-static-libs")
)
match = STATIC_LIBS_RE.search(build.stderr)
if match is None:
print("could not find list of native static libraries, check for "
"compilation errors")
sys.exit(1)
got = match.group(1).decode("ascii")
if want != got:
print(
"got unexpected list of native static libraries, "
"fix or update README. Got:\n {}\nInstead of:\n {}"
.format(got, want)
)
sys.exit(1)
if __name__ == "__main__":
main()
|