public: use last Git commit date (committer date, to be exact) as more predictable source for build num
This commit is contained in:
parent
8f257cc331
commit
c48d93e3ce
4 changed files with 29 additions and 5 deletions
|
@ -17,7 +17,7 @@ GNU General Public License for more details.
|
||||||
#include "crtlib.h"
|
#include "crtlib.h"
|
||||||
#include "buildenums.h"
|
#include "buildenums.h"
|
||||||
|
|
||||||
static const char *mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
static const char *const mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||||
static const char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
static const char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||||
|
|
||||||
int Q_buildnum_date( const char *date )
|
int Q_buildnum_date( const char *date )
|
||||||
|
@ -80,8 +80,13 @@ int Q_buildnum( void )
|
||||||
{
|
{
|
||||||
static int b = 0;
|
static int b = 0;
|
||||||
|
|
||||||
if( !b )
|
if( b ) return b;
|
||||||
b = Q_buildnum_date( __DATE__ );
|
|
||||||
|
if( COM_CheckString( g_buildcommit_date ))
|
||||||
|
b = Q_buildnum_iso( g_buildcommit_date );
|
||||||
|
|
||||||
|
if( b <= 0 )
|
||||||
|
b = Q_buildnum_date( g_build_date );
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,4 +15,5 @@ GNU General Public License for more details.
|
||||||
|
|
||||||
const char *g_buildcommit = XASH_BUILD_COMMIT;
|
const char *g_buildcommit = XASH_BUILD_COMMIT;
|
||||||
const char *g_buildbranch = XASH_BUILD_BRANCH;
|
const char *g_buildbranch = XASH_BUILD_BRANCH;
|
||||||
|
const char *g_buildcommit_date = XASH_BUILD_COMMIT_DATE;
|
||||||
|
const char *g_build_date = __DATE__;
|
||||||
|
|
|
@ -65,6 +65,8 @@ const char *Q_ArchitectureStringByID( const int arch, const uint abi, const int
|
||||||
const char *Q_buildarch( void );
|
const char *Q_buildarch( void );
|
||||||
extern const char *g_buildcommit;
|
extern const char *g_buildcommit;
|
||||||
extern const char *g_buildbranch;
|
extern const char *g_buildbranch;
|
||||||
|
extern const char *g_build_date;
|
||||||
|
extern const char *g_buildcommit_date;
|
||||||
|
|
||||||
//
|
//
|
||||||
// crtlib.c
|
// crtlib.c
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# mittorn, 2018
|
# mittorn, 2018
|
||||||
|
|
||||||
from waflib import Logs, Configure
|
from waflib import Logs, Configure
|
||||||
|
from waflib.extras import gitversion
|
||||||
import os
|
import os
|
||||||
|
|
||||||
top = '.'
|
top = '.'
|
||||||
|
@ -60,6 +61,16 @@ def export_define(conf, define, value=1):
|
||||||
def simple_check(conf, fragment, msg, mandatory=False, **kw):
|
def simple_check(conf, fragment, msg, mandatory=False, **kw):
|
||||||
return conf.check_cc(fragment=fragment, msg='Checking for %s' % msg, mandatory=mandatory, **kw)
|
return conf.check_cc(fragment=fragment, msg='Checking for %s' % msg, mandatory=mandatory, **kw)
|
||||||
|
|
||||||
|
@Configure.conf
|
||||||
|
def get_git_commit_date(conf):
|
||||||
|
node = conf.srcnode.find_node('.git')
|
||||||
|
|
||||||
|
if not node:
|
||||||
|
Logs.debug('can\'t find .git in conf.srcnode')
|
||||||
|
return None
|
||||||
|
|
||||||
|
return gitversion.run_git(conf, ['log', '-1', '--format=%ci'])
|
||||||
|
|
||||||
def options(opt):
|
def options(opt):
|
||||||
opt.add_option('--validate-target', action='store', dest='VALIDATE_TARGET', default=None,
|
opt.add_option('--validate-target', action='store', dest='VALIDATE_TARGET', default=None,
|
||||||
help='development option, needs --enable-tests flag')
|
help='development option, needs --enable-tests flag')
|
||||||
|
@ -67,6 +78,11 @@ def options(opt):
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
# private to libpublic
|
# private to libpublic
|
||||||
conf.load('gitversion')
|
conf.load('gitversion')
|
||||||
|
|
||||||
|
conf.start_msg('Git commit date')
|
||||||
|
conf.env.GIT_COMMIT_DATE = conf.get_git_commit_date()
|
||||||
|
conf.end_msg(conf.env.GIT_COMMIT_DATE)
|
||||||
|
|
||||||
conf.env.VALIDATE_TARGET = conf.options.VALIDATE_TARGET
|
conf.env.VALIDATE_TARGET = conf.options.VALIDATE_TARGET
|
||||||
|
|
||||||
# need to expose it for everyone using libpublic headers
|
# need to expose it for everyone using libpublic headers
|
||||||
|
@ -121,7 +137,7 @@ def build(bld):
|
||||||
# build it separately to slightly improve rebuild times
|
# build it separately to slightly improve rebuild times
|
||||||
bld.stlib(source = 'build_vcs.c',
|
bld.stlib(source = 'build_vcs.c',
|
||||||
target = 'build_vcs',
|
target = 'build_vcs',
|
||||||
defines = ['XASH_BUILD_COMMIT=\"%s\"' % bld.env.GIT_VERSION, 'XASH_BUILD_BRANCH=\"%s\"' % bld.env.GIT_BRANCH])
|
defines = ['XASH_BUILD_COMMIT=\"%s\"' % bld.env.GIT_VERSION, 'XASH_BUILD_BRANCH=\"%s\"' % bld.env.GIT_BRANCH, 'XASH_BUILD_COMMIT_DATE=\"%s\"' % bld.env.GIT_COMMIT_DATE])
|
||||||
|
|
||||||
bld.stlib(source = bld.path.ant_glob('*.c', excl='build_vcs.c'),
|
bld.stlib(source = bld.path.ant_glob('*.c', excl='build_vcs.c'),
|
||||||
target = 'public',
|
target = 'public',
|
||||||
|
|
Loading…
Add table
Reference in a new issue