4 SUFFIXS
= (".c", ".cc", ".cpp", ".cxx")
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
):
12 for dirpath
, dirnames
, filenames
in os
.walk("src"):
13 for filename
in filenames
:
14 source
= os
.path
.join(dirpath
, filename
)
15 prefix
, suffix
= os
.path
.splitext(source
)
17 sources
.append(source
.replace("\\", "/"))
18 sources
= sorted(sources
)
20 with
open("build.rs", "r") as f
:
22 cur
= re
.findall(r
"make([^;]+)\.compile\(\"a
\"\
)", build)[index]
23 new = '.file("' + '")\n .file("'.join(sources) + '")\n '
24 with open("build
.rs
", "wb
") as f:
25 build = f.write(build.replace(cur, new).encode())