Update versioning

This commit is contained in:
Arkshine 2014-12-08 01:39:10 +01:00
parent 2bba5ce69a
commit 3594c11238
7 changed files with 154 additions and 66 deletions

View File

@ -14,6 +14,7 @@ class AMXXConfig(object):
self.hlsdk_path = None
self.mysql_path = None
self.generated_headers = []
self.versionlib = None
self.csx_app = None
self.stdcxx_path = None
@ -24,7 +25,6 @@ class AMXXConfig(object):
def detectProductVersion(self):
builder.AddConfigureFile('product.version')
builder.AddConfigureFile('.git/HEAD')
# For OS X dylib versioning
import re
@ -243,11 +243,15 @@ class AMXXConfig(object):
cfg.defines += [
'AMX_NOPROPLIST',
'PAWN_CELL_SIZE=32',
'AMXMODX_BUILD',
'AMXX_USE_VERSIONLIB',
]
if self.use_auto_versioning():
cfg.defines += ['AMBUILD']
cfg.defines += ['AMXX_GENERATED_BUILD']
cfg.includes += [os.path.join(builder.buildPath, 'includes')]
cfg.includes += [os.path.join(builder.sourcePath, 'support', 'versionlib')]
cfg.includes += [os.path.join(builder.sourcePath, 'public')]
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'sdk')]
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'amtl')]
@ -258,9 +262,10 @@ class AMXXConfig(object):
# Low-level compiler and binary construction.
#
def MMCompiler(self, context):
compiler = context.compiler.clone()
def ConfigureForModule(self, context, compiler):
compiler.cxxincludes += [
os.path.join(context.currentSourcePath),
os.path.join(context.currentSourcePath, 'sdk'),
os.path.join(self.metamod_path, 'metamod'),
os.path.join(self.hlsdk_path, 'common'),
os.path.join(self.hlsdk_path, 'dlls'),
@ -271,48 +276,21 @@ class AMXXConfig(object):
]
return compiler
def LibraryBuilder(self, context, compiler, name):
binary = compiler.Library(name)
binary.compiler.cxxincludes += [os.path.join(context.currentSourcePath)]
def AddVersioning(self, binary):
if builder.target_platform == 'windows':
binary.compiler.rcdefines += [
'BINARY_NAME="{0}"'.format(binary.outputFile),
'RC_COMPILE',
]
if self.use_auto_versioning():
binary.compiler.rcdefines += ['AMBUILD']
binary.compiler.rcdefines += ['AMXX_GENERATED_BUILD']
elif builder.target_platform == 'mac':
binary.compiler.postlink += [
'-compatibility_version', '1.0.0',
'-current_version', self.productVersion
]
if self.use_auto_versioning():
binary.compiler.rcdefines += ['AMBUILD']
binary.compiler.sourcedeps += AMXX.generated_headers
return binary
def ModuleBuilder(self, context, compiler, name):
compiler.cxxincludes += [
os.path.join(context.currentSourcePath, 'sdk'),
]
if builder.target_platform == 'mac' or builder.target_platform == 'windows':
name = name + '_amxx'
elif builder.target_platform == 'linux':
name = name + '_amxx_i386'
return self.LibraryBuilder(context, compiler, name)
def ProgramBuilder(self, context, compiler, name):
binary = compiler.Program(name)
binary.compiler.cxxincludes += [os.path.join(context.currentSourcePath)]
if builder.target_platform == 'windows':
binary.compiler.rcdefines += [
'BINARY_NAME="{0}"'.format(binary.outputFile),
'AMBUILD',
'RC_COMPILE',
]
binary.compiler.linkflags += [self.versionlib]
binary.compiler.sourcedeps += AMXX.generated_headers
return binary
@ -322,30 +300,39 @@ class AMXXConfig(object):
#
def Library(self, context, name):
compiler = context.compiler.clone()
return self.LibraryBuilder(context, compiler, name)
binary = context.compiler.Library(name)
return self.AddVersioning(binary)
def MetaPlugin(self, context, name):
compiler = self.MMCompiler(context)
binary = context.compiler.Library(name)
self.ConfigureForModule(context, binary.compiler)
if builder.target_platform == 'mac' or builder.target_platform == 'windows':
name = name + '_mm'
elif builder.target_platform == 'linux':
name = name + '_mm_i386'
return self.LibraryBuilder(context, compiler, name)
return self.AddVersioning(binary)
def Module(self, context, name):
compiler = context.compiler.clone()
return self.ModuleBuilder(context, compiler, name)
binary = context.compiler.Library(name)
self.ConfigureForModule(context, binary.compiler)
return self.AddVersioning(binary)
def MetaModule(self, context, name):
compiler = self.MMCompiler(context)
return self.ModuleBuilder(context, compiler, name)
binary = context.compiler.Library(name)
self.ConfigureForModule(context, binary.compiler)
if builder.target_platform == 'mac' or builder.target_platform == 'windows':
name = name + '_amxx'
elif builder.target_platform == 'linux':
name = name + '_amxx_i386'
return self.AddVersioning(binary)
def Program(self, context, name):
compiler = context.compiler.clone()
return self.ProgramBuilder(context, compiler, name)
binary = context.compiler.Program(name)
return self.AddVersioning(binary)
AMXX = AMXXConfig()
AMXX.detectProductVersion()
@ -359,6 +346,10 @@ if AMXX.use_auto_versioning():
'support/Versioning',
{ 'AMXX': AMXX }
)
AMXX.versionlib = builder.RunScript(
'support/versionlib/AMBuilder',
{ 'AMXX': AMXX }
)
builder.RunBuildScripts(
[

42
public/amxmodx_version.h Normal file
View File

@ -0,0 +1,42 @@
#ifndef _INCLUDE_AMXX_VERSION_INFORMATION_H_
#define _INCLUDE_AMXX_VERSION_INFORMATION_H_
/**
* @file Contains AMX Mod X version information.
* @brief This file will redirect to an autogenerated version if being compiled via
* the build scripts.
*/
#if defined AMXX_GENERATED_BUILD
#if defined RC_COMPILE
#undef AMXX_USE_VERSIONLIB
#endif
#if defined AMXX_USE_VERSIONLIB
#include <versionlib.h>
#else
#include <amxmodx_version_auto.h>
#endif
#else
#define AMXX_BUILD_TAG "manual"
#define AMXX_BUILD_LOCAL_REV "0"
#define AMXX_BUILD_CSET "0"
#define AMXX_BUILD_MAJOR "1"
#define AMXX_BUILD_MINOR "8"
#define AMXX_BUILD_RELEASE "3"
#define AMXX_BUILD_UNIQUEID AMXX_BUILD_LOCAL_REV ":" AMXX_BUILD_CSET
#define AMXX_VERSION_STRING AMXX_BUILD_MAJOR "." AMXX_BUILD_MINOR "." AMXX_BUILD_RELEASE "-" AMXX_BUILD_TAG
#define AMXX_VERSION_FILE 1,8,3,0
#endif
#define AMXX_BUILD_TIMESTAMP __DATE__ " " __TIME__
#if !defined(AMXX_GENERATED_BUILD) || !defined(AMXX_USE_VERSIONLIB)
#define AMXX_VERSION AMXX_VERSION_STRING
#define AMXX_BUILD_ID AMXX_BUILD_UNIQUEID
#define AMXX_BUILD_TIME AMXX_BUILD_TIMESTAMP
#endif
#endif /* _INCLUDE_AMXX_VERSION_INFORMATION_H_ */

View File

@ -13,7 +13,7 @@ argv = [
os.path.join(builder.buildPath, 'includes'),
]
outputs = [
os.path.join(builder.buildFolder, 'includes', 'amxmodx_version.h'),
os.path.join(builder.buildFolder, 'includes', 'amxmodx_version_auto.h'),
os.path.join(builder.buildFolder, 'includes', 'amxmodx_version.inc'),
]

View File

@ -60,29 +60,27 @@ def output_version_headers():
if tag != "":
fullstring += "-{0}".format(tag)
if tag == "dev":
fullstring += "+{0}".format(shorthash)
fullstring += "+{0}".format(count)
with open(os.path.join(OutputFolder, 'amxmodx_version.h'), 'w') as fp:
with open(os.path.join(OutputFolder, 'amxmodx_version_auto.h'), 'w') as fp:
fp.write("""
#ifndef _AMXMODX_AUTO_VERSION_INFORMATION_H_
#define _AMXMODX_AUTO_VERSION_INFORMATION_H_
#define SVN_VERSION_STRING "{fullstring}"
#define SVN_VERSION_DWORD {major}, {minor}, {release}, 0
#define SVN_VERSION_PRODUCT "{product}"
#define SVN_VERSION SVN_VERSION_STRING
#define SVN_BUILD_ID "{count}:{longhash}"
#define AMXX_BUILD_TAG \"{0}\"
#define AMXX_BUILD_CSET \"{1}\"
#define AMXX_BUILD_MAJOR \"{2}\"
#define AMXX_BUILD_MINOR \"{3}\"
#define AMXX_BUILD_RELEASE \"{4}\"
#define AMXX_BUILD_LOCAL_REV \"{6}\"
#define AMXX_BUILD_UNIQUEID "{6}:" AMXX_BUILD_CSET
#define AMXX_VERSION_STRING \"{5}\"
#define AMXX_VERSION_FILE {2},{3},{4},0
#endif // _AMXMODX_AUTO_VERSION_INFORMATION_H_
""".format(
fullstring = fullstring,
major = major,
minor = minor,
release = release,
product = product,
count = count,
longhash = longhash
))
""".format(tag, shorthash, major, minor, release, fullstring, count))
version_num = int(major) * 100 + int(minor) * 10 + int(release)
with open(os.path.join(OutputFolder, 'amxmodx_version.inc'), 'w') as fp:
@ -92,13 +90,23 @@ def output_version_headers():
#endif
#define _amxmodx_version_included
#define AMXX_VERSION_TAG \"{tag}\"
#define AMXX_VERSION_CSET \"{shorthash}\"
#define AMXX_VERSION_MAJOR \"{major}\"
#define AMXX_VERSION_MINOR \"{minor}\"
#define AMXX_VERSION_RELEASE \"{release}\"
#define AMXX_VERSION_LOCAL_REV \"{count}\"
#define AMXX_VERSION {major}.{minor}{release}
#define AMXX_VERSION_NUM {version_num}
stock const AMXX_VERSION_STR[] = "{fullstring}";
""".format(
tag = tag,
shorthash = shorthash,
major = major,
minor = minor,
release = release,
count = count,
version_num = version_num,
fullstring = fullstring
))

View File

@ -0,0 +1,15 @@
# vim: sts=2 ts=8 sw=2 tw=99 et ft=python:
import os
lib = builder.compiler.StaticLibrary('version')
lib.compiler.includes += [
os.path.join(builder.sourcePath, 'public'),
]
lib.compiler.defines.remove('AMXX_USE_VERSIONLIB')
lib.compiler.sourcedeps += AMXX.generated_headers
lib.sources += [
'versionlib.cpp'
]
task = builder.Add(lib)
rvalue = task.binary

View File

@ -0,0 +1,8 @@
#include <amxmodx_version.h>
#include <versionlib.h>
const char *AMXX_LOCAL_REV = AMXX_BUILD_LOCAL_REV;
const char *AMXX_SHA = AMXX_BUILD_CSET;
const char *AMXX_VERSION = AMXX_VERSION_STRING;
const char *AMXX_BUILD_TIME = __DATE__ " " __TIME__;

View File

@ -0,0 +1,24 @@
#ifndef _INCLUDE_AMXX_VERSIONLIB_H_
#define _INCLUDE_AMXX_VERSIONLIB_H_
#if !defined(AMXX_USE_VERSIONLIB)
// These get defined in amxmodx_version.h since
// versionlib does not use versionlib.
#undef AMXX_LOCAL_REV
#undef AMXX_CSET
#undef AMXX_VERSION
#undef AMXX_BUILD_TIME
#endif
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C extern
#endif
EXTERN_C const char *AMXX_LOCAL_REV;
EXTERN_C const char *AMXX_SHA;
EXTERN_C const char *AMXX_VERSION;
EXTERN_C const char *AMXX_BUILD_TIME;
#endif // _INCLUDE_AMXX_VERSIONLIB_H_