Permalink
Browse files

Backport Git build to 1.10 branch.

  • Loading branch information...
dvander committed May 26, 2014
1 parent 190fab2 commit 09d1f564926ccea25ab5de3ceccac05bf7932062
View
@@ -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'),
@@ -237,7 +233,7 @@ class MMSConfig(object):
['public', 'mathlib'],
['public', 'vstdlib'],
['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:
@@ -247,7 +243,7 @@ class MMSConfig(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')
@@ -259,7 +255,7 @@ class MMSConfig(object):
else:
compiler.defines += ['COMPILER_GCC']
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']
@@ -293,20 +289,20 @@ class MMSConfig(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'))]
else:
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'tier1_i486.a'))]
@@ -319,7 +315,7 @@ class MMSConfig(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
@@ -1,8 +1,8 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
import os
if 'ep1' in MMS.sdks:
sdk = MMS.sdks['ep1']
if 'episode1' in MMS.sdks:
sdk = MMS.sdks['episode1']
name = 'metamod.' + sdk.ext
binary = MMS.HL2Library(builder, name, sdk)
binary.sources += [
@@ -142,7 +142,10 @@ CON_COMMAND(meta, "Metamod:Source Menu")
return;
} else if (strcmp(command, "version") == 0) {
CONMSG("Metamod:Source version %s\n", METAMOD_VERSION);
CONMSG("Build ID: %s\n", METAMOD_BUILD_ID);
#if defined(MMS_GENERATED_BUILD)
CONMSG("Built from: https://github.com/alliedmodders/metamod-source/commit/%s\n", METAMOD_BUILD_SHA);
#endif
CONMSG("Build ID: %s:%s\n", METAMOD_BUILD_LOCAL_REV, METAMOD_BUILD_SHA);
if (g_GameDll.loaded)
{
CONMSG("Loaded As: GameDLL (gameinfo.txt)\n");
View
@@ -3,7 +3,7 @@ import os
for sdk_name in MMS.sdks:
sdk = MMS.sdks[sdk_name]
if sdk.name == 'ep1':
if sdk.name == 'episode1':
continue
name = 'metamod.' + sdk.ext
View
@@ -70,7 +70,10 @@ bool Command_Meta(IMetamodSourceCommandInfo *info)
else if (strcmp(command, "version") == 0)
{
CONMSG("Metamod:Source version %s\n", METAMOD_VERSION);
CONMSG("Build ID: %s\n", METAMOD_BUILD_ID);
#if defined(MMS_GENERATED_BUILD)
CONMSG("Built from: https://github.com/alliedmodders/metamod-source/commit/%s\n", METAMOD_BUILD_SHA);
#endif
CONMSG("Build ID: %s:%s\n", METAMOD_BUILD_LOCAL_REV, METAMOD_BUILD_SHA);
if (g_Metamod.IsLoadedAsGameDLL())
{
@@ -15,11 +15,18 @@ outputs = [
os.path.join(builder.buildFolder, 'includes', 'metamod_version_auto.h')
]
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]
@@ -11,9 +11,19 @@
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,33 +36,43 @@ 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_header():
rev, cset = get_hg_version()
with FolderChanger(SourceFolder):
count, shorthash, longhash = get_git_version()
with open(os.path.join(SourceFolder, 'product.version')) as fp:
productContents = fp.read()
m = re.match('(\d+)\.(\d+)\.(\d+)(.*)', productContents)
contents = fp.read()
m = re.match('(\d+)\.(\d+)\.(\d+)-?(.*)', contents)
if m == None:
raise Exception('Could not detremine product version')
major, minor, release, tag = m.groups()
if tag:
tag = '-' + tag
with open(os.path.join(OutputFolder, 'metamod_version_auto.h'), 'w') as fp:
fp.write("""#ifndef _METAMOD_AUTO_VERSION_INFORMATION_H_
#define _METAMOD_AUTO_VERSION_INFORMATION_H_
#define MMS_BUILD_STRING \"{0}\"
#define MMS_BUILD_UNIQUEID \"{1}:{2}\" MMS_BUILD_STRING
#define MMS_FULL_VERSION \"{3}.{4}.{5}\" MMS_BUILD_STRING
#define MMS_FILE_VERSION {6},{7},{8},0
#define MMS_BUILD_LOCAL_REV \"{5}\"
#define MMS_BUILD_SHA \"{1}\"
#define MMS_BUILD_UNIQUEID \"{5}:{1}\" MMS_BUILD_STRING
#define MMS_FULL_VERSION \"{2}.{3}.{4}\" MMS_BUILD_STRING
#define MMS_FILE_VERSION {2},{3},{4},0
#endif /* _METAMOD_AUTO_VERSION_INFORMATION_H_ */
""".format(tag, rev, cset, major, minor, release, major, minor, release))
""".format(tag, shorthash, major, minor, release, count))
output_version_header()
@@ -9,6 +9,24 @@ our $SVN = "/usr/bin/svn";
our $SVN_USER = 'dvander';
our $SVN_ARGS = '';
sub GitRevNum
{
my ($path) = (@_);
my ($cd, $text, $rev);
$cd = Cwd::cwd();
chdir($path);
$text = `git rev-list --count HEAD`;
chdir($cd);
chomp $text;
if ($text =~ /^(\d+)/) {
return $1;
}
return 0;
}
sub HgRevNum
{
my ($path) = (@_);
@@ -34,7 +34,7 @@
$version = Build::ProductVersion(Build::PathFormat('../../build/product.version'));
$version =~ s/-dev//g;
$version .= '-hg' . Build::HgRevNum('../../build');
$version .= '-git' . Build::GitRevNum('../../build');
# Append OS to package version
if ($^O eq "darwin")
@@ -16,7 +16,7 @@
my ($version);
$version = Build::ProductVersion(Build::PathFormat('product.version'));
$version =~ s/-dev//g;
$version .= '-hg' . Build::HgRevNum('.');
$version .= '-git' . Build::GitRevNum('.');
my ($build_type);
$build_type = Build::GetBuildType(Build::PathFormat('support/buildbot/build_type'));
@@ -26,6 +26,7 @@
#include <metamod_version.h>
#include <versionlib.h>
const char *METAMOD_BUILD_ID = MMS_BUILD_UNIQUEID;
const char *METAMOD_BUILD_LOCAL_REV = MMS_BUILD_LOCAL_REV;
const char *METAMOD_BUILD_SHA = MMS_BUILD_SHA;
const char *METAMOD_VERSION = MMS_FULL_VERSION;
View
@@ -25,7 +25,8 @@
#ifndef _INCLUDE_METAMOD_VERSIONLIB_H_
#define _INCLUDE_METAMOD_VERSIONLIB_H_
extern "C" const char *METAMOD_BUILD_ID;
extern "C" const char *METAMOD_BUILD_LOCAL_REV;
extern "C" const char *METAMOD_BUILD_SHA;
extern "C" const char *METAMOD_VERSION;
#endif // _INCLUDE_METAMOD_VERSIONLIB_H_

0 comments on commit 09d1f56

Please sign in to comment.