1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-26 19:54:14 +01:00

Merge new versioning logic from SourceMod, fixes manual builds and --gen=vs.

This commit is contained in:
Nicholas Hastings 2015-04-11 10:22:15 -04:00
parent 36d26dd1b4
commit 8cfab6c637
15 changed files with 128 additions and 64 deletions

View File

@ -62,6 +62,12 @@ class MMSConfig(object):
self.generated_headers = None self.generated_headers = None
self.versionlib = None self.versionlib = None
def use_auto_versioning(self):
if builder.backend != 'amb2':
return False
return not getattr(builder.options, 'disable_auto_versioning', False)
def detectProductVersion(self): def detectProductVersion(self):
builder.AddConfigureFile('product.version') builder.AddConfigureFile('product.version')
@ -216,10 +222,16 @@ class MMSConfig(object):
cfg.defines += ['WIN32', '_WINDOWS'] cfg.defines += ['WIN32', '_WINDOWS']
# Finish up. # Finish up.
cfg.defines += [ 'MMS_USE_VERSIONLIB' ]
cfg.includes += [
os.path.join(builder.sourcePath, 'public'),
]
if self.use_auto_versioning():
cfg.defines += ['MMS_GENERATED_BUILD'] cfg.defines += ['MMS_GENERATED_BUILD']
cfg.includes += [os.path.join(builder.buildPath, 'includes')] cfg.includes += [
cfg.includes += [os.path.join(builder.sourcePath, 'versionlib')] os.path.join(builder.buildPath, 'includes'),
cfg.cxxincludes += [os.path.join(builder.sourcePath, 'public')] os.path.join(builder.sourcePath, 'versionlib'),
]
def HL2Compiler(self, context, sdk): def HL2Compiler(self, context, sdk):
compiler = context.compiler.clone() compiler = context.compiler.clone()
@ -277,13 +289,14 @@ class MMSConfig(object):
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.rcdefines += [ binary.compiler.rcdefines += [
'BINARY_NAME="{0}"'.format(binary.outputFile), 'BINARY_NAME="{0}"'.format(binary.outputFile),
'MMS_GENERATED_BUILD' 'RC_COMPILE'
] ]
elif builder.target_platform == 'mac': elif builder.target_platform == 'mac':
binary.compiler.postlink += [ binary.compiler.postlink += [
'-compatibility_version', '1.0.0', '-compatibility_version', '1.0.0',
'-current_version', self.productVersion '-current_version', self.productVersion
] ]
if self.use_auto_versioning():
binary.compiler.linkflags += [self.versionlib] binary.compiler.linkflags += [self.versionlib]
binary.compiler.sourcedeps += MMS.generated_headers binary.compiler.sourcedeps += MMS.generated_headers
return binary return binary
@ -359,6 +372,7 @@ MMS.detectProductVersion()
MMS.detectSDKs() MMS.detectSDKs()
MMS.configure() MMS.configure()
if MMS.use_auto_versioning():
MMS.generated_headers = builder.RunScript( MMS.generated_headers = builder.RunScript(
'support/buildbot/Versioning', 'support/buildbot/Versioning',
{ 'MMS': MMS } { 'MMS': MMS }
@ -368,15 +382,16 @@ MMS.versionlib = builder.RunScript(
{ 'MMS': MMS } { 'MMS': MMS }
) )
builder.RunBuildScripts( BuildScripts = [
[
'loader/AMBuilder', 'loader/AMBuilder',
'core-legacy/AMBuilder', 'core-legacy/AMBuilder',
'core/AMBuilder', 'core/AMBuilder',
'support/buildbot/PackageScript', ]
],
{ if builder.backend == 'amb2':
'MMS': MMS BuildScripts += [
} 'support/buildbot/PackageScript',
) ]
builder.RunBuildScripts(BuildScripts, { 'MMS': MMS })

View File

@ -16,7 +16,7 @@
#include "sh_string.h" #include "sh_string.h"
#include "sh_list.h" #include "sh_list.h"
#include "util.h" #include "util.h"
#include <versionlib.h> #include <metamod_version.h>
/** /**
* @brief Console Command Implementations * @brief Console Command Implementations
@ -142,10 +142,10 @@ CON_COMMAND(meta, "Metamod:Source Menu")
return; return;
} else if (strcmp(command, "version") == 0) { } else if (strcmp(command, "version") == 0) {
CONMSG("Metamod:Source version %s\n", METAMOD_VERSION); CONMSG("Metamod:Source version %s\n", METAMOD_VERSION);
CONMSG(" Compiled on: %s", MMS_BUILD_TIMESTAMP);
#if defined(MMS_GENERATED_BUILD) #if defined(MMS_GENERATED_BUILD)
CONMSG("Built from: https://github.com/alliedmodders/metamod-source/commit/%s\n", METAMOD_BUILD_SHA); CONMSG("Built from: https://github.com/alliedmodders/metamod-source/commit/%s\n", METAMOD_SHA);
#endif #endif
CONMSG("Build ID: %s:%s\n", METAMOD_BUILD_LOCAL_REV, METAMOD_BUILD_SHA);
if (g_GameDll.loaded) if (g_GameDll.loaded)
{ {
CONMSG("Loaded As: GameDLL (gameinfo.txt)\n"); CONMSG("Loaded As: GameDLL (gameinfo.txt)\n");

View File

@ -27,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION MMS_FILE_VERSION FILEVERSION MMS_VERSION_FILE
PRODUCTVERSION MMS_FILE_VERSION PRODUCTVERSION MMS_VERSION_FILE
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -45,12 +45,12 @@ BEGIN
BEGIN BEGIN
VALUE "Comments", "Metamod: Source" VALUE "Comments", "Metamod: Source"
VALUE "FileDescription", "Metamod: Source" VALUE "FileDescription", "Metamod: Source"
VALUE "FileVersion", MMS_FULL_VERSION VALUE "FileVersion", MMS_VERSION_STRING
VALUE "InternalName", "mmsource" VALUE "InternalName", "mmsource"
VALUE "LegalCopyright", "Copyright (c) 2004-2010, Metamod: Source Development Team" VALUE "LegalCopyright", "Copyright (c) 2004-2010, Metamod: Source Development Team"
VALUE "OriginalFilename", BINARY_NAME VALUE "OriginalFilename", BINARY_NAME
VALUE "ProductName", "Metamod:Source" VALUE "ProductName", "Metamod:Source"
VALUE "ProductVersion", MMS_FULL_VERSION VALUE "ProductVersion", MMS_VERSION_STRING
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -29,7 +29,7 @@
#include "util.h" #include "util.h"
#include <loader_bridge.h> #include <loader_bridge.h>
#include <sh_string.h> #include <sh_string.h>
#include <versionlib.h> #include <metamod_version.h>
SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false); SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);

View File

@ -28,7 +28,7 @@
#include "metamod.h" #include "metamod.h"
#include <interface.h> #include <interface.h>
#include <eiface.h> #include <eiface.h>
#include <versionlib.h> #include <metamod_version.h>
#include "metamod_provider.h" #include "metamod_provider.h"
#include "metamod_plugins.h" #include "metamod_plugins.h"
#include "metamod_util.h" #include "metamod_util.h"

View File

@ -26,7 +26,7 @@
#include <stdio.h> #include <stdio.h>
#include "metamod_oslink.h" #include "metamod_oslink.h"
#include <ctype.h> #include <ctype.h>
#include <versionlib.h> #include <metamod_version.h>
#include "metamod.h" #include "metamod.h"
#include "metamod_util.h" #include "metamod_util.h"
#include "metamod_console.h" #include "metamod_console.h"
@ -70,11 +70,10 @@ bool Command_Meta(IMetamodSourceCommandInfo *info)
else if (strcmp(command, "version") == 0) else if (strcmp(command, "version") == 0)
{ {
CONMSG("Metamod:Source version %s\n", METAMOD_VERSION); CONMSG("Metamod:Source version %s\n", METAMOD_VERSION);
CONMSG(" Compiled on: %s", MMS_BUILD_TIMESTAMP);
#if defined(MMS_GENERATED_BUILD) #if defined(MMS_GENERATED_BUILD)
CONMSG("Built from: https://github.com/alliedmodders/metamod-source/commit/%s\n", METAMOD_BUILD_SHA); CONMSG("Built from: https://github.com/alliedmodders/metamod-source/commit/%s\n", METAMOD_SHA);
#endif #endif
CONMSG("Build ID: %s:%s\n", METAMOD_BUILD_LOCAL_REV, METAMOD_BUILD_SHA);
if (g_Metamod.IsLoadedAsGameDLL()) if (g_Metamod.IsLoadedAsGameDLL())
{ {
CONMSG("Loaded As: GameDLL (gameinfo.txt)\n"); CONMSG("Loaded As: GameDLL (gameinfo.txt)\n");

View File

@ -27,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION MMS_FILE_VERSION FILEVERSION MMS_VERSION_FILE
PRODUCTVERSION MMS_FILE_VERSION PRODUCTVERSION MMS_VERSION_FILE
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -45,12 +45,12 @@ BEGIN
BEGIN BEGIN
VALUE "Comments", "Metamod: Source" VALUE "Comments", "Metamod: Source"
VALUE "FileDescription", "Metamod: Source" VALUE "FileDescription", "Metamod: Source"
VALUE "FileVersion", MMS_FULL_VERSION VALUE "FileVersion", MMS_VERSION_STRING
VALUE "InternalName", "mmsource" VALUE "InternalName", "mmsource"
VALUE "LegalCopyright", "Copyright (c) 2004-2010, Metamod: Source Development Team" VALUE "LegalCopyright", "Copyright (c) 2004-2010, Metamod: Source Development Team"
VALUE "OriginalFilename", BINARY_NAME VALUE "OriginalFilename", BINARY_NAME
VALUE "ProductName", "Metamod:Source" VALUE "ProductName", "Metamod:Source"
VALUE "ProductVersion", MMS_FULL_VERSION VALUE "ProductVersion", MMS_VERSION_STRING
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -30,11 +30,11 @@
#include <iplayerinfo.h> #include <iplayerinfo.h>
#include <assert.h> #include <assert.h>
#include <loader_bridge.h> #include <loader_bridge.h>
#include <versionlib.h> #include <metamod_version.h>
#include <sh_string.h> #include <sh_string.h>
#include "provider/provider_ep2.h" #include "provider/provider_ep2.h"
#if SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_DOTA || SOURCE_ENGINE == SE_SOURCE2
SH_DECL_HOOK2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &); SH_DECL_HOOK2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &);
#elif SOURCE_ENGINE >= SE_ORANGEBOX #elif SOURCE_ENGINE >= SE_ORANGEBOX
SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);

View File

@ -27,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION MMS_FILE_VERSION FILEVERSION MMS_VERSION_FILE
PRODUCTVERSION MMS_FILE_VERSION PRODUCTVERSION MMS_VERSION_FILE
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -45,12 +45,12 @@ BEGIN
BEGIN BEGIN
VALUE "Comments", "Metamod: Source Loader" VALUE "Comments", "Metamod: Source Loader"
VALUE "FileDescription", "Metamod: Source Loader" VALUE "FileDescription", "Metamod: Source Loader"
VALUE "FileVersion", MMS_FULL_VERSION VALUE "FileVersion", MMS_VERSION_STRING
VALUE "InternalName", "mmsource" VALUE "InternalName", "mmsource"
VALUE "LegalCopyright", "Copyright (c) 2004-2010, Metamod: Source Development Team" VALUE "LegalCopyright", "Copyright (c) 2004-2010, Metamod: Source Development Team"
VALUE "OriginalFilename", BINARY_NAME VALUE "OriginalFilename", BINARY_NAME
VALUE "ProductName", "Metamod:Source Loader" VALUE "ProductName", "Metamod:Source Loader"
VALUE "ProductVersion", MMS_FULL_VERSION VALUE "ProductVersion", MMS_VERSION_STRING
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -33,12 +33,34 @@
*/ */
#if defined MMS_GENERATED_BUILD #if defined MMS_GENERATED_BUILD
#include <metamod_version_auto.h> # if defined RC_COMPILE
# undef MMS_USE_VERSIONLIB
# endif
# if defined MMS_USE_VERSIONLIB
# include <versionlib.h>
# else # else
#define MMS_BUILD_STRING "-pdev" # include <metamod_version_auto.h>
#define MMS_BUILD_UNIQUEID "701:46ea970e0eb6" MMS_BUILD_STRING # endif
#define MMS_FULL_VERSION "1.9.0" MMS_BUILD_STRING #else
#define MMS_FILE_VERSION 1,9,0,0 #define MMS_BUILD_TAG "manual"
#define MMS_BUILD_LOCAL_REV "0"
#define MMS_BUILD_CSET "0"
#define MMS_BUILD_MAJOR "1"
#define MMS_BUILD_MINOR "11"
#define MMS_BUILD_RELEASE "0"
#define MMS_BUILD_UNIQUEID MMS_BUILD_LOCAL_REV ":" MMS_BUILD_CSET
#define MMS_VERSION_STRING MMS_BUILD_MAJOR "." MMS_BUILD_MINOR "." MMS_BUILD_RELEASE "-" MMS_BUILD_TAG
#define MMS_VERSION_FILE 1,11,0,0
#endif
#define MMS_BUILD_TIMESTAMP __DATE__ " " __TIME__
#if !defined(MMS_GENERATED_BUILD) || !defined(MMS_USE_VERSIONLIB)
# define METAMOD_VERSION MMS_VERSION_STRING
# define METAMOD_BUILD_ID MMS_BUILD_UNIQUEID
# define METAMOD_BUILD_TIME MMS_BUILD_TIMESTAMP
#endif #endif
#endif /* _INCLUDE_METAMOD_VERSION_INFORMATION_H_ */ #endif /* _INCLUDE_METAMOD_VERSION_INFORMATION_H_ */

View File

@ -1,5 +1,6 @@
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python: # vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
import os, sys import os, sys
import re
builder.SetBuildFolder('/') builder.SetBuildFolder('/')
@ -16,8 +17,11 @@ outputs = [
] ]
with open(os.path.join(builder.sourcePath, '.git', 'HEAD')) as fp: with open(os.path.join(builder.sourcePath, '.git', 'HEAD')) as fp:
git_state = fp.read().strip().split(':')[1].strip() head_contents = fp.read().strip()
if re.search('^[a-fA-F0-9]{40}$', head_contents):
git_head_path = os.path.join(builder.sourcePath, '.git', 'HEAD')
else:
git_state = head_contents.split(':')[1].strip()
git_head_path = os.path.join(builder.sourcePath, '.git', git_state) git_head_path = os.path.join(builder.sourcePath, '.git', git_state)
if not os.path.exists(git_head_path): if not os.path.exists(git_head_path):
git_head_path = os.path.join(builder.sourcePath, '.git', 'HEAD') git_head_path = os.path.join(builder.sourcePath, '.git', 'HEAD')

