diff -r 69989a9e83ff -r 41feee1fac07 PackageScript --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PackageScript Sat Apr 16 00:41:25 2011 -0700 @@ -0,0 +1,120 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os +import shutil +import ambuild.osutil as osutil +from ambuild.command import Command + +job = AMBuild.AddJob('package') + +class DestroyPath(Command): + def __init__(self, folder): + Command.__init__(self) + self.folder = folder + + def destroy(self, path): + entries = os.listdir(path) + for entry in entries: + newpath = os.path.join(path, entry) + if os.path.isdir(newpath): + self.destroy(newpath) + os.rmdir(newpath) + elif os.path.isfile(newpath): + os.remove(newpath) + + def run(self, runner, job): + runner.PrintOut('rm -rf {0}/*'.format(self.folder)) + self.destroy(self.folder) + +class CreateFolders(Command): + def __init__(self, folders): + Command.__init__(self) + self.folders = folders + + def run(self, runner, job): + for folder in self.folders: + path = os.path.join(*folder) + runner.PrintOut('mkdir {0}'.format(path)) + os.makedirs(path) + +#Shallow folder copy +class CopyFolder(Command): + def __init__(self, fromList, toList, excludes = []): + Command.__init__(self) + self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList) + self.toPath = os.path.join(*toList) + self.excludes = excludes + + def run(self, runner, job): + entries = os.listdir(self.fromPath) + for entry in entries: + if entry in self.excludes: + continue + path = os.path.join(self.fromPath, entry) + if not os.path.isfile(path): + continue + runner.PrintOut('copy {0} to {1}'.format(path, self.toPath)) + shutil.copy(path, self.toPath) + +#Single file copy +class CopyFile(Command): + def __init__(self, fromFile, toPath): + Command.__init__(self) + self.fromFile = fromFile + self.toPath = toPath + + def run(self, runner, job): + runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath)) + shutil.copy(self.fromFile, self.toPath) + + +folders = [['addons', 'metamod'], + ['addons', 'stripper'], + ['addons', 'stripper', 'bin'], + ['addons', 'stripper', 'dumps'], + ['addons', 'stripper', 'maps']] + +#Setup +job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package'))) +job.AddCommand(CreateFolders(folders)) + +#Copiy Files +job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'de_dust.cfg'), + os.path.join('addons', 'stripper', 'maps'))) +job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'global_filters.cfg'), + os.path.join('addons', 'stripper'))) +job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'stripper.vdf'), + os.path.join('addons', 'metamod'))) + +bincopies = [] + +def AddNormalLibrary(name, dest): + dest = os.path.join('addons', 'stripper', dest) + bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest)) + pdb_list.append(name + '\\' + name + '.pdb') + +def AddHL2Library(name, dest): + for i in Stripper.sdkInfo: + sdk = Stripper.sdkInfo[i] + if AMBuild.target['platform'] not in sdk['platform']: + continue + AddNormalLibrary(name + '.' + sdk['ext'], dest) + +pdb_list = [] + +# Copy loader binaries +if AMBuild.target['platform'] == 'linux': + AddNormalLibrary('stripper_mm_i486', 'bin') +else: + AddNormalLibrary('stripper_mm', 'bin') +AddNormalLibrary('stripper.core', 'bin') +AddHL2Library('stripper', 'bin') + +job.AddCommandGroup(bincopies) + +if AMBuild.target['platform'] == 'windows': + pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt') + for pdb in pdb_list: + pdblog.write(pdb + '\n') + pdblog.close() + +