Merge pull request from alliedmodders/git-mv

Switch build infrastructure to Git.
This commit is contained in:
David Anderson 2014-05-25 11:03:23 -07:00
commit 5681b99fd8
9 changed files with 107 additions and 67 deletions

View File

@ -3,16 +3,12 @@ import os, sys
class SDK(object):
def __init__(self, sdk, ext, aDef, name, platform, dir):
if dir == 'ep1':
folder = 'hl2sdk'
else:
folder = 'hl2sdk-' + dir
self.folder = 'hl2sdk-' + dir
self.envvar = sdk
self.ext = ext
self.code = aDef
self.define = name
self.platform = platform
self.folder = folder # Default folder name.
self.name = dir
self.path = None # Actual path
@ -21,15 +17,15 @@ WinLinux = ['windows', 'linux']
WinLinuxMac = ['windows', 'linux', 'mac']
PossibleSDKs = {
'ep1': SDK('HL2SDK', '1.ep1', '1', 'EPISODEONE', WinLinux, 'ep1'),
'ep2': SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'ob'),
'episode1': SDK('HL2SDK', '1.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
'ep2': SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'orangebox'),
'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'),
'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'),
'l4d': SDK('HL2SDKL4D', '2.l4d', '11', 'LEFT4DEAD', WinLinuxMac, 'l4d'),
'nd': SDK('HL2SDKND', '2.nd', '12', 'NUCLEARDAWN', WinLinuxMac, 'nd'),
'nucleardawn': SDK('HL2SDKND', '2.nd', '12', 'NUCLEARDAWN', WinLinuxMac, 'nucleardawn'),
'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '14', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'),
'darkm': SDK('HL2SDK-DARKM', '2.darkm', '2', 'DARKMESSIAH', WinOnly, 'darkm'),
'swarm': SDK('HL2SDK-SWARM', '2.swarm', '15', 'ALIENSWARM', WinOnly, 'swarm'),
@ -310,7 +306,7 @@ class SMConfig(object):
def HL2Compiler(self, context, sdk):
compiler = self.ExtCompiler(context)
if sdk.name == 'ep1':
if sdk.name == 'episode1':
mms_path = os.path.join(self.mms_root, 'core-legacy')
else:
mms_path = os.path.join(self.mms_root, 'core')
@ -330,7 +326,7 @@ class SMConfig(object):
['public', 'tier0'],
['public', 'tier1']
]
if sdk.name == 'ep1' or sdk.name == 'darkm':
if sdk.name == 'episode1' or sdk.name == 'darkm':
paths.append(['public', 'dlls'])
paths.append(['game_shared'])
else:
@ -341,7 +337,7 @@ class SMConfig(object):
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
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']:
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']:
compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE']
@ -375,20 +371,20 @@ class SMConfig(object):
compiler = self.HL2Compiler(context, sdk)
if builder.target_platform == 'linux':
if sdk.name == 'ep1':
if sdk.name == 'episode1':
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')
else:
lib_folder = os.path.join(sdk.path, 'lib', 'linux')
elif builder.target_platform == 'mac':
if sdk.name == '2013':
if sdk.name == 'sdk2013':
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32')
else:
lib_folder = os.path.join(sdk.path, 'lib', 'mac')
if builder.target_platform in ['linux', 'mac']:
if sdk.name == '2013':
if sdk.name == 'sdk2013':
compiler.postlink += [
compiler.Dep(os.path.join(lib_folder, 'tier1.a')),
compiler.Dep(os.path.join(lib_folder, 'mathlib.a'))
@ -407,7 +403,7 @@ class SMConfig(object):
dynamic_libs = []
if builder.target_platform == 'linux':
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']
elif sdk.name in ['l4d', 'blade', 'insurgency', 'csgo', 'dota']:
dynamic_libs = ['libtier0.so', 'libvstdlib.so']

View File

@ -340,7 +340,10 @@ void RootConsoleMenu::OnRootConsoleCommand(const char *cmdname, const CCommand &
ConsolePrint(" SourcePawn Engine: %s (build %s NO JIT)", g_pSourcePawn2->GetEngineName(), g_pSourcePawn2->GetVersionString());
ConsolePrint(" SourcePawn API: v1 = %d, v2 = %d", g_pSourcePawn->GetEngineAPIVersion(), g_pSourcePawn2->GetAPIVersion());
ConsolePrint(" Compiled on: %s %s", __DATE__, __TIME__);
ConsolePrint(" Build ID: %s", SOURCEMOD_BUILD_ID);
#if defined(SM_GENERATED_BUILD)
ConsolePrint(" Built from: https://github.com/alliedmodders/sourcemod/commit/%s", SOURCEMOD_SHA);
#endif
ConsolePrint(" Build ID: %s:%s", SOURCEMOD_LOCAL_REV, SOURCEMOD_SHA);
ConsolePrint(" http://www.sourcemod.net/");
}
}

