Update versioning
This commit is contained in:
parent
2bba5ce69a
commit
3594c11238
|
@ -14,6 +14,7 @@ class AMXXConfig(object):
|
||||||
self.hlsdk_path = None
|
self.hlsdk_path = None
|
||||||
self.mysql_path = None
|
self.mysql_path = None
|
||||||
self.generated_headers = []
|
self.generated_headers = []
|
||||||
|
self.versionlib = None
|
||||||
self.csx_app = None
|
self.csx_app = None
|
||||||
self.stdcxx_path = None
|
self.stdcxx_path = None
|
||||||
|
|
||||||
|
@ -24,7 +25,6 @@ class AMXXConfig(object):
|
||||||
|
|
||||||
def detectProductVersion(self):
|
def detectProductVersion(self):
|
||||||
builder.AddConfigureFile('product.version')
|
builder.AddConfigureFile('product.version')
|
||||||
builder.AddConfigureFile('.git/HEAD')
|
|
||||||
|
|
||||||
# For OS X dylib versioning
|
# For OS X dylib versioning
|
||||||
import re
|
import re
|
||||||
|
@ -243,11 +243,15 @@ class AMXXConfig(object):
|
||||||
cfg.defines += [
|
cfg.defines += [
|
||||||
'AMX_NOPROPLIST',
|
'AMX_NOPROPLIST',
|
||||||
'PAWN_CELL_SIZE=32',
|
'PAWN_CELL_SIZE=32',
|
||||||
|
'AMXMODX_BUILD',
|
||||||
|
'AMXX_USE_VERSIONLIB',
|
||||||
]
|
]
|
||||||
|
|
||||||
if self.use_auto_versioning():
|
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.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')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'sdk')]
|
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'sdk')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'amtl')]
|
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'amtl')]
|
||||||
|
@ -258,9 +262,10 @@ class AMXXConfig(object):
|
||||||
# Low-level compiler and binary construction.
|
# Low-level compiler and binary construction.
|
||||||
#
|
#
|
||||||
|
|
||||||
def MMCompiler(self, context):
|
def ConfigureForModule(self, context, compiler):
|
||||||
compiler = context.compiler.clone()
|
|
||||||
compiler.cxxincludes += [
|
compiler.cxxincludes += [
|
||||||
|
os.path.join(context.currentSourcePath),
|
||||||
|
os.path.join(context.currentSourcePath, 'sdk'),
|
||||||
os.path.join(self.metamod_path, 'metamod'),
|
os.path.join(self.metamod_path, 'metamod'),
|
||||||
os.path.join(self.hlsdk_path, 'common'),
|
os.path.join(self.hlsdk_path, 'common'),
|
||||||
os.path.join(self.hlsdk_path, 'dlls'),
|
os.path.join(self.hlsdk_path, 'dlls'),
|
||||||
|
@ -271,49 +276,22 @@ class AMXXConfig(object):
|
||||||
]
|
]
|
||||||
return compiler
|
return compiler
|
||||||
|
|
||||||
def LibraryBuilder(self, context, compiler, name):
|
def AddVersioning(self, binary):
|
||||||
binary = compiler.Library(name)
|
|
||||||
binary.compiler.cxxincludes += [os.path.join(context.currentSourcePath)]
|
|
||||||
if builder.target_platform == 'windows':
|
if builder.target_platform == 'windows':
|
||||||
binary.compiler.rcdefines += [
|
binary.compiler.rcdefines += [
|
||||||
'BINARY_NAME="{0}"'.format(binary.outputFile),
|
'BINARY_NAME="{0}"'.format(binary.outputFile),
|
||||||
'RC_COMPILE',
|
'RC_COMPILE',
|
||||||
]
|
]
|
||||||
if self.use_auto_versioning():
|
if self.use_auto_versioning():
|
||||||
binary.compiler.rcdefines += ['AMBUILD']
|
binary.compiler.rcdefines += ['AMXX_GENERATED_BUILD']
|
||||||
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():
|
if self.use_auto_versioning():
|
||||||
binary.compiler.rcdefines += ['AMBUILD']
|
binary.compiler.linkflags += [self.versionlib]
|
||||||
|
binary.compiler.sourcedeps += AMXX.generated_headers
|
||||||
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.sourcedeps += AMXX.generated_headers
|
|
||||||
return binary
|
return binary
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -322,30 +300,39 @@ class AMXXConfig(object):
|
||||||
#
|
#
|
||||||
|
|
||||||
def Library(self, context, name):
|
def Library(self, context, name):
|
||||||
compiler = context.compiler.clone()
|
binary = context.compiler.Library(name)
|
||||||
return self.LibraryBuilder(context, compiler, name)
|
return self.AddVersioning(binary)
|
||||||
|
|
||||||
def MetaPlugin(self, context, name):
|
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':
|
if builder.target_platform == 'mac' or builder.target_platform == 'windows':
|
||||||
name = name + '_mm'
|
name = name + '_mm'
|
||||||
elif builder.target_platform == 'linux':
|
elif builder.target_platform == 'linux':
|
||||||
name = name + '_mm_i386'
|
name = name + '_mm_i386'
|
||||||
|
|
||||||
return self.LibraryBuilder(context, compiler, name)
|
return self.AddVersioning(binary)
|
||||||
|
|
||||||
def Module(self, context, name):
|
def Module(self, context, name):
|
||||||
compiler = context.compiler.clone()
|
binary = context.compiler.Library(name)
|
||||||
return self.ModuleBuilder(context, compiler, name)
|
self.ConfigureForModule(context, binary.compiler)
|
||||||
|
return self.AddVersioning(binary)
|
||||||
|
|
||||||
def MetaModule(self, context, name):
|
def MetaModule(self, context, name):
|
||||||
compiler = self.MMCompiler(context)
|
binary = context.compiler.Library(name)
|
||||||
return self.ModuleBuilder(context, compiler, 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):
|
def Program(self, context, name):
|
||||||
compiler = context.compiler.clone()
|
binary = context.compiler.Program(name)
|
||||||
return self.ProgramBuilder(context, compiler, name)
|
return self.AddVersioning(binary)
|
||||||
|
|
||||||
AMXX = AMXXConfig()
|
AMXX = AMXXConfig()
|
||||||
AMXX.detectProductVersion()
|
AMXX.detectProductVersion()
|
||||||
|
@ -359,6 +346,10 @@ if AMXX.use_auto_versioning():
|
||||||
'support/Versioning',
|
'support/Versioning',
|
||||||
{ 'AMXX': AMXX }
|
{ 'AMXX': AMXX }
|
||||||
)
|
)
|
||||||
|
AMXX.versionlib = builder.RunScript(
|
||||||
|
'support/versionlib/AMBuilder',
|
||||||
|
{ 'AMXX': AMXX }
|
||||||
|
)
|
||||||
|
|
||||||
builder.RunBuildScripts(
|
builder.RunBuildScripts(
|
||||||
[
|
[
|
||||||
|
|
42
public/amxmodx_version.h
Normal file
42
public/amxmodx_version.h
Normal 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_ */
|
||||||
|
|
|
@ -13,7 +13,7 @@ argv = [
|
||||||
os.path.join(builder.buildPath, 'includes'),
|
os.path.join(builder.buildPath, 'includes'),
|
||||||
]
|
]
|
||||||
outputs = [
|
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'),
|
os.path.join(builder.buildFolder, 'includes', 'amxmodx_version.inc'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -60,29 +60,27 @@ def output_version_headers():
|
||||||
if tag != "":
|
if tag != "":
|
||||||
fullstring += "-{0}".format(tag)
|
fullstring += "-{0}".format(tag)
|
||||||
if tag == "dev":
|
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("""
|
fp.write("""
|
||||||
#ifndef _AMXMODX_AUTO_VERSION_INFORMATION_H_
|
#ifndef _AMXMODX_AUTO_VERSION_INFORMATION_H_
|
||||||
#define _AMXMODX_AUTO_VERSION_INFORMATION_H_
|
#define _AMXMODX_AUTO_VERSION_INFORMATION_H_
|
||||||
|
|
||||||
#define SVN_VERSION_STRING "{fullstring}"
|
#define AMXX_BUILD_TAG \"{0}\"
|
||||||
#define SVN_VERSION_DWORD {major}, {minor}, {release}, 0
|
#define AMXX_BUILD_CSET \"{1}\"
|
||||||
#define SVN_VERSION_PRODUCT "{product}"
|
#define AMXX_BUILD_MAJOR \"{2}\"
|
||||||
#define SVN_VERSION SVN_VERSION_STRING
|
#define AMXX_BUILD_MINOR \"{3}\"
|
||||||
#define SVN_BUILD_ID "{count}:{longhash}"
|
#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_
|
#endif // _AMXMODX_AUTO_VERSION_INFORMATION_H_
|
||||||
""".format(
|
""".format(tag, shorthash, major, minor, release, fullstring, count))
|
||||||
fullstring = fullstring,
|
|
||||||
major = major,
|
|
||||||
minor = minor,
|
|
||||||
release = release,
|
|
||||||
product = product,
|
|
||||||
count = count,
|
|
||||||
longhash = longhash
|
|
||||||
))
|
|
||||||
|
|
||||||
version_num = int(major) * 100 + int(minor) * 10 + int(release)
|
version_num = int(major) * 100 + int(minor) * 10 + int(release)
|
||||||
with open(os.path.join(OutputFolder, 'amxmodx_version.inc'), 'w') as fp:
|
with open(os.path.join(OutputFolder, 'amxmodx_version.inc'), 'w') as fp:
|
||||||
|
@ -92,13 +90,23 @@ def output_version_headers():
|
||||||
#endif
|
#endif
|
||||||
#define _amxmodx_version_included
|
#define _amxmodx_version_included
|
||||||
|
|
||||||
#define AMXX_VERSION {major}.{minor}{release}
|
#define AMXX_VERSION_TAG \"{tag}\"
|
||||||
#define AMXX_VERSION_NUM {version_num}
|
#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}";
|
stock const AMXX_VERSION_STR[] = "{fullstring}";
|
||||||
""".format(
|
""".format(
|
||||||
|
tag = tag,
|
||||||
|
shorthash = shorthash,
|
||||||
major = major,
|
major = major,
|
||||||
minor = minor,
|
minor = minor,
|
||||||
release = release,
|
release = release,
|
||||||
|
count = count,
|
||||||
version_num = version_num,
|
version_num = version_num,
|
||||||
fullstring = fullstring
|
fullstring = fullstring
|
||||||
))
|
))
|
||||||
|
|
15
support/versionlib/AMBuilder
Normal file
15
support/versionlib/AMBuilder
Normal 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
|
8
support/versionlib/versionlib.cpp
Normal file
8
support/versionlib/versionlib.cpp
Normal 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__;
|
24
support/versionlib/versionlib.h
Normal file
24
support/versionlib/versionlib.h
Normal 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_
|
Loading…
Reference in New Issue
Block a user