2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-21 09:26:14 +01:00

waf: update tools from engine branch, fix waf 2.1 migration issues, update batch file

This commit is contained in:
Alibek Omarov 2024-08-10 14:23:13 +03:00
parent adacfd18dd
commit 518a5c185c
5 changed files with 146 additions and 47 deletions

View File

@ -30,7 +30,7 @@ compiler_optimizations.CFLAGS['gottagofast'] = {
}
'''
VALID_BUILD_TYPES = ['fastnative', 'fast', 'release', 'debug', 'sanitize', 'msan', 'none']
VALID_BUILD_TYPES = ['fastnative', 'fast', 'humanrights', 'debug', 'sanitize', 'msan', 'none']
LINKFLAGS = {
'common': {
@ -64,20 +64,26 @@ CFLAGS = {
'msvc': ['/O2', '/Oy', '/Zi'],
'gcc': {
'3': ['-O3', '-fomit-frame-pointer'],
'default': ['-Ofast', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer']
'4': ['-Ofast', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'],
'default': ['-Ofast', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer', '-fno-semantic-interposition']
},
'clang': ['-Ofast'],
'default': ['-O3']
},
'fastnative': {
'msvc': ['/O2', '/Oy', '/Zi'],
'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', '-fno-semantic-interposition'],
'clang': ['-Ofast', '-march=native'],
'default': ['-O3']
},
'release': {
'humanrights': {
'msvc': ['/O2', '/Zi'],
'owcc': ['-O3', '-foptimize-sibling-calls', '-fomit-leaf-frame-pointer', '-fomit-frame-pointer', '-fschedule-insns', '-funsafe-math-optimizations', '-funroll-loops', '-frerun-optimizer', '-finline-functions', '-finline-limit=512', '-fguess-branch-probability', '-fno-strict-aliasing', '-floop-optimize'],
'gcc': {
'4': ['-O3'],
'3': ['-O3'],
'default': ['-O3','-fno-semantic-interposition'],
},
'default': ['-O3']
},
'debug': {
@ -99,13 +105,13 @@ CFLAGS = {
LTO_CFLAGS = {
'msvc': ['/GL'],
'gcc': ['-flto'],
'gcc': ['-flto=auto'],
'clang': ['-flto']
}
LTO_LINKFLAGS = {
'msvc': ['/LTCG'],
'gcc': ['-flto'],
'gcc': ['-flto=auto'],
'clang': ['-flto']
}
@ -115,21 +121,62 @@ POLLY_CFLAGS = {
# msvc sosat :(
}
OPENMP_CFLAGS = {
'gcc': ['-fopenmp', '-DHAVE_OPENMP=1'],
'clang': ['-fopenmp', '-DHAVE_OPENMP=1'],
'msvc': ['/openmp', '/DHAVE_OPENMP=1']
}
OPENMP_LINKFLAGS = {
'gcc': ['-fopenmp'],
'clang': ['-fopenmp'],
}
PROFILE_GENERATE_CFLAGS = {
'gcc': ['-fprofile-generate=xash3d-prof'],
}
PROFILE_GENERATE_LINKFLAGS = {
'gcc': ['-fprofile-generate=xash3d-prof'],
}
PROFILE_USE_CFLAGS = {
'gcc': ['-fprofile-use=%s'],
}
PROFILE_USE_LINKFLAGS = {
'gcc': ['-fprofile-use=%s'],
}
def options(opt):
grp = opt.add_option_group('Compiler optimization options')
grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default='release',
grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default='humanrights',
help = 'build type: debug, release or none(custom flags)')
grp.add_option('--enable-lto', action = 'store_true', dest = 'LTO', default = False,
help = 'enable Link Time Optimization if possible [default: %default]')
help = 'enable Link Time Optimization if possible [default: %(default)s]')
grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False,
help = 'enable polyhedral optimization if possible [default: %default]')
help = 'enable polyhedral optimization if possible [default: %(default)s]')
grp.add_option('--enable-openmp', action = 'store_true', dest = 'OPENMP', default = False,
help = 'enable OpenMP extensions [default: %(default)s]')
grp.add_option('--enable-profile', action = 'store_true', dest = 'PROFILE_GENERATE', default = False,
help = 'enable profile generating build (stored in xash3d-prof directory) [default: %(default)s]')
grp.add_option('--use-profile', action = 'store', dest = 'PROFILE_USE', default = None,
help = 'use profile during build [default: %(default)s]')
def configure(conf):
conf.start_msg('Build type')
# legacy naming for default release build
# https://chaos.social/@karolherbst/111340511652012860
if conf.options.BUILD_TYPE == 'release':
conf.options.BUILD_TYPE = 'humanrights'
if not conf.options.BUILD_TYPE in VALID_BUILD_TYPES:
conf.end_msg(conf.options.BUILD_TYPE, color='RED')
conf.fatal('Invalid build type. Valid are: %s' % ', '.join(VALID_BUILD_TYPES))
@ -138,6 +185,9 @@ def configure(conf):
conf.msg('LTO build', 'yes' if conf.options.LTO else 'no')
conf.msg('PolyOpt build', 'yes' if conf.options.POLLY else 'no')
conf.msg('OpenMP build', 'yes' if conf.options.OPENMP else 'no')
conf.msg('Generate profile', 'yes' if conf.options.PROFILE_GENERATE else 'no')
conf.msg('Use profile', conf.options.PROFILE_USE if not conf.options.PROFILE_GENERATE else 'no')
# -march=native should not be used
if conf.options.BUILD_TYPE.startswith('fast'):
@ -168,6 +218,17 @@ def get_optimization_flags(conf):
if conf.options.POLLY:
cflags += conf.get_flags_by_compiler(POLLY_CFLAGS, conf.env.COMPILER_CC)
if conf.options.OPENMP:
linkflags+= conf.get_flags_by_compiler(OPENMP_LINKFLAGS, conf.env.COMPILER_CC)
cflags += conf.get_flags_by_compiler(OPENMP_CFLAGS, conf.env.COMPILER_CC)
if conf.options.PROFILE_GENERATE:
linkflags+= conf.get_flags_by_compiler(PROFILE_GENERATE_LINKFLAGS, conf.env.COMPILER_CC)
cflags += conf.get_flags_by_compiler(PROFILE_GENERATE_CFLAGS, conf.env.COMPILER_CC)
elif conf.options.PROFILE_USE:
linkflags+= [conf.get_flags_by_compiler(PROFILE_USE_LINKFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE]
cflags += [conf.get_flags_by_compiler(PROFILE_USE_CFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE]
if conf.env.DEST_OS == 'nswitch' and conf.options.BUILD_TYPE == 'debug':
# enable remote debugger
cflags.append('-DNSWITCH_DEBUG')
@ -177,4 +238,17 @@ def get_optimization_flags(conf):
# remove fvisibility to allow everything to be exported by default
cflags.remove('-fvisibility=hidden')
if conf.env.COMPILER_CC != 'msvc' and conf.env.COMPILER_CC != 'owcc':
# HLSDK by default compiles with these options under Linux
# no reason for us to not do the same
# TODO: fix DEST_CPU in force 32 bit mode
if conf.env.DEST_CPU == 'x86' or (conf.env.DEST_CPU == 'x86_64' and conf.env.DEST_SIZEOF_VOID_P == 4):
cflags.append('-march=pentium-m')
cflags.append('-mtune=core2')
# on all compilers (except MSVC?) we need to copy CFLAGS to LINKFLAGS
if conf.options.LTO and conf.env.COMPILER_CC != 'msvc':
linkflags += cflags
return cflags, linkflags

View File

@ -3,6 +3,7 @@
# mittorn, 2018
from waflib.Configure import conf
from waflib import Logs
import os
VGUI_SUPPORTED_OS = ['win32', 'darwin', 'linux']
@ -13,55 +14,76 @@ int main() { return 0; }'''
def options(opt):
grp = opt.add_option_group('VGUI options')
vgui_dev_path = os.path.join(opt.path.path_from(opt.path), 'vgui_support', 'vgui-dev')
vgui_dev_path = os.path.join(opt.path.path_from(opt.root), 'vgui-dev')
grp.add_option('--vgui', action = 'store', dest = 'VGUI_DEV', default=vgui_dev_path,
help = 'path to vgui-dev repo [default: %default]')
help = 'path to vgui-dev repo [default: %(default)s]')
grp.add_option('--enable-unsupported-vgui', action = 'store_true', dest = 'ENABLE_UNSUPPORTED_VGUI', default=False,
help = 'ignore all checks and allow link against anything [default: %(default)s]')
grp.add_option('--skip-vgui-sanity-check', action = 'store_false', dest = 'VGUI_SANITY_CHECK', default=True,
help = 'skip checking VGUI sanity [default: %default]' )
help = 'skip checking VGUI sanity [default: %(default)s]' )
return
@conf
def check_vgui(conf):
conf.start_msg('Does this architecture support VGUI?')
if conf.env.DEST_CPU == 'x86' or (conf.env.DEST_CPU == 'x86_64' and not conf.options.ALLOW64):
vgui_dest_cpu = 'x86' # link with 32-bit binary when crosscompiling to 32-bit
else: vgui_dest_cpu = conf.env.DEST_CPU
if conf.env.DEST_CPU != 'x86' and not (conf.env.DEST_CPU == 'x86_64' and not conf.options.ALLOW64):
conf.end_msg('no')
Logs.warn('vgui is not supported on this CPU: ' + str(conf.env.DEST_CPU))
return False
else: conf.end_msg('yes')
if not conf.options.ENABLE_UNSUPPORTED_VGUI:
conf.start_msg('Does this architecture support VGUI?')
conf.start_msg('Does this OS support VGUI?')
if conf.env.DEST_OS not in VGUI_SUPPORTED_OS:
conf.end_msg('no')
Logs.warn('vgui is not supported on this OS: ' + str(conf.env.DEST_OS))
return False
else: conf.end_msg('yes')
if vgui_dest_cpu != 'x86':
conf.end_msg('no')
Logs.warn('vgui is not supported on this CPU: ' + str(vgui_dest_cpu))
return False
else: conf.end_msg('yes')
conf.start_msg('Does this toolchain able to link VGUI?')
if conf.env.DEST_OS == 'win32' and conf.env.COMPILER_CXX == 'g++':
conf.end_msg('no')
# we have ABI incompatibility ONLY on MinGW
Logs.warn('vgui can\'t be linked with MinGW')
return False
else: conf.end_msg('yes')
conf.start_msg('Does this OS support VGUI?')
if conf.env.DEST_OS not in VGUI_SUPPORTED_OS:
conf.end_msg('no')
Logs.warn('vgui is not supported on this OS: ' + str(conf.env.DEST_OS))
return False
else: conf.end_msg('yes')
conf.start_msg('Does this toolchain able to link VGUI?')
if conf.env.DEST_OS == 'win32' and conf.env.COMPILER_CXX == 'g++':
conf.end_msg('no')
# we have ABI incompatibility ONLY on MinGW
Logs.warn('vgui can\'t be linked with MinGW')
return False
else: conf.end_msg('yes')
conf.start_msg('Configuring VGUI by provided path')
vgui_dev = conf.options.VGUI_DEV
libpath = os.path.abspath(os.path.join(vgui_dev, 'lib'))
if conf.env.DEST_OS == 'win32':
conf.env.LIB_VGUI = ['vgui']
conf.env.LIBPATH_VGUI = [os.path.abspath(os.path.join(vgui_dev, 'lib/win32_vc6/'))]
else:
libpath = os.path.abspath(os.path.join(vgui_dev, 'lib'))
if conf.env.DEST_OS == 'linux':
conf.env.LIB_VGUI = [':vgui.so']
conf.env.LIBPATH_VGUI = [libpath]
elif conf.env.DEST_OS == 'darwin':
conf.env.LDFLAGS_VGUI = [os.path.join(libpath, 'vgui.dylib')]
libpath = os.path.join(libpath, 'win32_vc6')
if vgui_dest_cpu != 'x86':
# for 32-bit x86 it's expected to be under win32_vc6
# for others, it's expected to be under win32_vc6 subdirectory matching CPU arch (x86_64 for 64-bit CPUs)
libpath = os.path.join(libpath, vgui_dest_cpu)
conf.env.LIBPATH_VGUI = [libpath]
elif conf.env.DEST_OS == 'linux':
conf.env.LIB_VGUI = [':vgui.so']
if vgui_dest_cpu != 'x86':
libpath = os.path.join(libpath, vgui_dest_cpu)
conf.env.LIBPATH_VGUI = [libpath]
elif conf.env.DEST_OS == 'darwin':
if vgui_dest_cpu != 'x86':
conf.env.LDFLAGS_VGUI = [os.path.join(libpath, vgui_dest_cpu, 'vgui.dylib')]
else:
conf.fatal('vgui is not supported on this OS: ' + conf.env.DEST_OS)
conf.env.LDFLAGS_VGUI = [os.path.join(libpath, 'vgui.dylib')]
else:
# TODO: figure out what to do here
conf.env.LIB_VGUI = ['vgui']
conf.env.LIBPATH_VGUI = [os.path.join(libpath, conf.env.DEST_OS, vgui_dest_cpu)]
conf.env.INCLUDES_VGUI = [os.path.abspath(os.path.join(vgui_dev, 'include'))]
conf.env.HAVE_VGUI = 1

