This repository has been archived by the owner on Dec 3, 2018. It is now read-only.
forked from Azelphur-Servers/TF2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
executable file
·145 lines (117 loc) · 4.55 KB
/
build.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/python2
import yaml
import urllib
import urlparse
import subprocess
import os
import shutil
def mkdir(path):
folder = os.path.dirname(path)
if not os.path.exists(folder):
os.makedirs(folder)
def do_include(thing):
for path in config[thing]['include']:
mkdir(os.path.abspath(os.path.join('build', path)))
os.rename(os.path.join(thing, path), os.path.join('build', path))
def sourcemod_build(f):
print 'Building', f
spcomp = os.path.abspath('./sourcemod/addons/sourcemod/scripting/spcomp')
sp = os.path.abspath(f)
origWD = os.getcwd()
os.chdir('build/addons/sourcemod/plugins/')
r = subprocess.call(
[
spcomp,
sp
],
)
if r:
print 'Failed to compile, aborting'
exit()
os.chdir(origWD)
with open('surf.yaml', 'r') as stream:
config = yaml.load(stream)
for thing in ['metamod', 'sourcemod']:
if not os.path.exists(thing+'.tar.gz'):
subprocess.call(['wget', '-O', thing+'.tar.gz', config[thing]['url']])
if os.path.exists(thing):
shutil.rmtree(thing)
os.mkdir(thing)
subprocess.call(['tar', 'zxf', thing+'.tar.gz', '-C', thing])
do_include(thing)
os.mkdir('build/addons/sourcemod/plugins')
for root, dirs, files in os.walk('sourcemod_plugins'):
for name in files:
if name[-4:] == '.inc':
shutil.copy(
os.path.join(root, name),
'sourcemod/addons/sourcemod/scripting/include'
)
for root, dirs, files in os.walk('sourcemod_extensions'):
for name in files:
if name[-4:] == '.inc':
shutil.copy(
os.path.join(root, name),
'sourcemod/addons/sourcemod/scripting/include'
)
for plugin in config['sourcemod']['plugins']:
f = os.path.join('sourcemod/addons/sourcemod/plugins', plugin+'.smx')
if os.path.exists(f):
os.rename(f, 'build/addons/sourcemod/plugins/'+plugin+'.smx')
f = os.path.join('sourcemod/addons/sourcemod/plugins/disabled', plugin+'.smx')
if os.path.exists(f):
os.rename(f, 'build/addons/sourcemod/plugins/'+plugin+'.smx')
f = os.path.join('sourcemod_plugins/', plugin)
if os.path.exists(f) and os.path.isdir(f):
for folder in ['extensions', 'translations', 'gamedata', 'configs']:
if os.path.exists(os.path.join(f, folder)):
for t in os.listdir(os.path.join(f, folder)):
if os.path.isdir(os.path.join(f, folder, t)):
shutil.copytree(
os.path.join(f, folder, t),
os.path.join('build/addons/sourcemod/', folder, t)
)
else:
shutil.copy(
os.path.join(f, folder, t),
os.path.join('build/addons/sourcemod/', folder, t)
)
for root, dirs, files in os.walk(os.path.join(f, 'scripting')):
for name in files:
if name[-3:] == '.sp':
sourcemod_build(os.path.join(root, name))
if os.path.exists(f+'.sp') and os.path.isfile(f+'.sp'):
sourcemod_build(f+'.sp')
for extension in config['sourcemod']['extensions']:
f = os.path.join('sourcemod_extensions/', extension)
if os.path.exists(f) and os.path.isdir(f):
for folder in ['extensions', 'translations', 'gamedata', 'configs']:
if os.path.exists(os.path.join(f, folder)):
for t in os.listdir(os.path.join(f, folder)):
shutil.copy(
os.path.join(f, folder, t),
os.path.join('build/addons/sourcemod/', folder, t)
)
for src, dst in config['sourcemod']['configs']:
f = os.path.join('sourcemod_configs', src)
if os.path.exists(f):
shutil.copy(f, os.path.join('build/addons/sourcemod/configs/', dst))
continue
f = os.path.join('sourcemod/addons/sourcemod/configs', src)
if os.path.exists(f):
os.rename(f, os.path.join('build/addons/sourcemod/configs/', dst))
os.mkdir('build/cfg')
for src, dst in config['configs']:
f = os.path.join('cfg', src)
if os.path.exists(f):
mkdir(os.path.join('build/cfg/', dst))
if os.path.isdir(f):
shutil.copytree(f, os.path.join('build/cfg/', dst))
else:
shutil.copy(f, os.path.join('build/cfg/', dst))
os.mkdir('build/maps')
for map_file in config['maps']:
shutil.copy(
os.path.join('maps', map_file),
'build/maps/'
)