You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
3.7 KiB
197 lines
3.7 KiB
![]()
7 years ago
|
/*
|
||
|
build.c - returns a engine build number
|
||
|
Copyright (C) 2010 Uncle Mike
|
||
|
|
||
|
This program is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
*/
|
||
|
|
||
![]()
2 years ago
|
#include "crtlib.h"
|
||
![]()
7 years ago
|
|
||
![]()
3 years ago
|
static const char *date = __DATE__ ;
|
||
|
static const char *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 };
|
||
![]()
7 years ago
|
|
||
![]()
5 years ago
|
// returns days since Apr 1 2015
|
||
![]()
7 years ago
|
int Q_buildnum( void )
|
||
|
{
|
||
|
int m = 0, d = 0, y = 0;
|
||
|
static int b = 0;
|
||
|
|
||
|
if( b != 0 ) return b;
|
||
|
|
||
|
for( m = 0; m < 11; m++ )
|
||
|
{
|
||
|
if( !Q_strnicmp( &date[0], mon[m], 3 ))
|
||
|
break;
|
||
|
d += mond[m];
|
||
|
}
|
||
|
|
||
|
d += Q_atoi( &date[4] ) - 1;
|
||
|
y = Q_atoi( &date[7] ) - 1900;
|
||
|
b = d + (int)((y - 1) * 365.25f );
|
||
|
|
||
|
if((( y % 4 ) == 0 ) && m > 1 )
|
||
|
{
|
||
|
b += 1;
|
||
|
}
|
||
![]()
5 years ago
|
b -= 41728; // Apr 1 2015
|
||
![]()
7 years ago
|
|
||
|
return b;
|
||
![]()
5 years ago
|
}
|
||
|
|
||
|
/*
|
||
|
=============
|
||
|
Q_buildnum_compat
|
||
|
|
||
|
Returns a Xash3D build number. This is left for compability with original Xash3D.
|
||
|
IMPORTANT: this value must be changed ONLY after updating to newer Xash3D
|
||
|
IMPORTANT: this value must be acquired through "build" cvar.
|
||
|
=============
|
||
|
*/
|
||
|
int Q_buildnum_compat( void )
|
||
|
{
|
||
|
// do not touch this! Only author of Xash3D can increase buildnumbers!
|
||
![]()
5 years ago
|
return 4529;
|
||
![]()
6 years ago
|
}
|
||
|
|
||
|
/*
|
||
|
============
|
||
|
Q_buildos
|
||
|
|
||
|
Returns current name of operating system. Without any spaces.
|
||
|
============
|
||
|
*/
|
||
|
const char *Q_buildos( void )
|
||
|
{
|
||
|
const char *osname;
|
||
|
|
||
![]()
5 years ago
|
#if XASH_MINGW
|
||
![]()
5 years ago
|
osname = "win32-mingw";
|
||
![]()
5 years ago
|
#elif XASH_WIN32
|
||
![]()
5 years ago
|
osname = "win32";
|
||
![]()
5 years ago
|
#elif XASH_ANDROID
|
||
![]()
5 years ago
|
osname = "android";
|
||
![]()
5 years ago
|
#elif XASH_LINUX
|
||
![]()
5 years ago
|
osname = "linux";
|
||
![]()
5 years ago
|
#elif XASH_APPLE
|
||
![]()
5 years ago
|
osname = "apple";
|
||
![]()
5 years ago
|
#elif XASH_FREEBSD
|
||
![]()
5 years ago
|
osname = "freebsd";
|
||
![]()
5 years ago
|
#elif XASH_NETBSD
|
||
![]()
5 years ago
|
osname = "netbsd";
|
||
![]()
5 years ago
|
#elif XASH_OPENBSD
|
||
![]()
5 years ago
|
osname = "openbsd";
|
||
![]()
5 years ago
|
#elif XASH_EMSCRIPTEN
|
||
![]()
5 years ago
|
osname = "emscripten";
|
||
![]()
5 years ago
|
#elif XASH_DOS4GW
|
||
|
osname = "DOS4GW";
|
||
![]()
3 years ago
|
#elif XASH_HAIKU
|
||
|
osname = "haiku";
|
||
![]()
3 years ago
|
#elif XASH_SERENITY
|
||
|
osname = "serenityos";
|
||
![]()
6 years ago
|
#else
|
||
|
#error "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug"
|
||
|
#endif
|
||
|
|
||
|
return osname;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
============
|
||
![]()
3 years ago
|
Q_buildarch
|
||
![]()
6 years ago
|
|
||
![]()
3 years ago
|
Returns current name of the architecture. Without any spaces.
|
||
![]()
6 years ago
|
============
|
||
|
*/
|
||
|
const char *Q_buildarch( void )
|
||
|
{
|
||
|
const char *archname;
|
||
|
|
||
![]()
5 years ago
|
#if XASH_AMD64
|
||
![]()
6 years ago
|
archname = "amd64";
|
||
![]()
5 years ago
|
#elif XASH_X86
|
||
![]()
6 years ago
|
archname = "i386";
|
||
![]()
4 years ago
|
#elif XASH_ARM && XASH_64BIT
|
||
![]()
5 years ago
|
archname = "arm64";
|
||
|
#elif XASH_ARM
|
||
|
archname = "armv"
|
||
![]()
4 years ago
|
#if XASH_ARM == 8
|
||
|
"8_32" // for those who (mis)using 32-bit OS on 64-bit CPU
|
||
|
#elif XASH_ARM == 7
|
||
![]()
5 years ago
|
"7"
|
||
|
#elif XASH_ARM == 6
|
||
|
"6"
|
||
|
#elif XASH_ARM == 5
|
||
|
"5"
|
||
|
#elif XASH_ARM == 4
|
||
|
"4"
|
||
|
#endif
|
||
![]()
5 years ago
|
|
||
![]()
5 years ago
|
#if XASH_ARM_HARDFP
|
||
![]()
3 years ago
|
"hf"
|
||
![]()
5 years ago
|
#else
|
||
![]()
3 years ago
|
"l"
|
||
![]()
5 years ago
|
#endif
|
||
![]()
3 years ago
|
;
|
||
![]()
5 years ago
|
#elif XASH_MIPS && XASH_BIG_ENDIAN
|
||
![]()
3 years ago
|
archname = "mips"
|
||
|
#if XASH_64BIT
|
||
|
"64"
|
||
|
#endif
|
||
|
#if XASH_LITTLE_ENDIAN
|
||
|
"el"
|
||
|
#endif
|
||
|
;
|
||
|
#elif XASH_RISCV
|
||
|
archname = "riscv"
|
||
|
#if XASH_64BIT
|
||
|
"64"
|
||
|
#else
|
||
|
"32"
|
||
|
#endif
|
||
|
#if XASH_RISCV_SINGLEFP
|
||
|
"d"
|
||
|
#elif XASH_RISCV_DOUBLEFP
|
||
|
"f"
|
||
|
#endif
|
||
|
;
|
||
![]()
5 years ago
|
#elif XASH_JS
|
||
![]()
6 years ago
|
archname = "javascript";
|
||
![]()
5 years ago
|
#elif XASH_E2K
|
||
|
archname = "e2k";
|
||
![]()
6 years ago
|
#else
|
||
|
#error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug"
|
||
|
#endif
|
||
|
|
||
|
return archname;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
=============
|
||
|
Q_buildcommit
|
||
|
|
||
|
Returns a short hash of current commit in VCS as string.
|
||
|
XASH_BUILD_COMMIT must be passed in quotes
|
||
|
|
||
|
if XASH_BUILD_COMMIT is not defined,
|
||
![]()
5 years ago
|
Q_buildcommit will identify this build as "notset"
|
||
![]()
6 years ago
|
=============
|
||
|
*/
|
||
|
const char *Q_buildcommit( void )
|
||
|
{
|
||
|
#ifdef XASH_BUILD_COMMIT
|
||
|
return XASH_BUILD_COMMIT;
|
||
|
#else
|
||
|
return "notset";
|
||
|
#endif
|
||
|
}
|
||
![]()
6 years ago
|
|