-
Notifications
You must be signed in to change notification settings - Fork 255
/
BuildCompat.py
60 lines (51 loc) · 2.21 KB
/
BuildCompat.py
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
#!/usr/bin/python3
import os
from twisted.python.filepath import FilePath
from subprocess import Popen
import re
import sys
from xml.dom.minidom import parse as XMLOpen
tm = '-m' in sys.argv
parallel = '-j' in sys.argv
csc = sys.argv[sys.argv.index("--csc") + 1]
PROJECT_PATTERN = re.compile(r'''Project.".[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}.". = '''
r'''"([0-9a-zA-Z]+Compat)", '''
r'''"([0-9A-zA-Z\/]+.csproj)", '''
r'''".[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}."''')
PUBLICIZER = os.environ.get("PUBLICIZER", "./AssemblyPublicizer")
DOWNLOAD_LIBS = os.environ.get("DOWNLOAD_LIBS", "--download-libs")
tasks = []
def system(*cmd):
sp = Popen(cmd)
if not parallel:
sp.wait()
ec = sp.poll()
if ec:
raise SystemExit(ec)
else:
tasks.append(sp)
with open("Source/CombatExtended.sln") as f:
for line in f.readlines():
line = line.strip()
match = PROJECT_PATTERN.match(line)
if match:
name, csproj = match.groups()
if tm and name not in sys.argv: continue
csproj = csproj.replace('\\', '/').split('/')
csproj = FilePath("Source").descendant(csproj)
output = FilePath("AssembliesCompat").child(name+".dll")
with XMLOpen(csproj.path) as cpath:
op = cpath.getElementsByTagName("OutputPath")
if op:
op = op[0].firstChild.data
if 'ModPatches' in op:
op = op.rsplit("..\\ModPatches", 1)[-1].replace('\\', '/').split('/')
if op:
od = FilePath("ModPatches").descendant(op)
if not od.exists():
od.makedirs()
output = od.child(name+".dll")
print(f"Building {name}")
system("python3", "Make.py", "--csproj", csproj.path, "--output", output.path, DOWNLOAD_LIBS, "--all-libs", "--publicizer", PUBLICIZER, "--csc", csc, "--", "-r:Assemblies/CombatExtended.dll")
for t in tasks:
t.wait()