Updated symstore logic.
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', 'metamod', 'bin']]
73 job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
74 job.AddCommand(CreateFolders(folders))
77 job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'metaplugins.ini'),
78 os.path.join('addons', 'metamod')))
79 job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'README.txt'),
80 os.path.join('addons', 'metamod')))
84 def AddNormalLibrary(name, dest):
85 dest = os.path.join('addons', 'metamod', dest)
86 bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
87 pdb_list.append(name + '\\' + name + '.pdb')
89 def AddHL2Library(name, dest):
92 if AMBuild.target['platform'] not in sdk['platform']:
94 AddNormalLibrary(name + '.' + sdk['ext'], dest)
98 # Copy loader binaries
99 AddNormalLibrary('server', 'bin')
100 if AMBuild.target['platform'] == 'linux':
101 AddNormalLibrary('server_i486', 'bin')
103 AddHL2Library('metamod', 'bin')
105 job.AddCommandGroup(bincopies)
107 if AMBuild.target['platform'] == 'windows':
108 pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
110 pdblog.write(pdb + '\n')