1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/support/buildbot/PackageScript Fri May 14 00:34:36 2010 -0500
1.3 @@ -0,0 +1,112 @@
1.4 +# vim: set ts=2 sw=2 tw=99 noet ft=python:
1.5 +import os
1.6 +import shutil
1.7 +import ambuild.osutil as osutil
1.8 +from ambuild.command import Command
1.9 +
1.10 +job = AMBuild.AddJob('package')
1.11 +
1.12 +class DestroyPath(Command):
1.13 + def __init__(self, folder):
1.14 + Command.__init__(self)
1.15 + self.folder = folder
1.16 +
1.17 + def destroy(self, path):
1.18 + entries = os.listdir(path)
1.19 + for entry in entries:
1.20 + newpath = os.path.join(path, entry)
1.21 + if os.path.isdir(newpath):
1.22 + self.destroy(newpath)
1.23 + os.rmdir(newpath)
1.24 + elif os.path.isfile(newpath):
1.25 + os.remove(newpath)
1.26 +
1.27 + def run(self, runner, job):
1.28 + runner.PrintOut('rm -rf {0}/*'.format(self.folder))
1.29 + self.destroy(self.folder)
1.30 +
1.31 +class CreateFolders(Command):
1.32 + def __init__(self, folders):
1.33 + Command.__init__(self)
1.34 + self.folders = folders
1.35 +
1.36 + def run(self, runner, job):
1.37 + for folder in self.folders:
1.38 + path = os.path.join(*folder)
1.39 + runner.PrintOut('mkdir {0}'.format(path))
1.40 + os.makedirs(path)
1.41 +
1.42 +#Shallow folder copy
1.43 +class CopyFolder(Command):
1.44 + def __init__(self, fromList, toList, excludes = []):
1.45 + Command.__init__(self)
1.46 + self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList)
1.47 + self.toPath = os.path.join(*toList)
1.48 + self.excludes = excludes
1.49 +
1.50 + def run(self, runner, job):
1.51 + entries = os.listdir(self.fromPath)
1.52 + for entry in entries:
1.53 + if entry in self.excludes:
1.54 + continue
1.55 + path = os.path.join(self.fromPath, entry)
1.56 + if not os.path.isfile(path):
1.57 + continue
1.58 + runner.PrintOut('copy {0} to {1}'.format(path, self.toPath))
1.59 + shutil.copy(path, self.toPath)
1.60 +
1.61 +#Single file copy
1.62 +class CopyFile(Command):
1.63 + def __init__(self, fromFile, toPath):
1.64 + Command.__init__(self)
1.65 + self.fromFile = fromFile
1.66 + self.toPath = toPath
1.67 +
1.68 + def run(self, runner, job):
1.69 + runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath))
1.70 + shutil.copy(self.fromFile, self.toPath)
1.71 +
1.72 +
1.73 +folders = [['addons', 'metamod', 'bin']]
1.74 +
1.75 +#Setup
1.76 +job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
1.77 +job.AddCommand(CreateFolders(folders))
1.78 +
1.79 +#Copiy Files
1.80 +job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'metaplugins.ini'),
1.81 + os.path.join('addons', 'metamod')))
1.82 +job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'README.txt'),
1.83 + os.path.join('addons', 'metamod')))
1.84 +
1.85 +bincopies = []
1.86 +
1.87 +def AddNormalLibrary(name, dest):
1.88 + dest = os.path.join('addons', 'metamod', dest)
1.89 + bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
1.90 + pdb_list.append(name + '\\' + name + '.pdb')
1.91 +
1.92 +def AddHL2Library(name, dest):
1.93 + for i in MMS.sdkInfo:
1.94 + sdk = MMS.sdkInfo[i]
1.95 + if AMBuild.target['platform'] not in sdk['platform']:
1.96 + continue
1.97 + AddNormalLibrary(name + '.' + sdk['ext'], dest)
1.98 +
1.99 +pdb_list = []
1.100 +
1.101 +# Copy loader binaries
1.102 +AddNormalLibrary('server', 'bin')
1.103 +if AMBuild.target['platform'] == 'linux':
1.104 + AddNormalLibrary('server_i486', 'bin')
1.105 +
1.106 +AddHL2Library('metamod', 'bin')
1.107 +
1.108 +job.AddCommandGroup(bincopies)
1.109 +
1.110 +if AMBuild.target['platform'] == 'windows':
1.111 + pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
1.112 + for pdb in pdb_list:
1.113 + pdblog.write(pdb + '\n')
1.114 + pdblog.close()
1.115 +