Switch build infrastructure to Git.

This commit is contained in:
David Anderson 2014-05-25 01:53:58 -07:00
parent e20e4677df
commit 2e89d91a86
5 changed files with 92 additions and 60 deletions

View File

@ -3,16 +3,12 @@ import os, sys
class SDK(object): class SDK(object):
def __init__(self, sdk, ext, aDef, name, platform, dir): def __init__(self, sdk, ext, aDef, name, platform, dir):
if dir == 'ep1': self.folder = 'hl2sdk-' + dir
folder = 'hl2sdk'
else:
folder = 'hl2sdk-' + dir
self.envvar = sdk self.envvar = sdk
self.ext = ext self.ext = ext
self.code = aDef self.code = aDef
self.define = name self.define = name
self.platform = platform self.platform = platform
self.folder = folder # Default folder name.
self.name = dir self.name = dir
self.path = None # Actual path self.path = None # Actual path
@ -21,15 +17,15 @@ WinLinux = ['windows', 'linux']
WinLinuxMac = ['windows', 'linux', 'mac'] WinLinuxMac = ['windows', 'linux', 'mac']
PossibleSDKs = { PossibleSDKs = {
'ep1': SDK('HL2SDK', '1.ep1', '1', 'EPISODEONE', WinLinux, 'ep1'), 'ep1': SDK('HL2SDK', '1.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
'ep2': SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'ob'), 'ep2': SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'orangebox'),
'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'), 'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'), 'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'),
'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinuxMac, 'dods'), 'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinuxMac, 'dods'),
'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinuxMac, '2013'), 'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinuxMac, 'sdk2013'),
'tf2': SDK('HL2SDKTF2', '2.tf2', '10', 'TF2', WinLinuxMac, 'tf2'), 'tf2': SDK('HL2SDKTF2', '2.tf2', '10', 'TF2', WinLinuxMac, 'tf2'),
'l4d': SDK('HL2SDKL4D', '2.l4d', '11', 'LEFT4DEAD', WinLinuxMac, 'l4d'), 'l4d': SDK('HL2SDKL4D', '2.l4d', '11', 'LEFT4DEAD', WinLinuxMac, 'l4d'),
'nd': SDK('HL2SDKND', '2.nd', '12', 'NUCLEARDAWN', WinLinuxMac, 'nd'), 'nd': SDK('HL2SDKND', '2.nd', '12', 'NUCLEARDAWN', WinLinuxMac, 'nucleardawn'),
'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '14', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'), 'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '14', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'),
'darkm': SDK('HL2SDK-DARKM', '2.darkm', '2', 'DARKMESSIAH', WinOnly, 'darkm'), 'darkm': SDK('HL2SDK-DARKM', '2.darkm', '2', 'DARKMESSIAH', WinOnly, 'darkm'),
'swarm': SDK('HL2SDK-SWARM', '2.swarm', '15', 'ALIENSWARM', WinOnly, 'swarm'), 'swarm': SDK('HL2SDK-SWARM', '2.swarm', '15', 'ALIENSWARM', WinOnly, 'swarm'),
@ -310,7 +306,7 @@ class SMConfig(object):
def HL2Compiler(self, context, sdk): def HL2Compiler(self, context, sdk):
compiler = self.ExtCompiler(context) compiler = self.ExtCompiler(context)
if sdk.name == 'ep1': if sdk.name == 'episode1':
mms_path = os.path.join(self.mms_root, 'core-legacy') mms_path = os.path.join(self.mms_root, 'core-legacy')
else: else:
mms_path = os.path.join(self.mms_root, 'core') mms_path = os.path.join(self.mms_root, 'core')
@ -330,7 +326,7 @@ class SMConfig(object):
['public', 'tier0'], ['public', 'tier0'],
['public', 'tier1'] ['public', 'tier1']
] ]
if sdk.name == 'ep1' or sdk.name == 'darkm': if sdk.name == 'episode1' or sdk.name == 'darkm':
paths.append(['public', 'dlls']) paths.append(['public', 'dlls'])
paths.append(['game_shared']) paths.append(['game_shared'])
else: else:
@ -341,7 +337,7 @@ class SMConfig(object):
compiler.defines += ['SOURCE_ENGINE=' + sdk.code] compiler.defines += ['SOURCE_ENGINE=' + sdk.code]
if sdk.name == '2013' and compiler.cxx.behavior == 'gcc': if sdk.name == 'sdk2013' and compiler.cxx.behavior == 'gcc':
# The 2013 SDK already has these in public/tier0/basetypes.h # The 2013 SDK already has these in public/tier0/basetypes.h
compiler.defines.remove('stricmp=strcasecmp') compiler.defines.remove('stricmp=strcasecmp')
compiler.defines.remove('_stricmp=strcasecmp') compiler.defines.remove('_stricmp=strcasecmp')
@ -358,7 +354,7 @@ class SMConfig(object):
if sdk.name in ['blade', 'insurgency', 'csgo', 'dota']: if sdk.name in ['blade', 'insurgency', 'csgo', 'dota']:
compiler.defines += ['NETWORK_VARS_ENABLED'] compiler.defines += ['NETWORK_VARS_ENABLED']
if sdk.name in ['css', 'hl2dm', 'dods', '2013', 'tf2', 'l4d', 'nd', 'l4d2', 'dota']: if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'tf2', 'l4d', 'nucleardawn', 'l4d2', 'dota']:
if builder.target_platform in ['linux', 'mac']: if builder.target_platform in ['linux', 'mac']:
compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE'] compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE']
@ -375,20 +371,20 @@ class SMConfig(object):
compiler = self.HL2Compiler(context, sdk) compiler = self.HL2Compiler(context, sdk)
if builder.target_platform == 'linux': if builder.target_platform == 'linux':
if sdk.name == 'ep1': if sdk.name == 'episode1':
lib_folder = os.path.join(sdk.path, 'linux_sdk') lib_folder = os.path.join(sdk.path, 'linux_sdk')
elif sdk.name == '2013': elif sdk.name == 'sdk2013':
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32') lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32')
else: else:
lib_folder = os.path.join(sdk.path, 'lib', 'linux') lib_folder = os.path.join(sdk.path, 'lib', 'linux')
elif builder.target_platform == 'mac': elif builder.target_platform == 'mac':
if sdk.name == '2013': if sdk.name == 'sdk2013':
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32') lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32')
else: else:
lib_folder = os.path.join(sdk.path, 'lib', 'mac') lib_folder = os.path.join(sdk.path, 'lib', 'mac')
if builder.target_platform in ['linux', 'mac']: if builder.target_platform in ['linux', 'mac']:
if sdk.name == '2013': if sdk.name == 'sdk2013':
compiler.postlink += [ compiler.postlink += [
compiler.Dep(os.path.join(lib_folder, 'tier1.a')), compiler.Dep(os.path.join(lib_folder, 'tier1.a')),
compiler.Dep(os.path.join(lib_folder, 'mathlib.a')) compiler.Dep(os.path.join(lib_folder, 'mathlib.a'))
@ -407,7 +403,7 @@ class SMConfig(object):
dynamic_libs = [] dynamic_libs = []
if builder.target_platform == 'linux': if builder.target_platform == 'linux':
compiler.linkflags[0:0] = ['-lm'] compiler.linkflags[0:0] = ['-lm']
if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', '2013', 'nd', 'l4d2']: if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'nucleardawn', 'l4d2']:
dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so'] dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
elif sdk.name in ['l4d', 'blade', 'insurgency', 'csgo', 'dota']: elif sdk.name in ['l4d', 'blade', 'insurgency', 'csgo', 'dota']:
dynamic_libs = ['libtier0.so', 'libvstdlib.so'] dynamic_libs = ['libtier0.so', 'libvstdlib.so']

View File

@ -11,7 +11,7 @@ for sdk_name in SM.sdks:
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'), os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
] ]
if sdk.name != 'ep1': if sdk.name != 'episode1':
binary.compiler.defines += ['HOOKING_ENABLED'] binary.compiler.defines += ['HOOKING_ENABLED']
if binary.compiler.cxx.behavior == 'gcc': if binary.compiler.cxx.behavior == 'gcc':