View File

@ -503,13 +503,15 @@ def options(opt):
xc.add_option('--android', action='store', dest='ANDROID_OPTS', default=None,
help='enable building for android, format: --android=<arch>,<toolchain>,<api>, example: --android=armeabi-v7a-hard,4.9,9')
xc.add_option('--enable-magx', action='store_true', dest='MAGX', default=False,
help='enable building for Motorola MAGX [default: %default]')
help='enable building for Motorola MAGX [default: %(default)s]')
xc.add_option('--enable-msvc-wine', action='store_true', dest='MSVC_WINE', default=False,
help='enable building with MSVC using Wine [default: %default]')
help='enable building with MSVC using Wine [default: %(default)s]')
xc.add_option('--nswitch', action='store_true', dest='NSWITCH', default = False,
help ='enable building for Nintendo Switch [default: %default]')
help='enable building for Nintendo Switch [default: %(default)s]')
xc.add_option('--psvita', action='store_true', dest='PSVITA', default = False,
help ='enable building for PlayStation Vita [default: %default]')
help='enable building for PlayStation Vita [default: %(default)s]')
xc.add_option('--sailfish', action='store', dest='SAILFISH', default = None,
help='enable building for Sailfish/Aurora')
def configure(conf):
if conf.options.ANDROID_OPTS:
@ -593,6 +595,7 @@ def configure(conf):
conf.env.MAGX = conf.options.MAGX
conf.env.MSVC_WINE = conf.options.MSVC_WINE
conf.env.SAILFISH = conf.options.SAILFISH
MACRO_TO_DESTOS = OrderedDict({ '__ANDROID__' : 'android', '__SWITCH__' : 'nswitch', '__vita__' : 'psvita' })
for k in c_config.MACRO_TO_DESTOS:
MACRO_TO_DESTOS[k] = c_config.MACRO_TO_DESTOS[k] # ordering is important

