1.1 --- a/support/buildbot/PackageScript Thu Oct 24 13:30:44 2013 -0400
1.2 +++ b/support/buildbot/PackageScript Mon Nov 18 09:46:46 2013 -0800
1.3 @@ -1,114 +1,25 @@
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 +builder.SetBuildFolder('package')
1.42
1.43 -#Shallow folder copy
1.44 -class CopyFolder(Command):
1.45 - def __init__(self, fromList, toList, excludes = []):
1.46 - Command.__init__(self)
1.47 - self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList)
1.48 - self.toPath = os.path.join(*toList)
1.49 - self.excludes = excludes
1.50 -
1.51 - def run(self, runner, job):
1.52 - entries = os.listdir(self.fromPath)
1.53 - for entry in entries:
1.54 - if entry in self.excludes:
1.55 - continue
1.56 - path = os.path.join(self.fromPath, entry)
1.57 - if not os.path.isfile(path):
1.58 - continue
1.59 - runner.PrintOut('copy {0} to {1}'.format(path, self.toPath))
1.60 - shutil.copy(path, self.toPath)
1.61 -
1.62 -#Single file copy
1.63 -class CopyFile(Command):
1.64 - def __init__(self, fromFile, toPath):
1.65 - Command.__init__(self)
1.66 - self.fromFile = fromFile
1.67 - self.toPath = toPath
1.68 +addons_folder = builder.AddFolder('addons')
1.69 +metamod_folder = builder.AddFolder(os.path.join('addons', 'metamod'))
1.70 +bin_folder = builder.AddFolder(os.path.join('addons', 'metamod', 'bin'))
1.71
1.72 - def run(self, runner, job):
1.73 - runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath))
1.74 - shutil.copy(self.fromFile, self.toPath)
1.75 -
1.76 -
1.77 -folders = [['addons', 'metamod', 'bin']]
1.78 -
1.79 -#Setup
1.80 -job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
1.81 -job.AddCommand(CreateFolders(folders))
1.82 -
1.83 -#Copy Files
1.84 -job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'metamod.vdf'),
1.85 - os.path.join('addons')))
1.86 -job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'metaplugins.ini'),
1.87 - os.path.join('addons', 'metamod')))
1.88 -job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'README.txt'),
1.89 - os.path.join('addons', 'metamod')))
1.90 -
1.91 -bincopies = []
1.92 -
1.93 -def AddNormalLibrary(name, dest):
1.94 - dest = os.path.join('addons', 'metamod', dest)
1.95 - bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
1.96 - pdb_list.append(name + '\\' + name + '.pdb')
1.97 -
1.98 -def AddHL2Library(name, dest):
1.99 - for i in MMS.sdkInfo:
1.100 - sdk = MMS.sdkInfo[i]
1.101 - if AMBuild.target['platform'] not in sdk['platform']:
1.102 - continue
1.103 - AddNormalLibrary(name + '.' + sdk['ext'], dest)
1.104 +builder.AddCopy(os.path.join(builder.sourcePath, 'support', 'metamod.vdf'), addons_folder)
1.105 +builder.AddCopy(os.path.join(builder.sourcePath, 'support', 'metaplugins.ini'), metamod_folder)
1.106 +builder.AddCopy(os.path.join(builder.sourcePath, 'support', 'README.txt'), metamod_folder)
1.107
1.108 pdb_list = []
1.109 +for task in MMS.binaries:
1.110 + builder.AddCopy(task.binary, bin_folder)
1.111
1.112 -# Copy loader binaries
1.113 -AddNormalLibrary('server', 'bin')
1.114 -if AMBuild.target['platform'] == 'linux':
1.115 - AddNormalLibrary('server_i486', 'bin')
1.116 -
1.117 -AddHL2Library('metamod', 'bin')
1.118 + if task.debug:
1.119 + pdb_list.extend(task.debug)
1.120
1.121 -job.AddCommandGroup(bincopies)
1.122 +# Generate PDB info.
1.123 +with open(os.path.join(builder.buildPath, 'pdblog.txt'), 'wt') as fp:
1.124 + for line in pdb_list:
1.125 + fp.write(line.path + '\n')
1.126
1.127 -if AMBuild.target['platform'] == 'windows':
1.128 - pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
1.129 - for pdb in pdb_list:
1.130 - pdblog.write(pdb + '\n')
1.131 - pdblog.close()
1.132 -