mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-11 15:47:55 +00:00
wscript: move some code to our waflib, remove --no-gcc-colors, as newer GCC colorize output automatically, so there is no need in -fdisagnostic-colors=aloways flag, move common win32 libraries check here, better output for subprojects
This commit is contained in:
parent
ede52d7808
commit
bbde1394e1
137
wscript
137
wscript
@ -4,49 +4,27 @@
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from waflib import Logs, Options
|
from waflib import Logs, Options
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
sys.path.append(os.path.realpath('scripts/waflib'))
|
||||||
|
# print(sys.path)
|
||||||
|
import fwgslib
|
||||||
|
|
||||||
VERSION = '0.99'
|
VERSION = '0.99'
|
||||||
APPNAME = 'xash3d-fwgs'
|
APPNAME = 'xash3d-fwgs'
|
||||||
SUBDIRS = [ 'game_launch', 'mainui', 'vgui_support', 'engine' ]
|
SUBDIRS = [ 'engine', 'game_launch', 'mainui', 'vgui_support' ]
|
||||||
top = '.'
|
top = '.'
|
||||||
|
|
||||||
def get_git_version():
|
|
||||||
# try grab the current version number from git
|
|
||||||
version = 'notset'
|
|
||||||
if os.path.exists('.git'):
|
|
||||||
try:
|
|
||||||
version = os.popen('git describe --dirty --always').read().strip()
|
|
||||||
except Exception as e:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if(len(version) == 0):
|
|
||||||
version = 'notset'
|
|
||||||
|
|
||||||
return version
|
|
||||||
|
|
||||||
def get_flags_by_compiler(flags, compiler):
|
|
||||||
out = []
|
|
||||||
if compiler in flags:
|
|
||||||
out += flags[compiler]
|
|
||||||
elif 'default' in flags:
|
|
||||||
out += flags['default']
|
|
||||||
return out
|
|
||||||
|
|
||||||
def get_flags_by_type(flags, type, compiler):
|
|
||||||
out = []
|
|
||||||
if 'common' in flags:
|
|
||||||
out += get_flags_by_compiler(flags['common'], compiler)
|
|
||||||
if type in flags:
|
|
||||||
out += get_flags_by_compiler(flags[type], compiler)
|
|
||||||
return out
|
|
||||||
|
|
||||||
def options(opt):
|
def options(opt):
|
||||||
opt.load('compiler_cxx compiler_c')
|
opt.load('compiler_cxx compiler_c')
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
opt.load('msvc msvs')
|
opt.load('msvc msvs')
|
||||||
|
|
||||||
|
opt.add_option(
|
||||||
|
'--build-type', action='store', type='string', dest='BUILD_TYPE', default = None,
|
||||||
|
help = 'build type: debug, release or none(custom flags)')
|
||||||
|
|
||||||
opt.add_option(
|
opt.add_option(
|
||||||
'--dedicated', action = 'store_true', dest = 'DEDICATED', default = False,
|
'--dedicated', action = 'store_true', dest = 'DEDICATED', default = False,
|
||||||
help = 'build Xash Dedicated Server(XashDS)')
|
help = 'build Xash Dedicated Server(XashDS)')
|
||||||
@ -59,18 +37,6 @@ def options(opt):
|
|||||||
'--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')
|
||||||
|
|
||||||
opt.add_option(
|
|
||||||
'--no-gcc-colors', action = 'store_false', dest = 'GCC_COLORS', default = True,
|
|
||||||
help = 'do not enable gcc colors')
|
|
||||||
|
|
||||||
opt.add_option(
|
|
||||||
'--sdl2', action='store', type='string', dest = 'SDL2_PATH', default = None,
|
|
||||||
help = 'SDL2 path to build(required for Windows)')
|
|
||||||
|
|
||||||
opt.add_option(
|
|
||||||
'--build-type', action='store', type='string', dest='BUILD_TYPE', default = None,
|
|
||||||
help = 'build type: debug, release or none(custom flags)')
|
|
||||||
|
|
||||||
opt.recurse(SUBDIRS)
|
opt.recurse(SUBDIRS)
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
@ -83,42 +49,27 @@ def configure(conf):
|
|||||||
conf.fatal('Invalid build type. Valid are "debug", "release" or "none"')
|
conf.fatal('Invalid build type. Valid are "debug", "release" or "none"')
|
||||||
conf.end_msg(conf.options.BUILD_TYPE)
|
conf.end_msg(conf.options.BUILD_TYPE)
|
||||||
|
|
||||||
|
# Force XP compability, all build targets should add
|
||||||
|
# subsystem=bld.env.MSVC_SUBSYSTEM
|
||||||
|
# TODO: wrapper around bld.stlib, bld.shlib and so on?
|
||||||
|
conf.env.MSVC_SUBSYSTEM = 'WINDOWS,5.01'
|
||||||
conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC
|
conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC
|
||||||
conf.load('compiler_cxx compiler_c')
|
conf.load('compiler_cxx compiler_c gitversion')
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
conf.load('msvc msvs')
|
conf.load('msvc msvs')
|
||||||
|
|
||||||
# Check if we have 64-bit toolchain
|
conf.env.BIT32_MANDATORY = not conf.options.ALLOW64
|
||||||
conf.env.DEST_64BIT = False # predict state
|
conf.env.BIT32_ALLOW64 = conf.options.ALLOW64
|
||||||
try:
|
conf.load('force_32bit')
|
||||||
conf.check_cc(
|
|
||||||
fragment='''int main( void )
|
|
||||||
{
|
|
||||||
int check[sizeof(void*) == 4 ? 1: -1];
|
|
||||||
return 0;
|
|
||||||
}''',
|
|
||||||
msg = 'Checking if compiler create 32 bit code')
|
|
||||||
except conf.errors.ConfigurationError:
|
|
||||||
# Program not compiled, we have 64 bit
|
|
||||||
conf.env.DEST_64BIT = True
|
|
||||||
|
|
||||||
|
if conf.env.DEST_SIZEOF_VOID_P == 4:
|
||||||
if(conf.env.DEST_64BIT):
|
Logs.info('NOTE: will build engine for 32-bit target')
|
||||||
if(not conf.options.ALLOW64):
|
|
||||||
flag = '-m32'
|
|
||||||
# Think different.
|
|
||||||
if(conf.env.DEST_OS == 'darwin'):
|
|
||||||
flag = '-arch i386'
|
|
||||||
conf.env.append_value('LINKFLAGS', [flag])
|
|
||||||
conf.env.append_value('CFLAGS', [flag])
|
|
||||||
conf.env.append_value('CXXFLAGS', [flag])
|
|
||||||
Logs.info('NOTE: will build engine with 64-bit toolchain using %s' % flag)
|
|
||||||
else:
|
else:
|
||||||
Logs.warn('WARNING: 64-bit engine may be unstable')
|
Logs.warn('WARNING: 64-bit engine may be unstable')
|
||||||
|
|
||||||
linker_flags = {
|
linker_flags = {
|
||||||
'common': {
|
'common': {
|
||||||
'msvc': ['/DEBUG'],
|
'msvc': ['/DEBUG'], # always create PDB, doesn't affect result binaries
|
||||||
'default': ['-Wl,--no-undefined']
|
'default': ['-Wl,--no-undefined']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,28 +90,35 @@ def configure(conf):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.env.append_unique('CFLAGS', get_flags_by_type(
|
conf.env.append_unique('CFLAGS', fwgslib.get_flags_by_type(
|
||||||
compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC))
|
compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC))
|
||||||
conf.env.append_unique('CXXFLAGS', get_flags_by_type(
|
conf.env.append_unique('CXXFLAGS', fwgslib.get_flags_by_type(
|
||||||
compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC))
|
compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC))
|
||||||
conf.env.append_unique('LINKFLAGS', get_flags_by_type(
|
conf.env.append_unique('LINKFLAGS', fwgslib.get_flags_by_type(
|
||||||
linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC))
|
linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC))
|
||||||
|
|
||||||
# Force XP compability, all build targets should add
|
|
||||||
# subsystem=bld.env.MSVC_SUBSYSTEM
|
|
||||||
# TODO: wrapper around bld.stlib, bld.shlib and so on?
|
|
||||||
conf.env.MSVC_SUBSYSTEM = 'WINDOWS,5.01'
|
|
||||||
|
|
||||||
if(conf.env.DEST_OS == 'linux'):
|
|
||||||
conf.check( lib='dl' )
|
|
||||||
|
|
||||||
if(conf.env.DEST_OS != 'win32'):
|
|
||||||
conf.check( lib='m' )
|
|
||||||
conf.check( lib='pthread' )
|
|
||||||
|
|
||||||
conf.env.DEDICATED = conf.options.DEDICATED
|
conf.env.DEDICATED = conf.options.DEDICATED
|
||||||
conf.env.SINGLE_BINARY = conf.options.DEDICATED # We don't need game launcher on dedicated
|
conf.env.SINGLE_BINARY = conf.options.DEDICATED # We don't need game launcher on dedicated
|
||||||
|
|
||||||
|
if conf.env.DEST_OS == 'linux':
|
||||||
|
conf.check( lib='dl' )
|
||||||
|
|
||||||
|
if conf.env.DEST_OS != 'win32':
|
||||||
|
conf.check( lib='m' )
|
||||||
|
conf.check( lib='pthread' )
|
||||||
|
else:
|
||||||
|
# Common Win32 libraries
|
||||||
|
# Don't check them more than once, to save time
|
||||||
|
# Usually, they are always available
|
||||||
|
# but we need them in uselib
|
||||||
|
conf.check( lib='user32' )
|
||||||
|
conf.check( lib='shell32' )
|
||||||
|
conf.check( lib='gdi32' )
|
||||||
|
conf.check( lib='advapi32' )
|
||||||
|
conf.check( lib='dbghelp' )
|
||||||
|
conf.check( lib='psapi' )
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
conf.env.DEST_OS != 'win32' and
|
conf.env.DEST_OS != 'win32' and
|
||||||
@ -169,18 +127,15 @@ def configure(conf):
|
|||||||
else:
|
else:
|
||||||
conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX
|
conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX
|
||||||
|
|
||||||
conf.start_msg('Checking git hash')
|
conf.env.append_unique('DEFINES', 'XASH_BUILD_COMMIT="' + conf.env.GIT_VERSION if conf.env.GITVERSION else 'notset' + '"')
|
||||||
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
|
||||||
conf.msg(msg='Configuring ' + i, result='in progress', color='BLUE')
|
conf.msg(msg='--> ' + 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.msg(msg='<-- ' + i, result='done', color='BLUE')
|
||||||
conf.setenv('')
|
conf.setenv('')
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
|
Loading…
Reference in New Issue
Block a user