View File

@ -25,7 +25,7 @@ Setlocal EnableDelayedExpansion
set PYTHON_DIR_OK=FALSE
set REGPATH=
for %%i in (3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5) do (
for %%i in (3.13 3.12 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7) do (
for %%j in (HKCU HKLM) do (
for %%k in (SOFTWARE\Wow6432Node SOFTWARE) do (
for %%l in (Python\PythonCore IronPython) do (

View File

@ -21,12 +21,12 @@ def get_taskgen_count(self):
return idx
def options(opt):
opt.load('reconfigure compiler_optimizations xcompile compiler_cxx compiler_c clang_compilation_database strip_on_install msdev msvs msvc subproject')
opt.load('reconfigure compiler_optimizations xcompile compiler_cxx compiler_c clang_compilation_database strip_on_install msdev msvs subproject')
grp = opt.add_option_group('Common options')
grp.add_option('-8', '--64bits', action = 'store_true', dest = 'ALLOW64', default = False,
help = 'allow targetting 64-bit engine(Linux/Windows/OSX x86 only) [default: %default]')
help = 'allow targetting 64-bit engine(Linux/Windows/OSX x86 only) [default: %(default)s]')
grp.add_option('--disable-werror', action = 'store_true', dest = 'DISABLE_WERROR', default = False,
help = 'disable compilation abort on warning')
grp.add_option('--enable-voicemgr', action = 'store_true', dest = 'USE_VOICEMGR', default = False,