View File

@ -16,11 +16,18 @@ outputs = [
os.path.join(builder.buildFolder, 'includes', 'version_auto.inc'), os.path.join(builder.buildFolder, 'includes', 'version_auto.inc'),
] ]
with open(os.path.join(builder.sourcePath, '.git', 'HEAD')) as fp:
git_state = fp.read().strip().split(':')[1].strip()
git_head_path = os.path.join(builder.sourcePath, '.git', git_state)
if not os.path.exists(git_head_path):
git_head_path = os.path.join(builder.sourcePath, '.git', 'HEAD')
sources = [ sources = [
os.path.join(builder.sourcePath, 'product.version'), os.path.join(builder.sourcePath, 'product.version'),
# This is a hack, but we need some way to only run this script when HG changes. # This is a hack, but we need some way to only run this script when Git changes.
os.path.join(builder.sourcePath, '.hg', 'dirstate'), git_head_path,
# The script source is a dependency, of course... # The script source is a dependency, of course...
argv[1] argv[1]

View File

@ -11,9 +11,19 @@ if len(argv) < 2:
SourceFolder = os.path.abspath(os.path.normpath(argv[0])) SourceFolder = os.path.abspath(os.path.normpath(argv[0]))
OutputFolder = os.path.normpath(argv[1]) OutputFolder = os.path.normpath(argv[1])
def get_hg_version(): class FolderChanger:
argv = ['hg', 'parent', '-R', SourceFolder] def __init__(self, folder):
self.old = os.getcwd()
self.new = folder
def __enter__(self):
if self.new:
os.chdir(self.new)
def __exit__(self, type, value, traceback):
os.chdir(self.old)
def run_and_return(argv):
# Python 2.6 doesn't have check_output. # Python 2.6 doesn't have check_output.
if hasattr(subprocess, 'check_output'): if hasattr(subprocess, 'check_output'):
text = subprocess.check_output(argv) text = subprocess.check_output(argv)
@ -26,14 +36,18 @@ def get_hg_version():
if rval: if rval:
raise subprocess.CalledProcessError(rval, argv) raise subprocess.CalledProcessError(rval, argv)
text = output.decode('utf8') text = output.decode('utf8')
return text.strip()
m = re.match('changeset:\s+(\d+):(.+)', text) def get_git_version():
if m == None: revision_count = run_and_return(['git', 'rev-list', '--count', 'HEAD'])
raise Exception('Could not determine repository version') revision_hash = run_and_return(['git', 'log', '--pretty=format:%h:%H', '-n', '1'])
return m.groups() shorthash, longhash = revision_hash.split(':')
return revision_count, shorthash, longhash
def output_version_headers(): def output_version_headers():
rev, cset = get_hg_version() with FolderChanger(SourceFolder):
count, shorthash, longhash = get_git_version()
with open(os.path.join(SourceFolder, 'product.version')) as fp: with open(os.path.join(SourceFolder, 'product.version')) as fp:
contents = fp.read() contents = fp.read()
@ -41,11 +55,12 @@ def output_version_headers():
if m == None: if m == None:
raise Exception('Could not detremine product version') raise Exception('Could not detremine product version')
major, minor, release, tag = m.groups() major, minor, release, tag = m.groups()
fullstring = "{0}.{1}.{2}".format(major, minor, release) product = "{0}.{1}.{2}".format(major, minor, release)
fullstring = product
if tag != "": if tag != "":
fullstring += "-{0}".format(tag) fullstring += "-{0}".format(tag)
if tag == "dev": if tag == "dev":
fullstring += "+{0}".format(rev) fullstring += "+{0}".format(shorthash)
with open(os.path.join(OutputFolder, 'sourcemod_version_auto.h'), 'w') as fp: with open(os.path.join(OutputFolder, 'sourcemod_version_auto.h'), 'w') as fp:
fp.write(""" fp.write("""
@ -53,19 +68,18 @@ def output_version_headers():
#define _SOURCEMOD_AUTO_VERSION_INFORMATION_H_ #define _SOURCEMOD_AUTO_VERSION_INFORMATION_H_
#define SM_BUILD_TAG \"{0}\" #define SM_BUILD_TAG \"{0}\"
#define SM_BUILD_REV \"{1}\" #define SM_BUILD_CSET \"{1}\"
#define SM_BUILD_CSET \"{2}\" #define SM_BUILD_MAJOR \"{2}\"
#define SM_BUILD_MAJOR \"{3}\" #define SM_BUILD_MINOR \"{3}\"
#define SM_BUILD_MINOR \"{4}\" #define SM_BUILD_RELEASE \"{4}\"
#define SM_BUILD_RELEASE \"{5}\"
#define SM_BUILD_UNIQUEID SM_BUILD_REV \":\" SM_BUILD_CSET #define SM_BUILD_UNIQUEID SM_BUILD_REV \":\" SM_BUILD_CSET
#define SM_VERSION_STRING \"{6}\" #define SM_VERSION_STRING \"{5}\"
#define SM_VERSION_FILE {7},{8},{9},0 #define SM_VERSION_FILE {6},{7},{8},0
#endif /* _SOURCEMOD_AUTO_VERSION_INFORMATION_H_ */ #endif /* _SOURCEMOD_AUTO_VERSION_INFORMATION_H_ */
""".format(tag, rev, cset, major, minor, release, fullstring, major, minor, release)) """.format(tag, shorthash, major, minor, release, fullstring, major, minor, release))
with open(os.path.join(OutputFolder, 'version_auto.inc'), 'w') as fp: with open(os.path.join(OutputFolder, 'version_auto.inc'), 'w') as fp:
fp.write(""" fp.write("""
@ -75,13 +89,12 @@ def output_version_headers():
#define _auto_version_included #define _auto_version_included
#define SOURCEMOD_V_TAG \"{0}\" #define SOURCEMOD_V_TAG \"{0}\"
#define SOURCEMOD_V_REV {1} #define SOURCEMOD_V_CSET \"{1}\"
#define SOURCEMOD_V_CSET \"{2}\" #define SOURCEMOD_V_MAJOR {2}
#define SOURCEMOD_V_MAJOR {3} #define SOURCEMOD_V_MINOR {3}
#define SOURCEMOD_V_MINOR {4} #define SOURCEMOD_V_RELEASE {4}
#define SOURCEMOD_V_RELEASE {5}
#define SOURCEMOD_VERSION \"{6}\" #define SOURCEMOD_VERSION \"{5}\"
""".format(tag, rev, cset, major, minor, release, fullstring)) """.format(tag, shorthash, major, minor, release, fullstring))
output_version_headers() output_version_headers()

View File

@ -17,7 +17,7 @@ elif [ `uname` != "Linux" ] && [ -n "${COMSPEC:+1}" ]; then
decomp=unzip decomp=unzip
fi fi
if [ ! -d "sourcemod-central" ]; then if [ ! -d "sourcemod" ]; then
if [ ! -d "sourcemod-1.5" ]; then if [ ! -d "sourcemod-1.5" ]; then
echo "Could not find a SourceMod repository; make sure you aren't running this script inside it." echo "Could not find a SourceMod repository; make sure you aren't running this script inside it."
exit 1 exit 1
@ -54,29 +54,32 @@ fi
checkout () checkout ()
{ {
if [ ! -d "$name" ]; then if [ ! -d "$name" ]; then
hg clone https://hg.alliedmods.net/$path/$name git clone $repo -b $branch $name
if [ -n "$origin" ]; then
cd $name
git remote rm origin
git remote add origin $origin
cd ..
fi
else else
cd $name cd $name
sed -i 's/http:/https:/g' .hg/hgrc git checkout $branch
hg pull -u git pull origin $branch
cd .. cd ..
fi fi
} }
name=mmsource-1.10 name=mmsource-1.10
path=releases branch=1.10-dev
repo="https://github.com/alliedmodders/metamod-source"
origin=
checkout checkout
sdks=( csgo hl2dm nd l4d2 dods l4d css tf2 insurgency 2013 dota ) sdks=( csgo hl2dm nucleardawn l4d2 dods l4d css tf2 insurgency sdk2013 dota )
if [ $ismac -eq 0 ]; then if [ $ismac -eq 0 ]; then
# Checkout original HL2 SDK on Windows or Linux
name=hl2sdk
path=hl2sdks
checkout
# Add these SDKs for Windows or Linux # Add these SDKs for Windows or Linux
sdks+=( ob blade ) sdks+=( orangebox blade episode1 )
# Add more SDKs for Windows only # Add more SDKs for Windows only
if [ $iswin -eq 1 ]; then if [ $iswin -eq 1 ]; then
@ -84,17 +87,30 @@ if [ $ismac -eq 0 ]; then
fi fi
fi fi
# Check out a local copy as a proxy.
if [ ! -d "hl2sdk-proxy-repo" ]; then
git clone --mirror https://github.com/alliedmodders/hl2sdk hl2sdk-proxy-repo
else
cd hl2sdk-proxy-repo
git fetch
cd ..
fi
for sdk in "${sdks[@]}" for sdk in "${sdks[@]}"
do do
repo=hl2sdk-proxy-repo
origin="https://github.com/alliedmodders/hl2sdk"
name=hl2sdk-$sdk name=hl2sdk-$sdk
path=hl2sdks branch=$sdk
checkout checkout
done done
`python -c "import ambuild2"` `python -c "import ambuild2"`
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
name= repo="https://github.com/alliedmodders/ambuild"
path=ambuild origin=
branch=master
name=ambuild
checkout checkout
cd ambuild cd ambuild