|
|
@ -3,27 +3,28 @@ |
|
|
|
# a1batross, mittorn, 2018 |
|
|
|
# a1batross, mittorn, 2018 |
|
|
|
|
|
|
|
|
|
|
|
from __future__ import print_function |
|
|
|
from __future__ import print_function |
|
|
|
from waflib import Logs |
|
|
|
from waflib import Logs, Options |
|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
|
import os |
|
|
|
import sys |
|
|
|
import sys |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VERSION = '0.99' |
|
|
|
|
|
|
|
APPNAME = 'xash3d-fwgs' |
|
|
|
|
|
|
|
SUBDIRS = [ 'game_launch', 'mainui', 'vgui_support', 'engine' ] |
|
|
|
|
|
|
|
top = '.' |
|
|
|
|
|
|
|
|
|
|
|
def get_git_version(): |
|
|
|
def get_git_version(): |
|
|
|
# try grab the current version number from git |
|
|
|
# try grab the current version number from git |
|
|
|
version = "notset" |
|
|
|
version = 'notset' |
|
|
|
if os.path.exists(".git"): |
|
|
|
if os.path.exists('.git'): |
|
|
|
try: |
|
|
|
try: |
|
|
|
version = os.popen("git describe --dirty --always").read().strip() |
|
|
|
version = os.popen('git describe --dirty --always').read().strip() |
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
print(e) |
|
|
|
pass |
|
|
|
return version |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VERSION = '0.99' |
|
|
|
if(len(version) == 0): |
|
|
|
APPNAME = 'xash3d-fwgs' |
|
|
|
version = 'notset' |
|
|
|
GIT_SHA = get_git_version() |
|
|
|
|
|
|
|
SUBDIRS = [ 'game_launch', 'vgui_support', 'engine', 'mainui' ] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
top = '.' |
|
|
|
return version |
|
|
|
|
|
|
|
|
|
|
|
def options(opt): |
|
|
|
def options(opt): |
|
|
|
opt.load('compiler_cxx compiler_c') |
|
|
|
opt.load('compiler_cxx compiler_c') |
|
|
@ -42,6 +43,10 @@ def options(opt): |
|
|
|
'--release', action = 'store_true', dest = 'RELEASE', default = False, |
|
|
|
'--release', action = 'store_true', dest = 'RELEASE', default = False, |
|
|
|
help = 'strip debug info from binary and enable optimizations') |
|
|
|
help = 'strip debug info from binary and enable optimizations') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opt.add_option( |
|
|
|
|
|
|
|
'--no-download-deps', action = 'store_false', dest = 'AUTODL', default = True, |
|
|
|
|
|
|
|
help = 'don\'t try to download dependencies from network') |
|
|
|
|
|
|
|
|
|
|
|
opt.add_option( |
|
|
|
opt.add_option( |
|
|
|
'--win-style-install', action = 'store_true', dest = 'WIN_INSTALL', default = False, |
|
|
|
'--win-style-install', action = 'store_true', dest = 'WIN_INSTALL', default = False, |
|
|
|
help = 'install like Windows build, ignore prefix, useful for development') |
|
|
|
help = 'install like Windows build, ignore prefix, useful for development') |
|
|
@ -49,46 +54,53 @@ def options(opt): |
|
|
|
opt.recurse(SUBDIRS) |
|
|
|
opt.recurse(SUBDIRS) |
|
|
|
|
|
|
|
|
|
|
|
def configure(conf): |
|
|
|
def configure(conf): |
|
|
|
conf.env.MSVC_TARGETS = ['x86'] |
|
|
|
conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC |
|
|
|
conf.load('compiler_cxx compiler_c') |
|
|
|
conf.load('compiler_cxx compiler_c') |
|
|
|
if(conf.env.COMPILER_CC != 'msvc'): |
|
|
|
if sys.platform == 'win32': |
|
|
|
|
|
|
|
conf.load('msvc msvs') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if we have 64-bit toolchain |
|
|
|
|
|
|
|
conf.env.DEST_64BIT = False # predict state |
|
|
|
|
|
|
|
try: |
|
|
|
conf.check_cc( |
|
|
|
conf.check_cc( |
|
|
|
fragment=''' |
|
|
|
fragment=''' |
|
|
|
#include <stdio.h> |
|
|
|
int main( void ) |
|
|
|
int main( void ) { printf("%ld", sizeof( void * )); return 0; } |
|
|
|
{ |
|
|
|
|
|
|
|
int check[sizeof(void*) == 4 ? 1: -1]; |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
''', |
|
|
|
''', |
|
|
|
execute = True, |
|
|
|
msg = 'Checking if compiler create 32 bit code') |
|
|
|
define_ret = True, |
|
|
|
except conf.errors.ConfigurationError: |
|
|
|
uselib_store = 'SIZEOF_VOID_P', |
|
|
|
# Program not compiled, we have 64 bit |
|
|
|
msg = 'Checking sizeof(void*)') |
|
|
|
conf.env.DEST_64BIT = True |
|
|
|
else: |
|
|
|
|
|
|
|
conf.env.SIZEOF_VOID_P = '4' # TODO: detect target |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(int(conf.env.SIZEOF_VOID_P) != 4): |
|
|
|
if(conf.env.DEST_64BIT): |
|
|
|
if(not conf.options.ALLOW64): |
|
|
|
if(not conf.options.ALLOW64): |
|
|
|
conf.env.append_value('LINKFLAGS', '-m32') |
|
|
|
conf.env.append_value('LINKFLAGS', ['-m32']) |
|
|
|
conf.env.append_value('CFLAGS', '-m32') |
|
|
|
conf.env.append_value('CFLAGS', ['-m32']) |
|
|
|
conf.env.append_value('CXXFLAGS', '-m32') |
|
|
|
conf.env.append_value('CXXFLAGS', ['-m32']) |
|
|
|
Logs.info('NOTE: will build engine with 64-bit toolchain using -m32') |
|
|
|
Logs.info('NOTE: will build engine with 64-bit toolchain using -m32') |
|
|
|
else: |
|
|
|
else: |
|
|
|
Logs.warn('WARNING: 64-bit engine may be unstable') |
|
|
|
Logs.warn('WARNING: 64-bit engine may be unstable') |
|
|
|
|
|
|
|
|
|
|
|
if(conf.env.COMPILER_CC != 'msvc'): |
|
|
|
if(conf.env.COMPILER_CC != 'msvc'): |
|
|
|
if(conf.env.COMPILER_CC == 'gcc'): |
|
|
|
if(conf.env.COMPILER_CC == 'gcc'): |
|
|
|
conf.env.append_value('LINKFLAGS', '-Wl,--no-undefined') |
|
|
|
conf.env.append_unique('LINKFLAGS', ['-Wl,--no-undefined']) |
|
|
|
if(conf.options.RELEASE): |
|
|
|
if(conf.options.RELEASE): |
|
|
|
conf.env.append_unique('CFLAGS', '-O2') |
|
|
|
conf.env.append_unique('CFLAGS', ['-O2']) |
|
|
|
conf.env.append_unique('CXXFLAGS', '-O2') |
|
|
|
conf.env.append_unique('CXXFLAGS', ['-O2']) |
|
|
|
else: |
|
|
|
else: |
|
|
|
conf.env.append_unique('CFLAGS', '-Og') |
|
|
|
conf.env.append_unique('CFLAGS', ['-Og', '-g']) |
|
|
|
conf.env.append_unique('CFLAGS', '-g') |
|
|
|
conf.env.append_unique('CXXFLAGS', ['-Og', '-g']) |
|
|
|
conf.env.append_unique('CXXFLAGS', '-Og') |
|
|
|
else: |
|
|
|
conf.env.append_unique('CXXFLAGS', '-g') |
|
|
|
if(conf.options.RELEASE): |
|
|
|
|
|
|
|
conf.env.append_unique('CFLAGS', ['/O2']) |
|
|
|
|
|
|
|
conf.env.append_unique('CXXFLAGS', ['/O2']) |
|
|
|
else: |
|
|
|
else: |
|
|
|
if(not conf.options.RELEASE): |
|
|
|
conf.env.append_unique('CFLAGS', ['/Z7']) |
|
|
|
conf.env.append_unique('CFLAGS', '/Z7') |
|
|
|
conf.env.append_unique('CXXFLAGS', ['/Z7']) |
|
|
|
conf.env.append_unique('CXXFLAGS', '/Z7') |
|
|
|
conf.env.append_unique('LINKFLAGS', ['/DEBUG']) |
|
|
|
conf.env.append_unique('LINKFLAGS', '/DEBUG') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(conf.env.DEST_OS != 'win32'): |
|
|
|
if(conf.env.DEST_OS != 'win32'): |
|
|
|
conf.check( lib='dl' ) |
|
|
|
conf.check( lib='dl' ) |
|
|
@ -96,7 +108,7 @@ def configure(conf): |
|
|
|
conf.check( lib='pthread' ) |
|
|
|
conf.check( lib='pthread' ) |
|
|
|
|
|
|
|
|
|
|
|
conf.env.DEDICATED = conf.options.DEDICATED |
|
|
|
conf.env.DEDICATED = conf.options.DEDICATED |
|
|
|
conf.env.SINGLE_BINARY = conf.options.DEDICATED |
|
|
|
conf.env.SINGLE_BINARY = conf.options.DEDICATED # We don't need game launcher on dedicated |
|
|
|
|
|
|
|
|
|
|
|
# indicate if we are packaging for Linux/BSD |
|
|
|
# indicate if we are packaging for Linux/BSD |
|
|
|
if(not conf.options.WIN_INSTALL and |
|
|
|
if(not conf.options.WIN_INSTALL and |
|
|
@ -107,15 +119,18 @@ def configure(conf): |
|
|
|
# prefix is ignored |
|
|
|
# prefix is ignored |
|
|
|
conf.env.LIBDIR = conf.env.BINDIR = '/' |
|
|
|
conf.env.LIBDIR = conf.env.BINDIR = '/' |
|
|
|
|
|
|
|
|
|
|
|
# global |
|
|
|
conf.start_msg('Checking git hash') |
|
|
|
conf.env.append_unique('XASH_BUILD_COMMIT', GIT_SHA) |
|
|
|
git_version = get_git_version() |
|
|
|
|
|
|
|
conf.end_msg(git_version) |
|
|
|
|
|
|
|
conf.env.append_unique('DEFINES', 'XASH_BUILD_COMMIT="' + git_version + '"') |
|
|
|
|
|
|
|
|
|
|
|
for i in SUBDIRS: |
|
|
|
for i in SUBDIRS: |
|
|
|
conf.setenv(i, conf.env) # derive new env from global one |
|
|
|
conf.setenv(i, conf.env) # derive new env from global one |
|
|
|
conf.env.ENVNAME = i |
|
|
|
conf.env.ENVNAME = i |
|
|
|
Logs.info('Configuring ' + i) |
|
|
|
conf.msg(msg='Configuring ' + i, result='in progress', color='BLUE') |
|
|
|
# configure in standalone env |
|
|
|
# configure in standalone env |
|
|
|
conf.recurse(i) |
|
|
|
conf.recurse(i) |
|
|
|
|
|
|
|
conf.msg(msg='Configuring ' + i, result='done', color='BLUE') |
|
|
|
conf.setenv('') |
|
|
|
conf.setenv('') |
|
|
|
|
|
|
|
|
|
|
|
def build(bld): |
|
|
|
def build(bld): |
|
|
|