Fixed PackageScript to not try and include extra extensions.
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)
187 job.AddCommand(CopyFile(os.path.join('..', 'includes', 'version_auto.inc'),
188 os.path.join('addons', 'sourcemod', 'scripting', 'include')))
192 def AddNormalLibrary(name, dest):
193 dest = os.path.join('addons', 'sourcemod', dest)
194 bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
196 # Each platform's version of dump_syms needs the path in a different format.
197 if AMBuild.target['platform'] == 'linux':
198 debug_info.append(name + '/' + name + '.so')
199 elif AMBuild.target['platform'] == 'darwin':
200 debug_info.append(name + '/' + name + '.dylib.dSYM')
201 elif AMBuild.target['platform'] == 'windows':
202 debug_info.append(name + '\\' + name + '.pdb')
204 def AddHL2Library(name, dest):
207 if AMBuild.target['platform'] not in sdk['platform']:
209 AddNormalLibrary(name + '.' + sdk['ext'], dest)
213 if AMBuild.target['platform'] == 'linux':
214 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm_i486.so'),
215 os.path.join('addons', 'sourcemod', 'bin')))
216 debug_info.append('loader/sourcemod_mm_i486.so')
217 elif AMBuild.target['platform'] == 'darwin':
218 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dylib'),
219 os.path.join('addons', 'sourcemod', 'bin')))
220 debug_info.append('loader/sourcemod_mm.dylib.dSYM')
221 elif AMBuild.target['platform'] == 'windows':
222 bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dll'),
223 os.path.join('addons', 'sourcemod', 'bin')))
224 debug_info.append('loader\\sourcemod_mm.pdb')
226 AddHL2Library('sourcemod', 'bin')
227 AddNormalLibrary('sourcemod.logic', 'bin')
228 AddNormalLibrary('sourcepawn.jit.x86', 'bin')
229 AddNormalLibrary('geoip.ext', 'extensions')
230 AddNormalLibrary('dbi.mysql.ext', 'extensions')
231 AddNormalLibrary('dbi.sqlite.ext', 'extensions')
233 if 'css' in SM.sdkInfo:
234 AddNormalLibrary('game.cstrike.ext.2.css', 'extensions')
236 if 'csgo' in SM.sdkInfo:
237 AddNormalLibrary('game.cstrike.ext.2.csgo', 'extensions')
239 if 'ep2v' in SM.sdkInfo:
240 AddNormalLibrary('game.tf2.ext.2.ep2v', 'extensions')
242 AddNormalLibrary('topmenus.ext', 'extensions')
243 AddNormalLibrary('regex.ext', 'extensions')
244 AddNormalLibrary('webternet.ext', 'extensions')
245 AddNormalLibrary('clientprefs.ext', 'extensions')
246 AddNormalLibrary('updater.ext', 'extensions')
247 AddNormalLibrary('bintools.ext', 'extensions')
248 AddHL2Library('sdktools.ext', 'extensions')
250 bincopies.append(CopyFile(os.path.join('..', 'spcomp', 'spcomp' + osutil.ExecutableSuffix()),
251 os.path.join('addons', 'sourcemod', 'scripting')))
253 job.AddCommandGroup(bincopies)
255 if AMBuild.target['platform'] == 'windows':
256 job.AddCommand(CopyFile(
257 os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'batchtool', 'compile.exe'),
258 os.path.join('addons', 'sourcemod', 'scripting')))
260 pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
261 for pdb in debug_info:
262 pdblog.write(pdb + '\n')