Remove the need for SDK's. Update AMBuild scripts to AMBuild2. Fix shutdown crash. Update gamedata for testing. General code fixups.

This commit is contained in:
Dr!fter
2014-08-19 13:14:48 -04:00
parent 6c0a1b3dcb
commit 0f64a45a2b
26 changed files with 602 additions and 1869 deletions
+25 -108
View File
@@ -1,115 +1,32 @@
# vim: set ts=2 sw=2 tw=99 noet ft=python:
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
import os
import shutil
import ambuild.osutil as osutil
from ambuild.command import Command
job = AMBuild.AddJob('package')
builder.SetBuildFolder('package')
class DestroyPath(Command):
def __init__(self, folder):
Command.__init__(self)
self.folder = folder
folder_list = [
'addons/sourcemod/gamedata',
'addons/sourcemod/extensions',
'addons/sourcemod/scripting',
'addons/sourcemod/scripting/include',
]
def destroy(self, path):
entries = os.listdir(path)
for entry in entries:
newpath = os.path.join(path, entry)
if os.path.isdir(newpath):
self.destroy(newpath)
os.rmdir(newpath)
elif os.path.isfile(newpath):
os.remove(newpath)
# Create the distribution folder hierarchy.
folder_map = {}
for folder in folder_list:
norm_folder = os.path.normpath(folder)
folder_map[folder] = builder.AddFolder(norm_folder)
def run(self, runner, job):
runner.PrintOut('rm -rf {0}/*'.format(self.folder))
self.destroy(self.folder)
builder.AddCopy(DHooks.task.binary, folder_map['addons/sourcemod/extensions'])
class CreateFolders(Command):
def __init__(self, folders):
Command.__init__(self)
self.folders = folders
def run(self, runner, job):
for folder in self.folders:
path = os.path.join(*folder)
runner.PrintOut('mkdir {0}'.format(path))
os.makedirs(path)
#Shallow folder copy
class CopyFolder(Command):
def __init__(self, fromList, toList, excludes = []):
Command.__init__(self)
self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList)
self.toPath = os.path.join(*toList)
self.excludes = excludes
def run(self, runner, job):
entries = os.listdir(self.fromPath)
for entry in entries:
if entry in self.excludes:
continue
path = os.path.join(self.fromPath, entry)
if not os.path.isfile(path):
continue
runner.PrintOut('copy {0} to {1}'.format(path, self.toPath))
shutil.copy(path, self.toPath)
#Single file copy
class CopyFile(Command):
def __init__(self, fromFile, toPath):
Command.__init__(self)
self.fromFile = fromFile
self.toPath = toPath
def run(self, runner, job):
runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath))
shutil.copy(self.fromFile, self.toPath)
folders = [
['addons', 'sourcemod', 'extensions'],
['addons', 'sourcemod', 'scripting', 'include'],
['addons', 'sourcemod', 'gamedata'],
]
#Setup
job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
job.AddCommand(CreateFolders(folders))
#Copy Files
job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'sourcemod', 'scripting', 'include', 'dhooks.inc'),
os.path.join('addons', 'sourcemod', 'scripting', 'include')))
job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'sourcemod', 'scripting', 'dhooks-test.sp'),
os.path.join('addons', 'sourcemod', 'scripting')))
job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'sourcemod', 'gamedata', 'dhooks-test.games.txt'),
os.path.join('addons', 'sourcemod', 'gamedata')))
bincopies = []
def AddNormalLibrary(name, dest):
dest = os.path.join('addons', 'sourcemod', dest)
bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
#pdb_list.append(name + '\\' + name + '.pdb')
def AddHL2Library(name, dest):
for i in SM.sdkInfo:
sdk = SM.sdkInfo[i]
if AMBuild.target['platform'] not in sdk['platform']:
continue
AddNormalLibrary(name + '.ext.' + sdk['ext'], dest)
#pdb_list = []
AddHL2Library('dhooks', 'extensions')
job.AddCommandGroup(bincopies)
#if AMBuild.target['platform'] == 'windows':
# pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
# for pdb in pdb_list:
# pdblog.write(pdb + '\n')
# pdblog.close()
# Do all straight-up file copies from the source tree.
def CopyFiles(src, dest, files):
if not dest:
dest = src
dest_entry = folder_map[dest]
for source_file in files:
source_path = os.path.join(builder.sourcePath, src, source_file)
builder.AddCopy(source_path, dest_entry)
CopyFiles('sourcemod/scripting', 'addons/sourcemod/scripting', ['dhooks-test.sp'])
CopyFiles('sourcemod/scripting/include', 'addons/sourcemod/scripting/include', ['dhooks.inc'])
CopyFiles('sourcemod/gamedata', 'addons/sourcemod/gamedata', ['dhooks-test.games.txt'])
+6 -5
View File
@@ -10,12 +10,14 @@ require 'helpers.pm';
chdir('../../OUTPUT');
if ($^O eq "linux" || $^O eq "darwin") {
system("python3 build.py 2>&1");
} else {
system("C:\\Python31\\python.exe build.py 2>&1");
my $argn = $#ARGV + 1;
if ($argn > 0) {
$ENV{CC} = $ARGV[0];
$ENV{CXX} = $ARGV[0];
}
system("ambuild --no-color 2>&1");
if ($? != 0)
{
die "Build failed: $!\n";
@@ -24,4 +26,3 @@ else
{
exit(0);
}