|
|
@ -3,15 +3,16 @@ |
|
|
|
# a1batross, mittorn, 2018 |
|
|
|
# a1batross, mittorn, 2018 |
|
|
|
|
|
|
|
|
|
|
|
from __future__ import print_function |
|
|
|
from __future__ import print_function |
|
|
|
from waflib import Logs |
|
|
|
from waflib import Logs, Context, Configure |
|
|
|
import sys |
|
|
|
import sys |
|
|
|
import os |
|
|
|
import os |
|
|
|
sys.path.append(os.path.realpath('scripts/waflib')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VERSION = '2.4' |
|
|
|
VERSION = '2.4' |
|
|
|
APPNAME = 'hlsdk-xash3d' |
|
|
|
APPNAME = 'hlsdk-xash3d' |
|
|
|
top = '.' |
|
|
|
top = '.' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Context.Context.line_just = 55 # should fit for everything on 80x26 |
|
|
|
|
|
|
|
|
|
|
|
def options(opt): |
|
|
|
def options(opt): |
|
|
|
grp = opt.add_option_group('Common options') |
|
|
|
grp = opt.add_option_group('Common options') |
|
|
|
|
|
|
|
|
|
|
@ -19,19 +20,26 @@ def options(opt): |
|
|
|
help = 'build type: debug, release or none(custom flags)') |
|
|
|
help = 'build type: debug, release or none(custom flags)') |
|
|
|
|
|
|
|
|
|
|
|
grp.add_option('-8', '--64bits', action = 'store_true', dest = 'ALLOW64', default = False, |
|
|
|
grp.add_option('-8', '--64bits', action = 'store_true', dest = 'ALLOW64', default = False, |
|
|
|
help = 'allow targetting 64-bit game dlls') |
|
|
|
help = 'allow targetting 64-bit engine(Linux/Windows/OSX x86 only) [default: %default]') |
|
|
|
|
|
|
|
|
|
|
|
grp.add_option('--enable-voicemgr', action = 'store_true', dest = 'VOICEMGR', default = False, |
|
|
|
grp.add_option('--enable-voicemgr', action = 'store_true', dest = 'VOICEMGR', default = False, |
|
|
|
help = 'enable voice manager') |
|
|
|
help = 'enable voice manager [default: %default]') |
|
|
|
|
|
|
|
|
|
|
|
grp.add_option('--enable-goldsrc-support', action = 'store_true', dest = 'GOLDSRC', default = False, |
|
|
|
grp.add_option('--enable-goldsrc-support', action = 'store_true', dest = 'GOLDSRC', default = False, |
|
|
|
help = 'enable GoldSource engine support') |
|
|
|
help = 'enable GoldSource engine support [default: %default]') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grp.add_option('--enable-lto', action = 'store_true', dest = 'LTO', default = False, |
|
|
|
|
|
|
|
help = 'enable Link Time Optimization [default: %default]') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False, |
|
|
|
|
|
|
|
help = 'enable polyhedral optimization if possible [default: %default]') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opt.recurse('cl_dll dlls') |
|
|
|
opt.recurse('cl_dll dlls') |
|
|
|
|
|
|
|
|
|
|
|
opt.load('xcompile compiler_cxx compiler_c clang_compilation_database strip_on_install') |
|
|
|
opt.load('xcompile compiler_cxx compiler_c clang_compilation_database strip_on_install') |
|
|
|
if sys.platform == 'win32': |
|
|
|
if sys.platform == 'win32': |
|
|
|
opt.load('msvc msdev') |
|
|
|
opt.load('msvc msdev msvs') |
|
|
|
opt.load('reconfigure') |
|
|
|
opt.load('reconfigure') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -43,7 +51,7 @@ def configure(conf): |
|
|
|
conf.env.SERVER_NAME = 'hl' |
|
|
|
conf.env.SERVER_NAME = 'hl' |
|
|
|
conf.env.PREFIX = '' |
|
|
|
conf.env.PREFIX = '' |
|
|
|
|
|
|
|
|
|
|
|
conf.load('reconfigure') |
|
|
|
conf.load('fwgslib reconfigure') |
|
|
|
|
|
|
|
|
|
|
|
conf.start_msg('Build type') |
|
|
|
conf.start_msg('Build type') |
|
|
|
if conf.options.BUILD_TYPE == None: |
|
|
|
if conf.options.BUILD_TYPE == None: |
|
|
@ -56,7 +64,7 @@ def configure(conf): |
|
|
|
|
|
|
|
|
|
|
|
# -march=native should not be used |
|
|
|
# -march=native should not be used |
|
|
|
if conf.options.BUILD_TYPE == 'fast': |
|
|
|
if conf.options.BUILD_TYPE == 'fast': |
|
|
|
Logs.warn('WARNING: \'fast\' build type should not be used in release builds') |
|
|
|
Logs.warn('WARNING: \'fast\' build type should not be used in release builds') |
|
|
|
|
|
|
|
|
|
|
|
conf.env.VOICEMGR = conf.options.VOICEMGR |
|
|
|
conf.env.VOICEMGR = conf.options.VOICEMGR |
|
|
|
conf.env.GOLDSRC = conf.options.GOLDSRC |
|
|
|
conf.env.GOLDSRC = conf.options.GOLDSRC |
|
|
@ -71,76 +79,131 @@ def configure(conf): |
|
|
|
conf.load('xcompile compiler_c compiler_cxx strip_on_install') |
|
|
|
conf.load('xcompile compiler_c compiler_cxx strip_on_install') |
|
|
|
|
|
|
|
|
|
|
|
if conf.env.DEST_OS == 'android': |
|
|
|
if conf.env.DEST_OS == 'android': |
|
|
|
conf.options.ALLOW64 = True |
|
|
|
|
|
|
|
conf.options.GOLDSRC = False |
|
|
|
conf.options.GOLDSRC = False |
|
|
|
conf.env.SERVER_NAME = 'server' # can't be any other name, until specified |
|
|
|
conf.env.SERVER_NAME = 'server' # can't be any other name, until specified |
|
|
|
|
|
|
|
|
|
|
|
# print(conf.options.ALLOW64) |
|
|
|
# We restrict 64-bit builds ONLY for Win/Linux/OSX running on Intel architecture |
|
|
|
|
|
|
|
# Because compatibility with original GoldSrc |
|
|
|
conf.env.BIT32_MANDATORY = not conf.options.ALLOW64 |
|
|
|
if conf.env.DEST_OS in ['win32', 'linux', 'darwin'] and conf.env.DEST_CPU in ['x86_64']: |
|
|
|
conf.env.BIT32_ALLOW64 = conf.options.ALLOW64 |
|
|
|
conf.env.BIT32_ALLOW64 = conf.options.ALLOW64 |
|
|
|
conf.load('force_32bit') |
|
|
|
if not conf.env.BIT32_ALLOW64: |
|
|
|
|
|
|
|
Logs.info('WARNING: will build engine for 32-bit target') |
|
|
|
if conf.env.DEST_SIZEOF_VOID_P == 4: |
|
|
|
|
|
|
|
Logs.info('NOTE: will build game dlls for 32-bit target') |
|
|
|
|
|
|
|
else: |
|
|
|
else: |
|
|
|
Logs.warn('WARNING: 64-bit game dlls may be unstable') |
|
|
|
conf.env.BIT32_ALLOW64 = True |
|
|
|
|
|
|
|
conf.env.BIT32_MANDATORY = not conf.env.BIT32_ALLOW64 |
|
|
|
|
|
|
|
conf.load('force_32bit') |
|
|
|
|
|
|
|
|
|
|
|
linker_flags = { |
|
|
|
linker_flags = { |
|
|
|
'common': { |
|
|
|
'common': { |
|
|
|
'msvc': ['/DEBUG'], # always create PDB, doesn't affect result binaries |
|
|
|
'msvc': ['/DEBUG'], # always create PDB, doesn't affect result binaries |
|
|
|
'gcc': ['-Wl,--no-undefined'] |
|
|
|
'gcc': ['-Wl,--no-undefined'] |
|
|
|
}, |
|
|
|
}, |
|
|
|
'sanitize': { |
|
|
|
'sanitize': { |
|
|
|
'gcc': ['-fsanitize=undefined', '-fsanitize=address'], |
|
|
|
'clang': ['-fsanitize=undefined', '-fsanitize=address'], |
|
|
|
|
|
|
|
'gcc': ['-fsanitize=undefined', '-fsanitize=address'], |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
compiler_c_cxx_flags = { |
|
|
|
compiler_c_cxx_flags = { |
|
|
|
'common': { |
|
|
|
'common': { |
|
|
|
'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS'], |
|
|
|
# disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP |
|
|
|
'clang': ['-g', '-gdwarf-2'], |
|
|
|
'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'], |
|
|
|
'gcc': ['-g', '-Werror=implicit-function-declaration', '-fdiagnostics-color=always'] |
|
|
|
'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden'], |
|
|
|
|
|
|
|
'gcc': ['-g', '-fvisibility=hidden'] |
|
|
|
}, |
|
|
|
}, |
|
|
|
'fast': { |
|
|
|
'fast': { |
|
|
|
'msvc': ['/O2', '/Oy'], #todo: check /GL /LTCG |
|
|
|
'msvc': ['/O2', '/Oy'], #todo: check /GL /LTCG |
|
|
|
'gcc': ['-Ofast', '-march=native', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'], |
|
|
|
'gcc': ['-Ofast', '-march=native', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'], |
|
|
|
|
|
|
|
'clang': ['-Ofast', '-march=native'], |
|
|
|
'default': ['-O3'] |
|
|
|
'default': ['-O3'] |
|
|
|
}, |
|
|
|
}, |
|
|
|
'release': { |
|
|
|
'release': { |
|
|
|
'msvc': ['/O2'], |
|
|
|
'msvc': ['/O2'], |
|
|
|
'default': ['-O3'] |
|
|
|
'default': ['-O3'] |
|
|
|
}, |
|
|
|
}, |
|
|
|
'debug': { |
|
|
|
'debug': { |
|
|
|
'msvc': ['/O1'], |
|
|
|
'msvc': ['/O1'], |
|
|
|
'gcc': ['-Og'], |
|
|
|
'gcc': ['-Og'], |
|
|
|
'default': ['-O1'] |
|
|
|
'default': ['-O1'] |
|
|
|
}, |
|
|
|
}, |
|
|
|
'sanitize': { |
|
|
|
'sanitize': { |
|
|
|
'msvc': ['/Od', '/RTC1'], |
|
|
|
'msvc': ['/Od', '/RTC1'], |
|
|
|
'gcc': ['-Og', '-fsanitize=undefined', '-fsanitize=address'], |
|
|
|
'gcc': ['-Og', '-fsanitize=undefined', '-fsanitize=address'], |
|
|
|
'default': ['-O1'] |
|
|
|
'clang': ['-O0', '-fsanitize=undefined', '-fsanitize=address'], |
|
|
|
|
|
|
|
'default': ['-O0'] |
|
|
|
}, |
|
|
|
}, |
|
|
|
'nooptimize': { |
|
|
|
'nooptimize': { |
|
|
|
'msvc': ['/Od'], |
|
|
|
'msvc': ['/Od'], |
|
|
|
'default': ['-O0'] |
|
|
|
'default': ['-O0'] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
conf.env.append_unique('CFLAGS', conf.get_flags_by_type( |
|
|
|
compiler_optional_flags = [ |
|
|
|
compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) |
|
|
|
'-fdiagnostics-color=always', |
|
|
|
conf.env.append_unique('CXXFLAGS', conf.get_flags_by_type( |
|
|
|
'-Werror=implicit-function-declaration', |
|
|
|
compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) |
|
|
|
'-Werror=int-conversion', |
|
|
|
conf.env.append_unique('LINKFLAGS', conf.get_flags_by_type( |
|
|
|
'-Werror=return-type', |
|
|
|
linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) |
|
|
|
'-Werror=parentheses', |
|
|
|
|
|
|
|
'-Werror=vla', |
|
|
|
|
|
|
|
'-Werror=tautological-compare', |
|
|
|
|
|
|
|
'-Werror=duplicated-cond', |
|
|
|
|
|
|
|
'-Werror=bool-compare', |
|
|
|
|
|
|
|
'-Werror=bool-operation', |
|
|
|
|
|
|
|
'-Wstrict-aliasing', |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c_compiler_optional_flags = [ |
|
|
|
|
|
|
|
'-Werror=implicit-int', |
|
|
|
|
|
|
|
'-Werror=declaration-after-statement' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
linkflags = conf.get_flags_by_type(linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC) |
|
|
|
|
|
|
|
cflags = conf.get_flags_by_type(compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Here we don't differentiate C or C++ flags |
|
|
|
|
|
|
|
if conf.options.LTO: |
|
|
|
|
|
|
|
lto_cflags = { |
|
|
|
|
|
|
|
'msvc': ['/GL'], |
|
|
|
|
|
|
|
'gcc': ['-flto'], |
|
|
|
|
|
|
|
'clang': ['-flto'] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lto_linkflags = { |
|
|
|
|
|
|
|
'msvc': ['/LTCG'], |
|
|
|
|
|
|
|
'gcc': ['-flto'], |
|
|
|
|
|
|
|
'clang': ['-flto'] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cflags += conf.get_flags_by_compiler(lto_cflags, conf.env.COMPILER_CC) |
|
|
|
|
|
|
|
linkflags += conf.get_flags_by_compiler(lto_linkflags, conf.env.COMPILER_CC) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if conf.options.POLLY: |
|
|
|
|
|
|
|
polly_cflags = { |
|
|
|
|
|
|
|
'gcc': ['-fgraphite-identity'], |
|
|
|
|
|
|
|
'clang': ['-mllvm', '-polly'] |
|
|
|
|
|
|
|
# msvc sosat :( |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cflags += conf.get_flags_by_compiler(polly_cflags, conf.env.COMPILER_CC) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# And here C++ flags starts to be treated separately |
|
|
|
|
|
|
|
cxxflags = list(cflags) |
|
|
|
|
|
|
|
if conf.env.COMPILER_CC != 'msvc': |
|
|
|
|
|
|
|
conf.check_cc(cflags=cflags, msg= 'Checking for required C flags') |
|
|
|
|
|
|
|
conf.check_cxx(cxxflags=cflags, msg= 'Checking for required C++ flags') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cflags += conf.filter_cflags(compiler_optional_flags + c_compiler_optional_flags, cflags) |
|
|
|
|
|
|
|
cxxflags += conf.filter_cxxflags(compiler_optional_flags, cflags) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conf.env.append_unique('CFLAGS', cflags) |
|
|
|
|
|
|
|
conf.env.append_unique('CXXFLAGS', cxxflags) |
|
|
|
|
|
|
|
conf.env.append_unique('LINKFLAGS', linkflags) |
|
|
|
|
|
|
|
|
|
|
|
if conf.env.COMPILER_CC == 'msvc': |
|
|
|
if conf.env.COMPILER_CC == 'msvc': |
|
|
|
conf.env.append_unique('DEFINES', ['_CRT_SECURE_NO_WARNINGS','_CRT_NONSTDC_NO_DEPRECATE']) |
|
|
|
conf.define('_CRT_SECURE_NO_WARNINGS', 1) |
|
|
|
|
|
|
|
conf.define('_CRT_NONSTDC_NO_DEPRECATE', 1) |
|
|
|
else: |
|
|
|
else: |
|
|
|
conf.env.append_unique('DEFINES', ['stricmp=strcasecmp','strnicmp=strncasecmp','_LINUX','LINUX','_snprintf=snprintf','_vsnprintf=vsnprintf']) |
|
|
|
conf.env.append_unique('DEFINES', ['stricmp=strcasecmp', 'strnicmp=strncasecmp', '_snprintf=snprintf', '_vsnprintf=vsnprintf', '_LINUX', 'LINUX']) |
|
|
|
cflags = ['-fvisibility=hidden','-Wno-write-strings'] |
|
|
|
conf.env.append_unique('CXXFLAGS', ['-Wno-invalid-offsetof', '-fno-rtti', '-fno-exceptions']) |
|
|
|
conf.env.append_unique('CFLAGS', cflags) |
|
|
|
|
|
|
|
conf.env.append_unique('CXXFLAGS', cflags + ['-Wno-invalid-offsetof', '-fno-rtti', '-fno-exceptions']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# strip lib from pattern |
|
|
|
# strip lib from pattern |
|
|
|
if conf.env.DEST_OS in ['linux', 'darwin']: |
|
|
|
if conf.env.DEST_OS in ['linux', 'darwin']: |
|
|
@ -149,7 +212,7 @@ def configure(conf): |
|
|
|
if conf.env.cxxshlib_PATTERN.startswith('lib'): |
|
|
|
if conf.env.cxxshlib_PATTERN.startswith('lib'): |
|
|
|
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:] |
|
|
|
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:] |
|
|
|
|
|
|
|
|
|
|
|
conf.env.append_unique('DEFINES', 'CLIENT_WEAPONS') |
|
|
|
conf.define('CLIENT_WEAPONS', '1') |
|
|
|
|
|
|
|
|
|
|
|
conf.recurse('cl_dll dlls') |
|
|
|
conf.recurse('cl_dll dlls') |
|
|
|
|
|
|
|
|
|
|
|