View File

@ -55,24 +55,32 @@ def output_version_header():
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()
product = "{0}.{1}.{2}".format(major, minor, release)
if tag: fullstring = product
tag = '-' + tag if tag != "":
fullstring += "-{0}".format(tag)
if tag == "dev":
fullstring += "+{0}".format(count)
with open(os.path.join(OutputFolder, 'metamod_version_auto.h'), 'w') as fp: with open(os.path.join(OutputFolder, 'metamod_version_auto.h'), 'w') as fp:
fp.write("""#ifndef _METAMOD_AUTO_VERSION_INFORMATION_H_ fp.write("""
#ifndef _METAMOD_AUTO_VERSION_INFORMATION_H_
#define _METAMOD_AUTO_VERSION_INFORMATION_H_ #define _METAMOD_AUTO_VERSION_INFORMATION_H_
#define MMS_BUILD_STRING \"{0}\" #define MMS_BUILD_TAG \"{0}\"
#define MMS_BUILD_LOCAL_REV \"{5}\" #define MMS_BUILD_CSET \"{1}\"
#define MMS_BUILD_SHA \"{1}\" #define MMS_BUILD_MAJOR \"{2}\"
#define MMS_BUILD_UNIQUEID \"{5}:{1}\" MMS_BUILD_STRING #define MMS_BUILD_MINOR \"{3}\"
#define MMS_FULL_VERSION \"{2}.{3}.{4}\" MMS_BUILD_STRING #define MMS_BUILD_RELEASE \"{4}\"
#define MMS_FILE_VERSION {2},{3},{4},0 #define MMS_BUILD_LOCAL_REV \"{6}\"
#define MMS_BUILD_UNIQUEID "{6}:" MMS_BUILD_CSET
#define MMS_VERSION_STRING \"{5}\"
#define MMS_VERSION_FILE {2},{3},{4},0
#endif /* _METAMOD_AUTO_VERSION_INFORMATION_H_ */ #endif /* _METAMOD_AUTO_VERSION_INFORMATION_H_ */
""".format(tag, shorthash, major, minor, release, fullstring, count))
""".format(tag, shorthash, major, minor, release, count))
output_version_header() output_version_header()

