Ep2v cstrike ext now gets added to package.
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', 'configs', 'geoip'],
76 ['addons', 'sourcemod', 'translations'],
77 ['addons', 'sourcemod', 'logs'],
78 ['addons', 'sourcemod', 'extensions'],
79 ['addons', 'sourcemod', 'data'],
80 ['addons', 'sourcemod', 'scripting', 'include'],
81 ['addons', 'sourcemod', 'scripting', 'admin-flatfile'],
82 ['addons', 'sourcemod', 'scripting', 'adminmenu'],
83 ['addons', 'sourcemod', 'scripting', 'testsuite'],
85 ['addons', 'sourcemod', 'configs', 'sql-init-scripts'],
86 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql'],
87 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite'],
88 ['addons', 'sourcemod', 'scripting', 'basecommands'],
89 ['addons', 'sourcemod', 'scripting', 'basecomm'],
90 ['addons', 'sourcemod', 'scripting', 'funvotes'],
91 ['addons', 'sourcemod', 'scripting', 'basevotes'],
92 ['addons', 'sourcemod', 'scripting', 'basebans'],
93 ['addons', 'sourcemod', 'scripting', 'funcommands'],
94 ['addons', 'sourcemod', 'scripting', 'playercommands'],
95 ['addons', 'metamod'],
99 job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
100 job.AddCommand(CreateFolders(folders))
103 job.AddCommand(CopyFolder(['configs'], ['addons', 'sourcemod', 'configs']))
104 job.AddCommand(CopyFolder(['configs', 'geoip'], ['addons', 'sourcemod', 'configs', 'geoip']))
105 job.AddCommand(CopyFolder(['configs', 'cfg'], ['cfg', 'sourcemod']))
106 job.AddCommand(CopyFolder(['configs', 'metamod'], ['addons', 'metamod']))
107 job.AddCommand(CopyFolder(['configs', 'sql-init-scripts'],
108 ['addons', 'sourcemod', 'configs', 'sql-init-scripts']))
109 job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'mysql'],
110 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql']))
111 job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'sqlite'],
112 ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite']))
113 job.AddCommand(CopyFolder(['gamedata'], ['addons', 'sourcemod', 'gamedata']))
114 job.AddCommand(CopyFolder(['gamedata', 'sdktools.games'],
115 ['addons', 'sourcemod', 'gamedata', 'sdktools.games']))
116 job.AddCommand(CopyFolder(['gamedata', 'core.games'],
117 ['addons', 'sourcemod', 'gamedata', 'core.games']))
118 job.AddCommand(CopyFolder(['plugins'], ['addons', 'sourcemod', 'scripting'], ['AMBuilder']))
119 job.AddCommand(CopyFolder(['plugins', 'include'],
120 ['addons', 'sourcemod', 'scripting', 'include']))
121 job.AddCommand(CopyFolder(['translations'], ['addons', 'sourcemod', 'translations']))
122 job.AddCommand(CopyFolder(['public', 'licenses'], ['addons', 'sourcemod']))
123 job.AddCommand(CopyFolder(['plugins', 'admin-flatfile'],
124 ['addons', 'sourcemod', 'scripting', 'admin-flatfile']))
125 job.AddCommand(CopyFolder(['plugins', 'adminmenu'],
126 ['addons', 'sourcemod', 'scripting', 'adminmenu']))
127 job.AddCommand(CopyFolder(['plugins', 'testsuite'],
128 ['addons', 'sourcemod', 'scripting', 'testsuite']))
129 job.AddCommand(CopyFolder(['plugins', 'basecommands'],
130 ['addons', 'sourcemod', 'scripting', 'basecommands']))
131 job.AddCommand(CopyFolder(['plugins', 'basecomm'],
132 ['addons', 'sourcemod', 'scripting', 'basecomm']))
133 job.AddCommand(CopyFolder(['plugins', 'funvotes'],
134 ['addons', 'sourcemod', 'scripting', 'funvotes']))
135 job.AddCommand(CopyFolder(['plugins', 'basevotes'],
136 ['addons', 'sourcemod', 'scripting', 'basevotes']))
137 job.AddCommand(CopyFolder(['plugins', 'basebans'],
138 ['addons', 'sourcemod', 'scripting', 'basebans']))
139 job.AddCommand(CopyFolder(['plugins', 'funcommands'],
140 ['addons', 'sourcemod', 'scripting', 'funcommands']))
141 job.AddCommand(CopyFolder(['plugins', 'playercommands'],
142 ['addons', 'sourcemod', 'scripting', 'playercommands']))
165 'admin-sql-prefetch',
166 'admin-sql-threaded',
175 for plugin in defPlugins:
176 commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'),
177 os.path.join('addons', 'sourcemod', 'plugins')))
179 for plugin in disPlugins:
180 commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'),
181 os.path.join('addons', 'sourcemod', 'plugins', 'disabled')))
182 job.AddCommandGroup(commands)
186 def AddNormalLibrary(name, dest):
187 dest = os.path.join('addons', 'sourcemod', dest)
188 bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
189 pdb_list.append(name + '\\' + name + '.pdb')
191 def AddHL2Library(name, dest):
194 if AMBuild.target['platform'] not in sdk['platform']:
196 AddNormalLibrary(name + '.' + sdk['ext'], dest)
200 if AMBuild.target['platform'] == 'linux':
201 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm_i486.so'),
202 os.path.join('addons', 'sourcemod', 'bin')))
203 elif AMBuild.target['platform'] == 'darwin':
204 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dylib'),
205 os.path.join('addons', 'sourcemod', 'bin')))
206 elif AMBuild.target['platform'] == 'windows':
207 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dll'),
208 os.path.join('addons', 'sourcemod', 'bin')))
209 pdb_list.append('loader\\sourcemod_mm.pdb')
211 AddHL2Library('sourcemod', 'bin')
212 AddNormalLibrary('sourcemod.logic', 'bin')
213 AddNormalLibrary('sourcepawn.jit.x86', 'bin')
214 AddNormalLibrary('geoip.ext', 'extensions')
215 AddNormalLibrary('dbi.mysql.ext', 'extensions')
216 AddNormalLibrary('dbi.sqlite.ext', 'extensions')
217 if AMBuild.target['platform'] != 'darwin':
218 AddNormalLibrary('game.cstrike.ext.1.ep1', 'extensions')
219 AddNormalLibrary('game.cstrike.ext.2.ep2v', 'extensions')
220 AddNormalLibrary('game.tf2.ext.2.ep2v', 'extensions')
221 AddNormalLibrary('topmenus.ext', 'extensions')
222 AddNormalLibrary('regex.ext', 'extensions')
223 AddNormalLibrary('webternet.ext', 'extensions')
224 AddNormalLibrary('clientprefs.ext', 'extensions')
225 AddNormalLibrary('updater.ext', 'extensions')
226 AddHL2Library('bintools.ext', 'extensions')
227 AddHL2Library('sdktools.ext', 'extensions')
229 bincopies.append(CopyFile(os.path.join('..', 'spcomp', 'spcomp' + osutil.ExecutableSuffix()),
230 os.path.join('addons', 'sourcemod', 'scripting')))
232 job.AddCommandGroup(bincopies)
234 if AMBuild.target['platform'] == 'windows':
235 job.AddCommand(CopyFile(
236 os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'batchtool', 'compile.exe'),
237 os.path.join('addons', 'sourcemod', 'scripting')))
238 pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
240 pdblog.write(pdb + '\n')