mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-11-28 10:24:20 +01:00
Merge new versioning logic from SourceMod, fixes manual builds and --gen=vs.
This commit is contained in:
parent
36d26dd1b4
commit
8cfab6c637
@ -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 })
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "sh_string.h"
|
||||
#include "sh_list.h"
|
||||
#include "util.h"
|
||||
#include <versionlib.h>
|
||||
#include <metamod_version.h>
|
||||
|
||||
/**
|
||||
* @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");
|
||||
|
@ -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"
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "util.h"
|
||||
#include <loader_bridge.h>
|
||||
#include <sh_string.h>
|
||||
#include <versionlib.h>
|
||||
#include <metamod_version.h>
|
||||
|
||||
SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "metamod.h"
|
||||
#include <interface.h>
|
||||
#include <eiface.h>
|
||||
#include <versionlib.h>
|
||||
#include <metamod_version.h>
|
||||
#include "metamod_provider.h"
|
||||
#include "metamod_plugins.h"
|
||||
#include "metamod_util.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include "metamod_oslink.h"
|
||||
#include <ctype.h>
|
||||
#include <versionlib.h>
|
||||
#include <metamod_version.h>
|
||||
#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");
|
||||
|
@ -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"
|
||||
|
@ -30,11 +30,11 @@
|
||||
#include <iplayerinfo.h>
|
||||
#include <assert.h>
|
||||
#include <loader_bridge.h>
|
||||
#include <versionlib.h>
|
||||
#include <metamod_version.h>
|
||||
#include <sh_string.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 &);
|
||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
||||
|
@ -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"
|
||||
|
@ -33,12 +33,34 @@
|
||||
*/
|
||||
|
||||
#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
|
||||
# include <metamod_version_auto.h>
|
||||
# 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_ */
|
||||
|
||||
|
@ -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'),
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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'
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <metamod_version.h>
|
||||
#include <versionlib.h>
|
||||
|
||||
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__;
|
||||
|
@ -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_
|
||||
|
Loading…
Reference in New Issue
Block a user