mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-01-30 19:52:17 +01:00
Port build process to Git.
This commit is contained in:
parent
455d491752
commit
149bc768b7
@ -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']
|
||||
|
@ -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 += [
|
||||
|
@ -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
|
||||
|
@ -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 @@ 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,33 +36,41 @@ 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_UNIQUEID \"{1}\" MMS_BUILD_STRING
|
||||
#define MMS_FULL_VERSION \"{2}.{3}.{4}\" MMS_BUILD_STRING
|
||||
#define MMS_FILE_VERSION {5},{6},{7},0
|
||||
|
||||
#endif /* _METAMOD_AUTO_VERSION_INFORMATION_H_ */
|
||||
|
||||
""".format(tag, rev, cset, major, minor, release, major, minor, release))
|
||||
""".format(tag, shorthash, major, minor, release, major, minor, release))
|
||||
|
||||
output_version_header()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user