View File

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

View File

@ -49,13 +49,13 @@
# endif
#else
#define SM_BUILD_TAG "manual"
#define SM_BUILD_REV "0"
#define SM_BUILD_LOCAL_REV "0"
#define SM_BUILD_CSET "0"
#define SM_BUILD_MAJOR "1"
#define SM_BUILD_MINOR "6"
#define SM_BUILD_RELEASE "0"
#define SM_BUILD_UNIQUEID SM_BUILD_REV ":" SM_BUILD_CSET
#define SM_BUILD_UNIQUEID SM_BUILD_LOCAL_REV ":" SM_BUILD_CSET
#define SM_VERSION_STRING SM_BUILD_MAJOR "." SM_BUILD_MINOR "." SM_BUILD_RELEASE "-" SM_BUILD_TAG
#define SM_VERSION_FILE 1,6,0,0

View File

@ -16,11 +16,18 @@ outputs = [
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 = [
os.path.join(builder.sourcePath, 'product.version'),
# This is a hack, but we need some way to only run this script when HG changes.
os.path.join(builder.sourcePath, '.hg', 'dirstate'),
# This is a hack, but we need some way to only run this script when Git changes.
git_head_path,
# The script source is a dependency, of course...
argv[1]

View File

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

View File

@ -17,7 +17,7 @@ elif [ `uname` != "Linux" ] && [ -n "${COMSPEC:+1}" ]; then
decomp=unzip
fi
if [ ! -d "sourcemod-central" ]; then
if [ ! -d "sourcemod" ]; then
if [ ! -d "sourcemod-1.5" ]; then
echo "Could not find a SourceMod repository; make sure you aren't running this script inside it."
exit 1
@ -54,29 +54,32 @@ fi
checkout ()
{
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
cd $name
sed -i 's/http:/https:/g' .hg/hgrc
hg pull -u
git checkout $branch
git pull origin $branch
cd ..
fi
}
name=mmsource-1.10
path=releases
branch=1.10-dev
repo="https://github.com/alliedmodders/metamod-source"
origin=
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
# Checkout original HL2 SDK on Windows or Linux
name=hl2sdk
path=hl2sdks
checkout
# Add these SDKs for Windows or Linux
sdks+=( ob blade )
sdks+=( orangebox blade episode1 )
# Add more SDKs for Windows only
if [ $iswin -eq 1 ]; then
@ -84,17 +87,30 @@ if [ $ismac -eq 0 ]; then
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[@]}"
do
repo=hl2sdk-proxy-repo
origin="https://github.com/alliedmodders/hl2sdk"
name=hl2sdk-$sdk
path=hl2sdks
branch=$sdk
checkout
done
`python -c "import ambuild2"`
if [ $? -eq 1 ]; then
name=
path=ambuild
repo="https://github.com/alliedmodders/ambuild"
origin=
branch=master
name=ambuild
checkout
cd ambuild

View File

@ -29,6 +29,7 @@
#include <sourcemod_version.h>
#include <versionlib.h>
const char *SOURCEMOD_BUILD_ID = SM_BUILD_UNIQUEID;
const char *SOURCEMOD_LOCAL_REV = SM_BUILD_LOCAL_REV;
const char *SOURCEMOD_SHA = SM_BUILD_CSET;
const char *SOURCEMOD_VERSION = SM_VERSION_STRING;
const char *SOURCEMOD_BUILD_TIME = __DATE__ " " __TIME__;

View File

@ -32,7 +32,8 @@
#if !defined(SM_USE_VERSIONLIB)
// These get defined in sourcemod_version.h since
// versionlib does not use versionlib.
# undef SOURCEMOD_BUILD_ID
# undef SOURCEMOD_LOCAL_REV
# undef SOURCEMOD_CSET
# undef SOURCEMOD_VERSION
# undef SOURCEMOD_BUILD_TIME
#endif
@ -42,7 +43,8 @@
#else
# define EXTERN_C extern
#endif
EXTERN_C const char *SOURCEMOD_BUILD_ID;
EXTERN_C const char *SOURCEMOD_LOCAL_REV;
EXTERN_C const char *SOURCEMOD_SHA;
EXTERN_C const char *SOURCEMOD_VERSION;
EXTERN_C const char *SOURCEMOD_BUILD_TIME;