diff --git a/AMBuildScript b/AMBuildScript index 08880be..df845de 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -62,6 +62,12 @@ class MMSConfig(object): self.generated_headers = 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): builder.AddConfigureFile('product.version') @@ -216,10 +222,16 @@ class MMSConfig(object): cfg.defines += ['WIN32', '_WINDOWS'] # 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.includes += [os.path.join(builder.buildPath, 'includes')] - cfg.includes += [os.path.join(builder.sourcePath, 'versionlib')] - cfg.cxxincludes += [os.path.join(builder.sourcePath, 'public')] + cfg.includes += [ + os.path.join(builder.buildPath, 'includes'), + os.path.join(builder.sourcePath, 'versionlib'), + ] def HL2Compiler(self, context, sdk): compiler = context.compiler.clone() @@ -277,13 +289,14 @@ class MMSConfig(object): binary.sources += ['version.rc'] binary.compiler.rcdefines += [ 'BINARY_NAME="{0}"'.format(binary.outputFile), - 'MMS_GENERATED_BUILD' + 'RC_COMPILE' ] elif builder.target_platform == 'mac': binary.compiler.postlink += [ '-compatibility_version', '1.0.0', '-current_version', self.productVersion ] + if self.use_auto_versioning(): binary.compiler.linkflags += [self.versionlib] binary.compiler.sourcedeps += MMS.generated_headers return binary @@ -359,6 +372,7 @@ MMS.detectProductVersion() MMS.detectSDKs() MMS.configure() +if MMS.use_auto_versioning(): MMS.generated_headers = builder.RunScript( 'support/buildbot/Versioning', { 'MMS': MMS } @@ -368,15 +382,16 @@ MMS.versionlib = builder.RunScript( { 'MMS': MMS } ) -builder.RunBuildScripts( - [ +BuildScripts = [ 'loader/AMBuilder', 'core-legacy/AMBuilder', 'core/AMBuilder', - 'support/buildbot/PackageScript', - ], - { - 'MMS': MMS - } -) +] + +if builder.backend == 'amb2': + BuildScripts += [ + 'support/buildbot/PackageScript', + ] + +builder.RunBuildScripts(BuildScripts, { 'MMS': MMS }) diff --git a/core-legacy/concommands.cpp b/core-legacy/concommands.cpp index 56fe107..c3a4a4a 100644 --- a/core-legacy/concommands.cpp +++ b/core-legacy/concommands.cpp @@ -16,7 +16,7 @@ #include "sh_string.h" #include "sh_list.h" #include "util.h" -#include +#include /** * @brief Console Command Implementations @@ -142,10 +142,10 @@ CON_COMMAND(meta, "Metamod:Source Menu") return; } else if (strcmp(command, "version") == 0) { CONMSG("Metamod:Source version %s\n", METAMOD_VERSION); + CONMSG(" Compiled on: %s", MMS_BUILD_TIMESTAMP); #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 - CONMSG("Build ID: %s:%s\n", METAMOD_BUILD_LOCAL_REV, METAMOD_BUILD_SHA); if (g_GameDll.loaded) { CONMSG("Loaded As: GameDLL (gameinfo.txt)\n"); diff --git a/core-legacy/version.rc b/core-legacy/version.rc index ce93a16..f032f77 100755 --- a/core-legacy/version.rc +++ b/core-legacy/version.rc @@ -27,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION MMS_FILE_VERSION - PRODUCTVERSION MMS_FILE_VERSION + FILEVERSION MMS_VERSION_FILE + PRODUCTVERSION MMS_VERSION_FILE FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -45,12 +45,12 @@ BEGIN BEGIN VALUE "Comments", "Metamod: Source" VALUE "FileDescription", "Metamod: Source" - VALUE "FileVersion", MMS_FULL_VERSION + VALUE "FileVersion", MMS_VERSION_STRING VALUE "InternalName", "mmsource" VALUE "LegalCopyright", "Copyright (c) 2004-2010, Metamod: Source Development Team" VALUE "OriginalFilename", BINARY_NAME VALUE "ProductName", "Metamod:Source" - VALUE "ProductVersion", MMS_FULL_VERSION + VALUE "ProductVersion", MMS_VERSION_STRING END END BLOCK "VarFileInfo" diff --git a/core-legacy/vsp_bridge.cpp b/core-legacy/vsp_bridge.cpp index 83973af..4bf37cc 100644 --- a/core-legacy/vsp_bridge.cpp +++ b/core-legacy/vsp_bridge.cpp @@ -29,7 +29,7 @@ #include "util.h" #include #include -#include +#include SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false); diff --git a/core/metamod.cpp b/core/metamod.cpp index d5c94b9..9d9fc0b 100644 --- a/core/metamod.cpp +++ b/core/metamod.cpp @@ -28,7 +28,7 @@ #include "metamod.h" #include #include -#include +#include #include "metamod_provider.h" #include "metamod_plugins.h" #include "metamod_util.h" diff --git a/core/metamod_console.cpp b/core/metamod_console.cpp index 4f42e83..c4756bd 100644 --- a/core/metamod_console.cpp +++ b/core/metamod_console.cpp @@ -26,7 +26,7 @@ #include #include "metamod_oslink.h" #include -#include +#include #include "metamod.h" #include "metamod_util.h" #include "metamod_console.h" @@ -70,11 +70,10 @@ bool Command_Meta(IMetamodSourceCommandInfo *info) else if (strcmp(command, "version") == 0) { CONMSG("Metamod:Source version %s\n", METAMOD_VERSION); + CONMSG(" Compiled on: %s", MMS_BUILD_TIMESTAMP); #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 - CONMSG("Build ID: %s:%s\n", METAMOD_BUILD_LOCAL_REV, METAMOD_BUILD_SHA); - if (g_Metamod.IsLoadedAsGameDLL()) { CONMSG("Loaded As: GameDLL (gameinfo.txt)\n"); diff --git a/core/version.rc b/core/version.rc index 2e4420e..63bde2b 100755 --- a/core/version.rc +++ b/core/version.rc @@ -27,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION MMS_FILE_VERSION - PRODUCTVERSION MMS_FILE_VERSION + FILEVERSION MMS_VERSION_FILE + PRODUCTVERSION MMS_VERSION_FILE FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -45,12 +45,12 @@ BEGIN BEGIN VALUE "Comments", "Metamod: Source" VALUE "FileDescription", "Metamod: Source" - VALUE "FileVersion", MMS_FULL_VERSION + VALUE "FileVersion", MMS_VERSION_STRING VALUE "InternalName", "mmsource" VALUE "LegalCopyright", "Copyright (c) 2004-2010, Metamod: Source Development Team" VALUE "OriginalFilename", BINARY_NAME VALUE "ProductName", "Metamod:Source" - VALUE "ProductVersion", MMS_FULL_VERSION + VALUE "ProductVersion", MMS_VERSION_STRING END END BLOCK "VarFileInfo" diff --git a/core/vsp_bridge.cpp b/core/vsp_bridge.cpp index cd73988..ce76931 100644 --- a/core/vsp_bridge.cpp +++ b/core/vsp_bridge.cpp @@ -30,11 +30,11 @@ #include #include #include -#include +#include #include #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 &); #elif SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &); diff --git a/loader/version.rc b/loader/version.rc index edd1931..602b4be 100644 --- a/loader/version.rc +++ b/loader/version.rc @@ -27,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION MMS_FILE_VERSION - PRODUCTVERSION MMS_FILE_VERSION + FILEVERSION MMS_VERSION_FILE + PRODUCTVERSION MMS_VERSION_FILE FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -45,12 +45,12 @@ BEGIN BEGIN VALUE "Comments", "Metamod: Source Loader" VALUE "FileDescription", "Metamod: Source Loader" - VALUE "FileVersion", MMS_FULL_VERSION + VALUE "FileVersion", MMS_VERSION_STRING VALUE "InternalName", "mmsource" VALUE "LegalCopyright", "Copyright (c) 2004-2010, Metamod: Source Development Team" VALUE "OriginalFilename", BINARY_NAME VALUE "ProductName", "Metamod:Source Loader" - VALUE "ProductVersion", MMS_FULL_VERSION + VALUE "ProductVersion", MMS_VERSION_STRING END END BLOCK "VarFileInfo" diff --git a/public/metamod_version.h b/public/metamod_version.h index 0957c96..9c88b39 100644 --- a/public/metamod_version.h +++ b/public/metamod_version.h @@ -33,12 +33,34 @@ */ #if defined MMS_GENERATED_BUILD -#include +# if defined RC_COMPILE +# undef MMS_USE_VERSIONLIB +# endif +# if defined MMS_USE_VERSIONLIB +# include +# else +# include +# endif #else -#define MMS_BUILD_STRING "-pdev" -#define MMS_BUILD_UNIQUEID "701:46ea970e0eb6" MMS_BUILD_STRING -#define MMS_FULL_VERSION "1.9.0" MMS_BUILD_STRING -#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 /* _INCLUDE_METAMOD_VERSION_INFORMATION_H_ */ + diff --git a/support/buildbot/Versioning b/support/buildbot/Versioning index 2144f28..7929ef3 100644 --- a/support/buildbot/Versioning +++ b/support/buildbot/Versioning @@ -1,5 +1,6 @@ # vim: set ts=8 sts=2 sw=2 tw=99 et ft=python: import os, sys +import re builder.SetBuildFolder('/') @@ -16,11 +17,14 @@ outputs = [ ] 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') + 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) + 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'), diff --git a/support/buildbot/generate_headers.py b/support/buildbot/generate_headers.py index 0135d2c..c730ee7 100644 --- a/support/buildbot/generate_headers.py +++ b/support/buildbot/generate_headers.py @@ -55,24 +55,32 @@ def output_version_header(): if m == None: raise Exception('Could not detremine product version') major, minor, release, tag = m.groups() - - if tag: - tag = '-' + tag + product = "{0}.{1}.{2}".format(major, minor, release) + fullstring = product + 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: - fp.write("""#ifndef _METAMOD_AUTO_VERSION_INFORMATION_H_ + fp.write(""" +#ifndef _METAMOD_AUTO_VERSION_INFORMATION_H_ #define _METAMOD_AUTO_VERSION_INFORMATION_H_ -#define MMS_BUILD_STRING \"{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 +#define MMS_BUILD_TAG \"{0}\" +#define MMS_BUILD_CSET \"{1}\" +#define MMS_BUILD_MAJOR \"{2}\" +#define MMS_BUILD_MINOR \"{3}\" +#define MMS_BUILD_RELEASE \"{4}\" +#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_ */ - -""".format(tag, shorthash, major, minor, release, count)) + """.format(tag, shorthash, major, minor, release, fullstring, count)) output_version_header() diff --git a/versionlib/AMBuildScript b/versionlib/AMBuildScript index ed728f6..d46d66e 100644 --- a/versionlib/AMBuildScript +++ b/versionlib/AMBuildScript @@ -1,6 +1,7 @@ # vim: sts=2 ts=8 sw=2 tw=99 et ft=python: lib = builder.compiler.StaticLibrary("version") +lib.compiler.defines.remove('MMS_USE_VERSIONLIB') lib.compiler.sourcedeps += MMS.generated_headers lib.sources += [ 'versionlib.cpp' diff --git a/versionlib/versionlib.cpp b/versionlib/versionlib.cpp index a30505f..76db83f 100644 --- a/versionlib/versionlib.cpp +++ b/versionlib/versionlib.cpp @@ -26,7 +26,7 @@ #include #include -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; - +const char *METAMOD_LOCAL_REV = MMS_BUILD_LOCAL_REV; +const char *METAMOD_SHA = MMS_BUILD_CSET; +const char *METAMOD_VERSION = MMS_VERSION_STRING; +const char *METAMOD_BUILD_TIME = __DATE__ " " __TIME__; diff --git a/versionlib/versionlib.h b/versionlib/versionlib.h index 47bb91f..9914a82 100644 --- a/versionlib/versionlib.h +++ b/versionlib/versionlib.h @@ -25,8 +25,23 @@ #ifndef _INCLUDE_METAMOD_VERSIONLIB_H_ #define _INCLUDE_METAMOD_VERSIONLIB_H_ -extern "C" const char *METAMOD_BUILD_LOCAL_REV; -extern "C" const char *METAMOD_BUILD_SHA; -extern "C" const char *METAMOD_VERSION; +#if !defined(MMS_USE_VERSIONLIB) +// These get defined in metamod_version.h since +// 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_