forked from kivy/python-for-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper.py
More file actions
61 lines (50 loc) · 1.69 KB
/
Copy pathwrapper.py
File metadata and controls
61 lines (50 loc) · 1.69 KB
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
#!/usr/bin/python3
# Taken from https://github.com/termux/termux-packages/blob/master/packages/python-scipy/wrapper.py.in
import os
import subprocess
import sys
"""
This wrapper is used to ignore or replace some unsupported flags for flang-new.
It will operate as follows:
1. Ignore `-Minform=inform` and `-fdiagnostics-color`.
They are added by meson automatically, but are not supported by flang-new yet.
2. Remove `-lflang` and `-lpgmath`.
It exists in classic-flang but doesn't exist in flang-new.
3. Replace `-Oz` to `-O2`.
`-Oz` is not supported by flang-new.
4. Replace `-module` to `-J`.
See https://github.com/llvm/llvm-project/issues/66969
5. Ignore `-MD`, `-MQ file` and `-MF file`.
They generates files used by GNU make but we're using ninja.
6. Ignore `-fvisibility=hidden`.
It is not supported by flang-new, and ignoring it will not break the functionality,
as scipy also uses version script for shared libraries.
"""
COMPLIER_PATH = "@COMPILER@"
def main(argv: list[str]):
cwd = os.getcwd()
argv_new = []
i = 0
while i < len(argv):
arg = argv[i]
if arg in [
"-Minform=inform",
"-lflang",
"-lpgmath",
"-MD",
"-fvisibility=hidden",
] or arg.startswith("-fdiagnostics-color"):
pass
elif arg == "-Oz":
argv_new.append("-O2")
elif arg == "-module":
argv_new.append("-J")
elif arg in ["-MQ", "-MF"]:
i += 1
else:
argv_new.append(arg)
i += 1
args = [COMPLIER_PATH] + argv_new
subprocess.check_call(args, env=os.environ, cwd=cwd, text=True)
if __name__ == "__main__":
main(sys.argv[1:])