Basic support for parsing and creating types from structure syntax.
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.filename = filename
32 self.fromPath = os.path.join(fromPath, filename)
36 tofile = os.path.join(self.toPath, self.filename)
37 if not osutil.FileExists(tofile):
39 return osutil.IsFileNewer(self.fromPath, tofile)
41 def run(self, runner, job):
42 if not self.shouldCopy():
44 runner.PrintOut('copy {0} to {1}'.format(self.fromPath, self.toPath))
45 shutil.copy(self.fromPath, self.toPath)
48 class CreateFolder(Command):
49 def __init__(self, folder):
50 Command.__init__(self)
53 def run(self, runner, job):
54 runner.PrintOut('mkdir {0}'.format(self.folder))
55 os.makedirs(self.folder)
57 def AddCopy(job, filename, fromPath, toPath):
58 job.AddCommand(CopyFile(filename, fromPath, toPath))
60 def AddFolder(job, folder):
61 if not os.path.exists(os.path.join(AMBuild.outputFolder, 'dist', folder)):
62 job.AddCommand(CreateFolder(folder))
64 libkeima = osutil.StaticLibPrefix() + 'keima' + osutil.StaticLibSuffix()
65 spshell = 'spshell' + osutil.ExecutableSuffix()
67 AddFolder(job, 'include')
73 os.path.join(AMBuild.sourceFolder, 'include'),
77 os.path.join(AMBuild.sourceFolder, 'include'),
81 os.path.join(AMBuild.outputFolder, 'keima'),
85 os.path.join(AMBuild.outputFolder, 'spshell'),