ANOTHER typo 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', 'sdktools.games'],
75 ['addons', 'sourcemod', 'gamedata', 'sm-cstrike.games'],
76 ['addons', 'sourcemod', 'configs', 'geoip'],
77 ['addons', 'sourcemod', 'translations'],
78 ['addons', 'sourcemod', 'logs'],
79 ['addons', 'sourcemod', 'extensions'],
80 ['addons', 'sourcemod', 'data'],
81 ['addons', 'sourcemod', 'scripting', 'include'],
82 ['addons', 'sourcemod', 'scripting', 'admin-flatfile'],
83 ['addons', 'sourcemod', 'scripting', 'adminmenu'],
84 ['addons', 'sourcemod', 'scripting', 'testsuite'],
86 ['addons', 'sourcemod', 'configs', 'sql-init-scripts'],
87 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql'],
88 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite'],
89 ['addons', 'sourcemod', 'scripting', 'basecommands'],
90 ['addons', 'sourcemod', 'scripting', 'basecomm'],
91 ['addons', 'sourcemod', 'scripting', 'funvotes'],
92 ['addons', 'sourcemod', 'scripting', 'basevotes'],
93 ['addons', 'sourcemod', 'scripting', 'basebans'],
94 ['addons', 'sourcemod', 'scripting', 'funcommands'],
95 ['addons', 'sourcemod', 'scripting', 'playercommands'],
96 ['addons', 'metamod'],
100 job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
101 job.AddCommand(CreateFolders(folders))
104 job.AddCommand(CopyFolder(['configs'], ['addons', 'sourcemod', 'configs']))
105 job.AddCommand(CopyFolder(['configs', 'geoip'], ['addons', 'sourcemod', 'configs', 'geoip']))
106 job.AddCommand(CopyFolder(['configs', 'cfg'], ['cfg', 'sourcemod']))
107 job.AddCommand(CopyFolder(['configs', 'metamod'], ['addons', 'metamod']))
108 job.AddCommand(CopyFolder(['configs', 'sql-init-scripts'],
109 ['addons', 'sourcemod', 'configs', 'sql-init-scripts']))
110 job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'mysql'],
111 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql']))
112 job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'sqlite'],
113 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite']))
114 job.AddCommand(CopyFolder(['gamedata'], ['addons', 'sourcemod', 'gamedata']))
115 job.AddCommand(CopyFolder(['gamedata', 'sdktools.games'],
116 ['addons', 'sourcemod', 'gamedata', 'sdktools.games']))
117 job.AddCommand(CopyFolder(['gamedata', 'core.games'],
118 ['addons', 'sourcemod', 'gamedata', 'core.games']))
119 job.AddCommand(CopyFolder(['gamedata', 'sm-cstrike.games'],
120 ['addons', 'sourcemod', 'gamedata', 'sm-cstrike.games']))
121 job.AddCommand(CopyFolder(['plugins'], ['addons', 'sourcemod', 'scripting'], ['AMBuilder']))
122 job.AddCommand(CopyFolder(['plugins', 'include'],
123 ['addons', 'sourcemod', 'scripting', 'include']))
124 job.AddCommand(CopyFolder(['translations'], ['addons', 'sourcemod', 'translations']))
125 job.AddCommand(CopyFolder(['public', 'licenses'], ['addons', 'sourcemod']))
126 job.AddCommand(CopyFolder(['plugins', 'admin-flatfile'],
127 ['addons', 'sourcemod', 'scripting', 'admin-flatfile']))
128 job.AddCommand(CopyFolder(['plugins', 'adminmenu'],
129 ['addons', 'sourcemod', 'scripting', 'adminmenu']))
130 job.AddCommand(CopyFolder(['plugins', 'testsuite'],
131 ['addons', 'sourcemod', 'scripting', 'testsuite']))
132 job.AddCommand(CopyFolder(['plugins', 'basecommands'],
133 ['addons', 'sourcemod', 'scripting', 'basecommands']))
134 job.AddCommand(CopyFolder(['plugins', 'basecomm'],
135 ['addons', 'sourcemod', 'scripting', 'basecomm']))
136 job.AddCommand(CopyFolder(['plugins', 'funvotes'],
137 ['addons', 'sourcemod', 'scripting', 'funvotes']))
138 job.AddCommand(CopyFolder(['plugins', 'basevotes'],
139 ['addons', 'sourcemod', 'scripting', 'basevotes']))
140 job.AddCommand(CopyFolder(['plugins', 'basebans'],
141 ['addons', 'sourcemod', 'scripting', 'basebans']))
142 job.AddCommand(CopyFolder(['plugins', 'funcommands'],
143 ['addons', 'sourcemod', 'scripting', 'funcommands']))
144 job.AddCommand(CopyFolder(['plugins', 'playercommands'],
145 ['addons', 'sourcemod', 'scripting', 'playercommands']))
168 'admin-sql-prefetch',
169 'admin-sql-threaded',
178 for plugin in defPlugins:
179 commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'),
180 os.path.join('addons', 'sourcemod', 'plugins')))
182 for plugin in disPlugins:
183 commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'),
184 os.path.join('addons', 'sourcemod', 'plugins', 'disabled')))
185 job.AddCommandGroup(commands)
189 def AddNormalLibrary(name, dest):
190 dest = os.path.join('addons', 'sourcemod', dest)
191 bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
193 # Each platform's version of dump_syms needs the path in a different format.
194 if AMBuild.target['platform'] == 'linux':
195 debug_info.append(name + '/' + name + '.so')
196 elif AMBuild.target['platform'] == 'darwin':
197 debug_info.append(name + '/' + name + '.dylib.dSYM')
198 elif AMBuild.target['platform'] == 'windows':
199 debug_info.append(name + '\\' + name + '.pdb')
201 def AddHL2Library(name, dest):
204 if AMBuild.target['platform'] not in sdk['platform']:
206 AddNormalLibrary(name + '.' + sdk['ext'], dest)
210 if AMBuild.target['platform'] == 'linux':
211 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm_i486.so'),
212 os.path.join('addons', 'sourcemod', 'bin')))
213 debug_info.append('loader/sourcemod_mm_i486.so')
214 elif AMBuild.target['platform'] == 'darwin':
215 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dylib'),
216 os.path.join('addons', 'sourcemod', 'bin')))
217 debug_info.append('loader/sourcemod_mm.dylib.dSYM')
218 elif AMBuild.target['platform'] == 'windows':
219 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dll'),
220 os.path.join('addons', 'sourcemod', 'bin')))
221 debug_info.append('loader\\sourcemod_mm.pdb')
223 AddHL2Library('sourcemod', 'bin')
224 AddNormalLibrary('sourcemod.logic', 'bin')
225 AddNormalLibrary('sourcepawn.jit.x86', 'bin')
226 AddNormalLibrary('geoip.ext', 'extensions')
227 AddNormalLibrary('dbi.mysql.ext', 'extensions')
228 AddNormalLibrary('dbi.sqlite.ext', 'extensions')
230 AddNormalLibrary('game.cstrike.ext.2.ep2v', 'extensions')
231 if AMBuild.target['platform'] != 'darwin':
232 AddNormalLibrary('game.cstrike.ext.2.csgo', 'extensions')
234 AddNormalLibrary('game.tf2.ext.2.ep2v', 'extensions')
235 AddNormalLibrary('topmenus.ext', 'extensions')
236 AddNormalLibrary('regex.ext', 'extensions')
237 AddNormalLibrary('webternet.ext', 'extensions')
238 AddNormalLibrary('clientprefs.ext', 'extensions')
239 AddNormalLibrary('updater.ext', 'extensions')
240 AddNormalLibrary('bintools.ext', 'extensions')
241 AddHL2Library('sdktools.ext', 'extensions')
243 bincopies.append(CopyFile(os.path.join('..', 'spcomp', 'spcomp' + osutil.ExecutableSuffix()),
244 os.path.join('addons', 'sourcemod', 'scripting')))
246 job.AddCommandGroup(bincopies)
248 if AMBuild.target['platform'] == 'windows':
249 job.AddCommand(CopyFile(
250 os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'batchtool', 'compile.exe'),
251 os.path.join('addons', 'sourcemod', 'scripting')))
253 pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
254 for pdb in debug_info:
255 pdblog.write(pdb + '\n')