remove `#!/usr/bin/env sh`
[liba.git] / script / meson.py
blob12eafe8bccdbce38b1a634a50a1a2a42c4ca5076
1 #!/usr/bin/env python
2 import sys, os, re
4 SUFFIXS = (".c", ".h", ".cc", ".hh", ".cpp", ".hpp", ".cxx", ".hxx")
5 ROOT = os.path.abspath(sys.argv[0])
6 ROOT = os.path.dirname(ROOT)
7 ROOT = os.path.dirname(ROOT)
10 def main(index=0, SUFFIXS=SUFFIXS):
11 sources = []
12 for dirpath, dirnames, filenames in os.walk("include"):
13 for filename in filenames:
14 source = os.path.join(dirpath, filename)
15 prefix, suffix = os.path.splitext(source)
16 if suffix in SUFFIXS:
17 sources.append(source.replace("\\", "/"))
18 for dirpath, dirnames, filenames in os.walk("src"):
19 for filename in filenames:
20 source = os.path.join(dirpath, filename)
21 prefix, suffix = os.path.splitext(source)
22 if suffix in SUFFIXS:
23 sources.append(source.replace("\\", "/"))
24 sources = sorted(sources)
26 with open("meson.build", "r") as f:
27 meson = f.read()
28 cur = re.findall(r"sources = ([^\]]+)", meson)[index] + "]\n"
29 new = "[\n '" + "',\n '".join(sources) + "',\n]\n"
30 with open("meson.build", "wb") as f:
31 meson = f.write(meson.replace(cur, new).encode())
34 os.chdir(ROOT + "/java")
35 main(1, [".java"])
36 main()
37 os.chdir(ROOT + "/lua")
38 main()
39 os.chdir(ROOT + "/quickjs")
40 main()
41 os.chdir(ROOT)
42 main()