AMBuild.dist
author David Anderson <dvander@alliedmods.net>
Sun Jan 27 17:34:30 2013 -0800 (2013-01-27)
changeset 261 219b49bf4a03
parent 106 8534dbfb8c1a
permissions -rw-r--r--
Add support for importing enum types and enum values (as constexprs).
[email protected]
     1
# vim: set ts=2 sw=2 tw=99 noet ft=python: 
[email protected]
     2
# 
[email protected]
     3
# Copyright (C) 2004-2012 David Anderson
[email protected]
     4
# 
[email protected]
     5
# This file is part of SourcePawn.
[email protected]
     6
# 
[email protected]
     7
# SourcePawn is free software: you can redistribute it and/or modify it under
[email protected]
     8
# the terms of the GNU General Public License as published by the Free
[email protected]
     9
# Software Foundation, either version 3 of the License, or (at your option)
[email protected]
    10
# any later version.
[email protected]
    11
# 
[email protected]
    12
# SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
[email protected]
    13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
[email protected]
    14
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
[email protected]
    15
# 
[email protected]
    16
# You should have received a copy of the GNU General Public License along with
[email protected]
    17
# SourcePawn. If not, see http://www.gnu.org/licenses/.
[email protected]
    18
#
[email protected]
    19
import os
[email protected]
    20
import os.path
[email protected]
    21
import shutil
[email protected]
    22
import ambuild.osutil as osutil
[email protected]
    23
from ambuild.command import Command
[email protected]
    24
[email protected]
    25
job = AMBuild.AddJob('dist')
[email protected]
    26
[email protected]
    27
# Single file copy
[email protected]
    28
class CopyFile(Command):
[email protected]
    29
	def __init__(self, filename, fromPath, toPath):
[email protected]
    30
		Command.__init__(self)
[email protected]
    31
		self.filename = filename
[email protected]
    32
		self.fromPath = os.path.join(fromPath, filename)
[email protected]
    33
		self.toPath = toPath
[email protected]
    34
[email protected]
    35
	def shouldCopy(self):
[email protected]
    36
		tofile = os.path.join(self.toPath, self.filename)
[email protected]
    37
		if not osutil.FileExists(tofile):
[email protected]
    38
			return True
[email protected]
    39
		return osutil.IsFileNewer(self.fromPath, tofile)
[email protected]
    40
[email protected]
    41
	def run(self, runner, job):
[email protected]
    42
		if not self.shouldCopy():
[email protected]
    43
			return
[email protected]
    44
		runner.PrintOut('copy {0} to {1}'.format(self.fromPath, self.toPath))
[email protected]
    45
		shutil.copy(self.fromPath, self.toPath)
[email protected]
    46
[email protected]
    47
# Create a folder
[email protected]
    48
class CreateFolder(Command):
[email protected]
    49
	def __init__(self, folder):
[email protected]
    50
		Command.__init__(self)
[email protected]
    51
		self.folder = folder
[email protected]
    52
[email protected]
    53
	def run(self, runner, job):
[email protected]
    54
		runner.PrintOut('mkdir {0}'.format(self.folder))
[email protected]
    55
		os.makedirs(self.folder)
[email protected]
    56
[email protected]
    57
def AddCopy(job, filename, fromPath, toPath):
[email protected]
    58
	job.AddCommand(CopyFile(filename, fromPath, toPath))
[email protected]
    59
[email protected]
    60
def AddFolder(job, folder):
[email protected]
    61
	if not os.path.exists(os.path.join(AMBuild.outputFolder, 'dist', folder)):
[email protected]
    62
		job.AddCommand(CreateFolder(folder))
[email protected]
    63
[email protected]
    64
libkeima = osutil.StaticLibPrefix() + 'keima' + osutil.StaticLibSuffix()
[email protected]
    65
spshell = 'spshell' + osutil.ExecutableSuffix()
[email protected]
    66
[email protected]
    67
AddFolder(job, 'include')
[email protected]
    68
AddFolder(job, 'lib')
[email protected]
    69
AddFolder(job, 'bin')
[email protected]
    70
[email protected]
    71
AddCopy(job,
[email protected]
    72
        'keima.h',
[email protected]
    73
        os.path.join(AMBuild.sourceFolder, 'include'),
[email protected]
    74
        'include')
[email protected]
    75
AddCopy(job,
[email protected]
    76
        'keima_util.h',
[email protected]
    77
        os.path.join(AMBuild.sourceFolder, 'include'),
[email protected]
    78
        'include')
[email protected]
    79
AddCopy(job,
[email protected]
    80
        libkeima,
[email protected]
    81
        os.path.join(AMBuild.outputFolder, 'keima'),
[email protected]
    82
        'lib')
[email protected]
    83
AddCopy(job,
[email protected]
    84
        spshell,
[email protected]
    85
        os.path.join(AMBuild.outputFolder, 'spshell'),
[email protected]
    86
        'bin')
[email protected]
    87