Update build script for Lua
[liba.git] / script / meson.py
blobd1a23cd734734920a39184bb00ae2530ee0d9ef9
1 #!/usr/bin/env python
2 import os, re
4 SUFFIXS = (".c", ".h", ".cc", ".hh", ".cpp", ".hpp", ".cxx", ".hxx")
6 sources = []
7 for dirpath, dirnames, filenames in os.walk("include"):
8 for filename in filenames:
9 source = os.path.join(dirpath, filename)
10 prefix, suffix = os.path.splitext(source)
11 if suffix in SUFFIXS:
12 sources.append(source.replace("\\", "/"))
13 for dirpath, dirnames, filenames in os.walk("src"):
14 for filename in filenames:
15 source = os.path.join(dirpath, filename)
16 prefix, suffix = os.path.splitext(source)
17 if suffix in SUFFIXS:
18 sources.append(source.replace("\\", "/"))
19 sources = sorted(sources)
21 with open("meson.build", "r") as f:
22 meson = f.read()
23 new = "[\n '" + "',\n '".join(sources) + "',\n]\n"
24 old = re.findall(r"sources = ([^\]]+)", meson)[0] + "]\n"
25 with open("meson.build", "wb") as f:
26 meson = f.write(meson.replace(old, new).encode())