More Windows build fix.
1 # vim: set ts=2 sw=2 tw=99 noet ft=python:
4 import ambuild.osutil as osutil
5 from ambuild.command import Command
7 job = AMBuild.AddJob('package')
9 class DestroyPath(Command):
10 def __init__(self, folder):
11 Command.__init__(self)
14 def destroy(self, path):
15 entries = os.listdir(path)
17 newpath = os.path.join(path, entry)
18 if os.path.isdir(newpath):
21 elif os.path.isfile(newpath):
24 def run(self, runner, job):
25 runner.PrintOut('rm -rf {0}/*'.format(self.folder))
26 self.destroy(self.folder)
28 class CreateFolders(Command):
29 def __init__(self, folders):
30 Command.__init__(self)
31 self.folders = folders
33 def run(self, runner, job):
34 for folder in self.folders:
35 path = os.path.join(*folder)
36 runner.PrintOut('mkdir {0}'.format(path))
40 class CopyFolder(Command):
41 def __init__(self, fromList, toList, excludes = []):
42 Command.__init__(self)
43 self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList)
44 self.toPath = os.path.join(*toList)
45 self.excludes = excludes
47 def run(self, runner, job):
48 entries = os.listdir(self.fromPath)
50 if entry in self.excludes:
52 path = os.path.join(self.fromPath, entry)
53 if not os.path.isfile(path):
55 runner.PrintOut('copy {0} to {1}'.format(path, self.toPath))
56 shutil.copy(path, self.toPath)
59 class CopyFile(Command):
60 def __init__(self, fromFile, toPath):
61 Command.__init__(self)
62 self.fromFile = fromFile
65 def run(self, runner, job):
66 runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath))
67 shutil.copy(self.fromFile, self.toPath)
70 folders = [['addons', 'sourcemod', 'bin'],
71 ['addons', 'sourcemod', 'plugins', 'disabled'],
72 ['addons', 'sourcemod', 'gamedata'],
73 ['addons', 'sourcemod', 'gamedata', 'core.games'],
74 ['addons', 'sourcemod', 'gamedata', 'sdkhooks.games'],
75 ['addons', 'sourcemod', 'gamedata', 'sdktools.games'],
76 ['addons', 'sourcemod', 'gamedata', 'sm-cstrike.games'],
77 ['addons', 'sourcemod', 'configs', 'geoip'],
78 ['addons', 'sourcemod', 'translations'],
79 ['addons', 'sourcemod', 'logs'],
80 ['addons', 'sourcemod', 'extensions'],
81 ['addons', 'sourcemod', 'data'],
82 ['addons', 'sourcemod', 'scripting', 'include'],
83 ['addons', 'sourcemod', 'scripting', 'admin-flatfile'],
84 ['addons', 'sourcemod', 'scripting', 'adminmenu'],
85 ['addons', 'sourcemod', 'scripting', 'testsuite'],
87 ['addons', 'sourcemod', 'configs', 'sql-init-scripts'],
88 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql'],
89 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite'],
90 ['addons', 'sourcemod', 'scripting', 'basecommands'],
91 ['addons', 'sourcemod', 'scripting', 'basecomm'],
92 ['addons', 'sourcemod', 'scripting', 'funvotes'],
93 ['addons', 'sourcemod', 'scripting', 'basevotes'],
94 ['addons', 'sourcemod', 'scripting', 'basebans'],
95 ['addons', 'sourcemod', 'scripting', 'funcommands'],
96 ['addons', 'sourcemod', 'scripting', 'playercommands'],
97 ['addons', 'metamod'],
101 job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
102 job.AddCommand(CreateFolders(folders))
105 job.AddCommand(CopyFolder(['configs'], ['addons', 'sourcemod', 'configs']))
106 job.AddCommand(CopyFolder(['configs', 'geoip'], ['addons', 'sourcemod', 'configs', 'geoip']))
107 job.AddCommand(CopyFolder(['configs', 'cfg'], ['cfg', 'sourcemod']))
108 job.AddCommand(CopyFolder(['configs', 'metamod'], ['addons', 'metamod']))
109 job.AddCommand(CopyFolder(['configs', 'sql-init-scripts'],
110 ['addons', 'sourcemod', 'configs', 'sql-init-scripts']))
111 job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'mysql'],
112 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql']))
113 job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'sqlite'],
114 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite']))
115 job.AddCommand(CopyFolder(['gamedata'], ['addons', 'sourcemod', 'gamedata']))
116 job.AddCommand(CopyFolder(['gamedata', 'sdkhooks.games'],
117 ['addons', 'sourcemod', 'gamedata', 'sdkhooks.games']))
118 job.AddCommand(CopyFolder(['gamedata', 'sdktools.games'],
119 ['addons', 'sourcemod', 'gamedata', 'sdktools.games']))
120 job.AddCommand(CopyFolder(['gamedata', 'core.games'],
121 ['addons', 'sourcemod', 'gamedata', 'core.games']))
122 job.AddCommand(CopyFolder(['gamedata', 'sm-cstrike.games'],
123 ['addons', 'sourcemod', 'gamedata', 'sm-cstrike.games']))
124 job.AddCommand(CopyFolder(['plugins'], ['addons', 'sourcemod', 'scripting'], ['AMBuilder']))
125 job.AddCommand(CopyFolder(['plugins', 'include'],
126 ['addons', 'sourcemod', 'scripting', 'include']))
127 job.AddCommand(CopyFolder(['translations'], ['addons', 'sourcemod', 'translations']))
128 job.AddCommand(CopyFolder(['public', 'licenses'], ['addons', 'sourcemod']))
129 job.AddCommand(CopyFolder(['plugins', 'admin-flatfile'],
130 ['addons', 'sourcemod', 'scripting', 'admin-flatfile']))
131 job.AddCommand(CopyFolder(['plugins', 'adminmenu'],
132 ['addons', 'sourcemod', 'scripting', 'adminmenu']))
133 job.AddCommand(CopyFolder(['plugins', 'testsuite'],
134 ['addons', 'sourcemod', 'scripting', 'testsuite']))
135 job.AddCommand(CopyFolder(['plugins', 'basecommands'],
136 ['addons', 'sourcemod', 'scripting', 'basecommands']))
137 job.AddCommand(CopyFolder(['plugins', 'basecomm'],
138 ['addons', 'sourcemod', 'scripting', 'basecomm']))
139 job.AddCommand(CopyFolder(['plugins', 'funvotes'],
140 ['addons', 'sourcemod', 'scripting', 'funvotes']))
141 job.AddCommand(CopyFolder(['plugins', 'basevotes'],
142 ['addons', 'sourcemod', 'scripting', 'basevotes']))
143 job.AddCommand(CopyFolder(['plugins', 'basebans'],
144 ['addons', 'sourcemod', 'scripting', 'basebans']))
145 job.AddCommand(CopyFolder(['plugins', 'funcommands'],
146 ['addons', 'sourcemod', 'scripting', 'funcommands']))
147 job.AddCommand(CopyFolder(['plugins', 'playercommands'],
148 ['addons', 'sourcemod', 'scripting', 'playercommands']))
171 'admin-sql-prefetch',
172 'admin-sql-threaded',
181 for plugin in defPlugins:
182 commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'),
183 os.path.join('addons', 'sourcemod', 'plugins')))
185 for plugin in disPlugins:
186 commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'),
187 os.path.join('addons', 'sourcemod', 'plugins', 'disabled')))
188 job.AddCommandGroup(commands)
190 job.AddCommand(CopyFile(os.path.join('..', 'includes', 'version_auto.inc'),
191 os.path.join('addons', 'sourcemod', 'scripting', 'include')))
195 def AddNormalLibrary(name, dest):
196 dest = os.path.join('addons', 'sourcemod', dest)
197 bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
199 # Each platform's version of dump_syms needs the path in a different format.
200 if AMBuild.target['platform'] == 'linux':
201 debug_info.append(name + '/' + name + '.so')
202 elif AMBuild.target['platform'] == 'darwin':
203 debug_info.append(name + '/' + name + '.dylib.dSYM')
204 elif AMBuild.target['platform'] == 'windows':
205 debug_info.append(name + '\\' + name + '.pdb')
207 def AddHL2Library(name, dest):
210 if AMBuild.target['platform'] not in sdk['platform']:
212 AddNormalLibrary(name + '.' + sdk['ext'], dest)
216 if AMBuild.target['platform'] == 'linux':
217 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm_i486.so'),
218 os.path.join('addons', 'sourcemod', 'bin')))
219 debug_info.append('loader/sourcemod_mm_i486.so')
220 elif AMBuild.target['platform'] == 'darwin':
221 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dylib'),
222 os.path.join('addons', 'sourcemod', 'bin')))
223 debug_info.append('loader/sourcemod_mm.dylib.dSYM')
224 elif AMBuild.target['platform'] == 'windows':
225 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dll'),
226 os.path.join('addons', 'sourcemod', 'bin')))
227 debug_info.append('loader\\sourcemod_mm.pdb')
229 AddHL2Library('sourcemod', 'bin')
230 AddNormalLibrary('sourcemod.logic', 'bin')
231 AddNormalLibrary('sourcepawn.jit.x86', 'bin')
232 AddNormalLibrary('geoip.ext', 'extensions')
234 AddNormalLibrary('dbi.mysql.ext', 'extensions')
235 AddNormalLibrary('dbi.sqlite.ext', 'extensions')
237 if 'css' in SM.sdkInfo:
238 AddNormalLibrary('game.cstrike.ext.2.css', 'extensions')
240 if 'csgo' in SM.sdkInfo:
241 AddNormalLibrary('game.cstrike.ext.2.csgo', 'extensions')
243 if 'tf2' in SM.sdkInfo:
244 AddNormalLibrary('game.tf2.ext.2.tf2', 'extensions')
246 AddNormalLibrary('topmenus.ext', 'extensions')
247 AddNormalLibrary('regex.ext', 'extensions')
248 AddNormalLibrary('webternet.ext', 'extensions')
249 AddNormalLibrary('clientprefs.ext', 'extensions')
250 AddNormalLibrary('updater.ext', 'extensions')
251 AddNormalLibrary('bintools.ext', 'extensions')
252 AddHL2Library('sdkhooks.ext', 'extensions')
253 AddHL2Library('sdktools.ext', 'extensions')
255 bincopies.append(CopyFile(os.path.join('..', 'spcomp', 'spcomp' + osutil.ExecutableSuffix()),
256 os.path.join('addons', 'sourcemod', 'scripting')))
258 # Each platform's version of dump_syms needs the path in a different format.
259 if AMBuild.target['platform'] == 'linux':
260 debug_info.append('spcomp' + '/' + 'spcomp')
261 elif AMBuild.target['platform'] == 'darwin':
262 debug_info.append('spcomp' + '/' + 'spcomp' + '.dSYM')
263 elif AMBuild.target['platform'] == 'windows':
264 debug_info.append('spcomp' + '\\' + 'spcomp' + '.pdb')
266 job.AddCommandGroup(bincopies)
268 if AMBuild.target['platform'] == 'windows':
269 job.AddCommand(CopyFile(
270 os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'batchtool', 'compile.exe'),
271 os.path.join('addons', 'sourcemod', 'scripting')))
273 pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
274 for pdb in debug_info:
275 pdblog.write(pdb + '\n')