Push build.
1 # vim: set ts=2 sw=2 tw=99 noet ft=python:
3 # Copyright (C) 2004-2012 David Anderson
5 # This file is part of SourcePawn.
7 # SourcePawn is free software: you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation, either version 3 of the License, or (at your option)
12 # SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # SourcePawn. If not, see http://www.gnu.org/licenses/.
22 import ambuild.osutil as osutil
23 from ambuild.command import Command
25 job = AMBuild.AddJob('dist')
28 class CopyFile(Command):
29 def __init__(self, filename, fromPath, toPath):
30 Command.__init__(self)
31 self.fromPath = os.path.join(fromPath, filename)
34 def run(self, runner, job):
35 runner.PrintOut('copy {0} to {1}'.format(self.fromPath, self.toPath))
36 shutil.copy(self.fromPath, self.toPath)
39 class CreateFolder(Command):
40 def __init__(self, folder):
41 Command.__init__(self)
44 def run(self, runner, job):
45 runner.PrintOut('mkdir {0}'.format(self.folder))
46 os.makedirs(self.folder)
49 def ShouldCopy(filename, fromPath, toPath):
50 fromfile = os.path.join(fromPath, filename)
51 tofile = os.path.join(AMBuild.outputFolder, 'dist', toPath, filename)
52 if not osutil.FileExists(tofile):
54 return osutil.IsFileNewer(fromfile, tofile)
56 def AddCopy(job, filename, fromPath, toPath):
57 if not ShouldCopy(filename, fromPath, toPath):
59 job.AddCommand(CopyFile(filename, fromPath, toPath))
61 def AddFolder(job, folder):
62 if not os.path.exists(os.path.join(AMBuild.outputFolder, 'dist', folder)):
63 job.AddCommand(CreateFolder(folder))
65 libkeima = osutil.StaticLibPrefix() + 'keima' + osutil.StaticLibSuffix()
66 spshell = 'spshell' + osutil.ExecutableSuffix()
68 AddFolder(job, 'include')
74 os.path.join(AMBuild.sourceFolder, 'include'),
78 os.path.join(AMBuild.sourceFolder, 'include'),
82 os.path.join(AMBuild.outputFolder, 'keima'),
86 os.path.join(AMBuild.outputFolder, 'spshell'),