View File

@ -1,6 +1,7 @@
# vim: sts=2 ts=8 sw=2 tw=99 et ft=python: # vim: sts=2 ts=8 sw=2 tw=99 et ft=python:
lib = builder.compiler.StaticLibrary("version") lib = builder.compiler.StaticLibrary("version")
lib.compiler.defines.remove('MMS_USE_VERSIONLIB')
lib.compiler.sourcedeps += MMS.generated_headers lib.compiler.sourcedeps += MMS.generated_headers
lib.sources += [ lib.sources += [
'versionlib.cpp' 'versionlib.cpp'

View File

@ -26,7 +26,7 @@
#include <metamod_version.h> #include <metamod_version.h>
#include <versionlib.h> #include <versionlib.h>
const char *METAMOD_BUILD_LOCAL_REV = MMS_BUILD_LOCAL_REV; const char *METAMOD_LOCAL_REV = MMS_BUILD_LOCAL_REV;
const char *METAMOD_BUILD_SHA = MMS_BUILD_SHA; const char *METAMOD_SHA = MMS_BUILD_CSET;
const char *METAMOD_VERSION = MMS_FULL_VERSION; const char *METAMOD_VERSION = MMS_VERSION_STRING;
const char *METAMOD_BUILD_TIME = __DATE__ " " __TIME__;

View File

@ -25,8 +25,23 @@
#ifndef _INCLUDE_METAMOD_VERSIONLIB_H_ #ifndef _INCLUDE_METAMOD_VERSIONLIB_H_
#define _INCLUDE_METAMOD_VERSIONLIB_H_ #define _INCLUDE_METAMOD_VERSIONLIB_H_
extern "C" const char *METAMOD_BUILD_LOCAL_REV; #if !defined(MMS_USE_VERSIONLIB)
extern "C" const char *METAMOD_BUILD_SHA; // These get defined in metamod_version.h since
extern "C" const char *METAMOD_VERSION; // versionlib does not use versionlib.
# undef METAMOD_LOCAL_REV
# undef METAMOD_CSET
# undef METAMOD_VERSION
# undef METAMOD_BUILD_TIME
#endif
#ifdef __cplusplus
# define EXTERN_C extern "C"
#else
# define EXTERN_C extern
#endif
EXTERN_C const char *METAMOD_LOCAL_REV;
EXTERN_C const char *METAMOD_SHA;
EXTERN_C const char *METAMOD_VERSION;
EXTERN_C const char *METAMOD_BUILD_TIME;
#endif // _INCLUDE_METAMOD_VERSIONLIB_H_ #endif // _INCLUDE_METAMOD_VERSIONLIB_H_