2018-05-28 17:17:25 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# a1batross, mittorn, 2018
|
|
|
|
|
2022-10-04 02:02:49 +02:00
|
|
|
from waflib import Build, Context, Logs
|
2018-05-28 17:17:25 +02:00
|
|
|
import sys
|
2018-12-13 06:08:03 +01:00
|
|
|
import os
|
|
|
|
|
2018-06-17 13:30:59 +02:00
|
|
|
VERSION = '0.99'
|
|
|
|
APPNAME = 'xash3d-fwgs'
|
|
|
|
top = '.'
|
|
|
|
|
2019-10-05 02:06:51 +02:00
|
|
|
Context.Context.line_just = 55 # should fit for everything on 80x26
|
|
|
|
|
2019-02-19 15:49:09 +01:00
|
|
|
class Subproject:
|
2022-08-19 02:10:34 +02:00
|
|
|
def __init__(self, name, fnFilter = None):
|
2019-02-19 15:49:09 +01:00
|
|
|
self.name = name
|
2022-08-19 02:10:34 +02:00
|
|
|
self.fnFilter = fnFilter
|
2019-11-04 23:01:33 +01:00
|
|
|
|
2022-08-19 02:10:34 +02:00
|
|
|
def is_exists(self, ctx):
|
|
|
|
return ctx.path.find_node(self.name + '/wscript')
|
2019-11-04 23:01:33 +01:00
|
|
|
|
2022-08-19 02:10:34 +02:00
|
|
|
def is_enabled(self, ctx):
|
|
|
|
if not self.is_exists(ctx):
|
2021-03-05 13:57:52 +01:00
|
|
|
return False
|
|
|
|
|
2022-08-19 02:10:34 +02:00
|
|
|
if self.fnFilter:
|
|
|
|
return self.fnFilter(ctx)
|
2022-01-15 04:24:57 +01:00
|
|
|
|
2019-11-04 23:01:33 +01:00
|
|
|
return True
|
|
|
|
|
2019-02-19 15:49:09 +01:00
|
|
|
SUBDIRS = [
|
2022-08-19 02:10:34 +02:00
|
|
|
# always configured and built
|
|
|
|
Subproject('public'),
|
|
|
|
Subproject('filesystem'),
|
|
|
|
Subproject('engine'),
|
|
|
|
Subproject('stub/server'),
|
2020-01-19 01:38:37 +01:00
|
|
|
Subproject('dllemu'),
|
2019-02-19 15:49:09 +01:00
|
|
|
|
2022-08-19 02:10:34 +02:00
|
|
|
# disable only by engine feature, makes no sense to even parse subprojects in dedicated mode
|
2022-09-11 01:22:26 +02:00
|
|
|
Subproject('3rdparty/extras', lambda x: not x.env.DEDICATED and x.env.DEST_OS != 'android'),
|
2022-09-10 19:54:34 +02:00
|
|
|
Subproject('3rdparty/nanogl', lambda x: not x.env.DEDICATED and x.env.NANOGL),
|
|
|
|
Subproject('3rdparty/gl-wes-v2', lambda x: not x.env.DEDICATED and x.env.GLWES),
|
|
|
|
Subproject('3rdparty/gl4es', lambda x: not x.env.DEDICATED and x.env.GL4ES),
|
|
|
|
Subproject('ref/gl', lambda x: not x.env.DEDICATED and (x.env.GL or x.env.NANOGL or x.env.GLWES or x.env.GL4ES)),
|
|
|
|
Subproject('ref/soft', lambda x: not x.env.DEDICATED and x.env.SOFT),
|
2023-02-16 19:30:31 +01:00
|
|
|
Subproject('ref/vk', lambda x: not x.env.DEDICATED and x.env.VULKAN),
|
2022-09-10 18:06:56 +02:00
|
|
|
Subproject('3rdparty/mainui', lambda x: not x.env.DEDICATED),
|
|
|
|
Subproject('3rdparty/vgui_support', lambda x: not x.env.DEDICATED),
|
|
|
|
Subproject('stub/client', lambda x: not x.env.DEDICATED),
|
|
|
|
Subproject('game_launch', lambda x: not x.env.SINGLE_BINARY and x.env.DEST_OS != 'android'),
|
2022-08-19 02:10:34 +02:00
|
|
|
|
|
|
|
# disable only by external dependency presense
|
2022-08-25 18:33:16 +02:00
|
|
|
Subproject('3rdparty/opus', lambda x: not x.env.HAVE_SYSTEM_OPUS and not x.env.DEDICATED),
|
2022-08-19 02:10:34 +02:00
|
|
|
|
|
|
|
# enabled optionally
|
|
|
|
Subproject('utils/mdldec', lambda x: x.env.ENABLE_UTILS),
|
|
|
|
Subproject('utils/run-fuzzer', lambda x: x.env.ENABLE_FUZZER),
|
2019-02-19 15:49:09 +01:00
|
|
|
]
|
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
def options(opt):
|
2019-02-19 14:33:14 +01:00
|
|
|
grp = opt.add_option_group('Common options')
|
2018-12-13 06:13:27 +01:00
|
|
|
|
2019-03-26 14:25:54 +01:00
|
|
|
grp.add_option('-d', '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False,
|
2019-10-11 02:46:17 +02:00
|
|
|
help = 'build Xash Dedicated Server [default: %default]')
|
2018-11-18 21:04:30 +01:00
|
|
|
|
2022-09-11 01:12:44 +02:00
|
|
|
grp.add_option('--gamedir', action = 'store', dest = 'GAMEDIR', default = 'valve',
|
|
|
|
help = 'engine default game directory [default: %default]')
|
|
|
|
|
2019-03-26 14:25:54 +01:00
|
|
|
grp.add_option('--single-binary', action = 'store_true', dest = 'SINGLE_BINARY', default = False,
|
2019-10-23 19:47:26 +02:00
|
|
|
help = 'build single "xash" binary (always enabled for dedicated) [default: %default]')
|
2019-02-19 15:49:09 +01:00
|
|
|
|
2019-03-26 14:25:54 +01:00
|
|
|
grp.add_option('-8', '--64bits', action = 'store_true', dest = 'ALLOW64', default = False,
|
2019-10-11 02:46:17 +02:00
|
|
|
help = 'allow targetting 64-bit engine(Linux/Windows/OSX x86 only) [default: %default]')
|
2018-11-18 21:04:30 +01:00
|
|
|
|
2021-11-25 14:52:28 +01:00
|
|
|
grp.add_option('-P', '--enable-packaging', action = 'store_true', dest = 'PACKAGING', default = False,
|
|
|
|
help = 'respect prefix option, useful for packaging for various operating systems [default: %default]')
|
2018-12-13 06:13:27 +01:00
|
|
|
|
2022-09-12 06:18:24 +02:00
|
|
|
grp.add_option('--enable-bundled-deps', action = 'store_true', dest = 'BUILD_BUNDLED_DEPS', default = False,
|
2022-08-19 03:03:53 +02:00
|
|
|
help = 'prefer to build bundled dependencies (like opus) instead of relying on system provided')
|
|
|
|
|
2019-03-20 00:38:13 +01:00
|
|
|
grp.add_option('--enable-bsp2', action = 'store_true', dest = 'SUPPORT_BSP2_FORMAT', default = False,
|
2019-10-11 02:46:17 +02:00
|
|
|
help = 'build engine and renderers with BSP2 map support(recommended for Quake, breaks compatibility!) [default: %default]')
|
2019-07-27 14:36:24 +02:00
|
|
|
|
2019-11-06 21:13:03 +01:00
|
|
|
grp.add_option('--low-memory-mode', action = 'store', dest = 'LOW_MEMORY', default = 0, type = 'int',
|
2019-10-26 07:12:59 +02:00
|
|
|
help = 'enable low memory mode (only for devices have <128 ram)')
|
|
|
|
|
2021-09-05 23:04:27 +02:00
|
|
|
grp.add_option('--disable-werror', action = 'store_true', dest = 'DISABLE_WERROR', default = False,
|
|
|
|
help = 'disable compilation abort on warning')
|
|
|
|
|
2022-09-10 19:54:34 +02:00
|
|
|
grp = opt.add_option_group('Renderers options')
|
|
|
|
|
|
|
|
grp.add_option('--enable-all-renderers', action='store_true', dest='ALL_RENDERERS', default=False,
|
|
|
|
help = 'enable all renderers supported by Xash3D FWGS [default: %default]')
|
|
|
|
|
|
|
|
grp.add_option('--enable-gles1', action='store_true', dest='NANOGL', default=False,
|
|
|
|
help = 'enable gles1 renderer [default: %default]')
|
|
|
|
|
|
|
|
grp.add_option('--enable-gles2', action='store_true', dest='GLWES', default=False,
|
|
|
|
help = 'enable gles2 renderer [default: %default]')
|
|
|
|
|
|
|
|
grp.add_option('--enable-gl4es', action='store_true', dest='GL4ES', default=False,
|
|
|
|
help = 'enable gles2 renderer [default: %default]')
|
|
|
|
|
|
|
|
grp.add_option('--disable-gl', action='store_false', dest='GL', default=True,
|
|
|
|
help = 'disable opengl renderer [default: %default]')
|
|
|
|
|
2023-02-16 19:19:30 +01:00
|
|
|
grp.add_option('--disable-vulkan', action='store_false', dest='VULKAN', default=True,
|
|
|
|
help = 'disable vulkan renderer [default: %default]')
|
|
|
|
|
2022-09-10 19:54:34 +02:00
|
|
|
grp.add_option('--disable-soft', action='store_false', dest='SOFT', default=True,
|
2022-10-02 21:28:53 +02:00
|
|
|
help = 'disable soft renderer [default: %default]')
|
2022-09-10 19:54:34 +02:00
|
|
|
|
2021-03-05 13:57:52 +01:00
|
|
|
grp = opt.add_option_group('Utilities options')
|
|
|
|
|
|
|
|
grp.add_option('--enable-utils', action = 'store_true', dest = 'ENABLE_UTILS', default = False,
|
|
|
|
help = 'enable building various development utilities [default: %default]')
|
|
|
|
|
2022-01-15 04:24:57 +01:00
|
|
|
grp.add_option('--enable-fuzzer', action = 'store_true', dest = 'ENABLE_FUZZER', default = False,
|
|
|
|
help = 'enable building libFuzzer runner [default: %default]' )
|
|
|
|
|
2021-01-29 01:33:14 +01:00
|
|
|
opt.load('compiler_optimizations subproject')
|
2019-02-18 19:25:26 +01:00
|
|
|
|
2019-11-17 21:31:25 +01:00
|
|
|
for i in SUBDIRS:
|
2022-08-19 02:10:34 +02:00
|
|
|
if not i.is_exists(opt):
|
2019-11-17 21:31:25 +01:00
|
|
|
continue
|
|
|
|
|
|
|
|
opt.add_subproject(i.name)
|
2019-02-19 15:49:09 +01:00
|
|
|
|
2022-11-16 02:20:02 +01:00
|
|
|
opt.load('xshlib xcompile compiler_cxx compiler_c sdl2 clang_compilation_database strip_on_install waf_unit_test msdev msvs msvc reconfigure')
|
2019-04-11 21:45:23 +02:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
def configure(conf):
|
2021-01-29 01:33:14 +01:00
|
|
|
conf.load('fwgslib reconfigure compiler_optimizations')
|
2021-02-22 07:15:13 +01:00
|
|
|
conf.env.MSVC_TARGETS = ['x86' if not conf.options.ALLOW64 else 'x64']
|
|
|
|
|
2021-02-25 15:16:17 +01:00
|
|
|
# Load compilers early
|
|
|
|
conf.load('xshlib xcompile compiler_c compiler_cxx')
|
|
|
|
|
2023-02-05 02:09:32 +01:00
|
|
|
if conf.options.NSWITCH:
|
|
|
|
conf.load('nswitch')
|
|
|
|
|
2021-02-25 15:16:17 +01:00
|
|
|
# HACKHACK: override msvc DEST_CPU value by something that we understand
|
|
|
|
if conf.env.DEST_CPU == 'amd64':
|
2021-02-22 07:15:13 +01:00
|
|
|
conf.env.DEST_CPU = 'x86_64'
|
2018-06-17 13:30:59 +02:00
|
|
|
|
2021-02-25 15:16:17 +01:00
|
|
|
if conf.env.COMPILER_CC == 'msvc':
|
|
|
|
conf.load('msvc_pdb')
|
|
|
|
|
|
|
|
conf.load('msvs msdev subproject gitversion clang_compilation_database strip_on_install waf_unit_test enforce_pic')
|
|
|
|
|
2021-03-05 15:59:54 +01:00
|
|
|
# Force XP compatibility, all build targets should add subsystem=bld.env.MSVC_SUBSYSTEM
|
|
|
|
if conf.env.MSVC_TARGETS[0] == 'x86':
|
|
|
|
conf.env.MSVC_SUBSYSTEM = 'WINDOWS,5.01'
|
|
|
|
conf.env.CONSOLE_SUBSYSTEM = 'CONSOLE,5.01'
|
|
|
|
else:
|
|
|
|
conf.env.MSVC_SUBSYSTEM = 'WINDOWS'
|
|
|
|
conf.env.CONSOLE_SUBSYSTEM = 'CONSOLE'
|
|
|
|
|
2021-01-29 01:33:14 +01:00
|
|
|
enforce_pic = True # modern defaults
|
2019-11-07 02:49:49 +01:00
|
|
|
|
2019-05-06 03:11:12 +02:00
|
|
|
# modify options dictionary early
|
2019-09-19 16:07:41 +02:00
|
|
|
if conf.env.DEST_OS == 'android':
|
2019-11-04 23:01:33 +01:00
|
|
|
conf.options.NO_VGUI= True # skip vgui
|
2019-05-06 03:11:12 +02:00
|
|
|
conf.options.NANOGL = True
|
|
|
|
conf.options.GLWES = True
|
2022-06-12 02:06:31 +02:00
|
|
|
conf.options.GL4ES = True
|
2019-05-06 03:11:12 +02:00
|
|
|
conf.options.GL = False
|
2021-01-29 01:33:14 +01:00
|
|
|
elif conf.env.MAGX:
|
|
|
|
conf.options.USE_SELECT = True
|
|
|
|
conf.options.SDL12 = True
|
|
|
|
conf.options.NO_VGUI = True
|
|
|
|
conf.options.GL = False
|
2021-06-07 08:36:37 +02:00
|
|
|
conf.options.VK = False
|
2021-01-29 01:33:14 +01:00
|
|
|
conf.options.LOW_MEMORY = 1
|
|
|
|
conf.options.SINGLE_BINARY = True
|
2019-11-07 04:56:07 +01:00
|
|
|
conf.options.NO_ASYNC_RESOLVE = True
|
2019-11-07 03:07:10 +01:00
|
|
|
conf.define('XASH_SDLMAIN', 1)
|
2019-11-06 21:13:03 +01:00
|
|
|
enforce_pic = False
|
2021-11-24 21:54:03 +01:00
|
|
|
elif conf.env.DEST_OS == 'dos':
|
|
|
|
conf.options.SINGLE_BINARY = True
|
2023-02-05 02:09:32 +01:00
|
|
|
elif conf.env.DEST_OS == 'nswitch':
|
|
|
|
conf.options.NO_VGUI = True
|
|
|
|
conf.options.GL = True
|
|
|
|
conf.options.SINGLE_BINARY = True
|
|
|
|
conf.options.NO_ASYNC_RESOLVE = True
|
|
|
|
conf.options.USE_STBTT = True
|
2023-02-16 19:54:08 +01:00
|
|
|
conf.options.VULKAN = False # https://github.com/w23/xash3d-fwgs/issues/429
|
2019-11-06 21:13:03 +01:00
|
|
|
|
2021-01-29 01:33:14 +01:00
|
|
|
if conf.env.STATIC_LINKING:
|
|
|
|
enforce_pic = False # PIC may break full static builds
|
|
|
|
|
|
|
|
conf.check_pic(enforce_pic)
|
2019-11-06 21:13:03 +01:00
|
|
|
|
2019-05-31 01:59:45 +02:00
|
|
|
# We restrict 64-bit builds ONLY for Win/Linux/OSX running on Intel architecture
|
|
|
|
# Because compatibility with original GoldSrc
|
2019-11-04 23:01:33 +01:00
|
|
|
if conf.env.DEST_OS in ['win32', 'linux', 'darwin'] and conf.env.DEST_CPU == 'x86_64':
|
2019-10-18 04:06:10 +02:00
|
|
|
conf.env.BIT32_MANDATORY = not conf.options.ALLOW64
|
2021-02-11 22:05:41 +01:00
|
|
|
if conf.env.BIT32_MANDATORY:
|
2019-05-31 01:59:45 +02:00
|
|
|
Logs.info('WARNING: will build engine for 32-bit target')
|
|
|
|
else:
|
2019-10-18 04:06:10 +02:00
|
|
|
conf.env.BIT32_MANDATORY = False
|
2019-11-04 23:01:33 +01:00
|
|
|
|
2019-05-12 02:03:34 +02:00
|
|
|
conf.load('force_32bit')
|
2018-12-13 06:13:27 +01:00
|
|
|
|
2019-09-27 23:23:21 +02:00
|
|
|
compiler_optional_flags = [
|
2019-12-03 00:35:23 +01:00
|
|
|
# '-Wall', '-Wextra', '-Wpedantic',
|
2019-09-27 23:23:21 +02:00
|
|
|
'-fdiagnostics-color=always',
|
|
|
|
'-Werror=return-type',
|
|
|
|
'-Werror=parentheses',
|
2019-10-05 02:06:51 +02:00
|
|
|
'-Werror=vla',
|
|
|
|
'-Werror=tautological-compare',
|
|
|
|
'-Werror=duplicated-cond',
|
|
|
|
'-Werror=bool-compare',
|
|
|
|
'-Werror=bool-operation',
|
2020-09-29 14:42:43 +02:00
|
|
|
'-Werror=cast-align=strict', # =strict is for GCC >=8
|
|
|
|
'-Werror=packed',
|
|
|
|
'-Werror=packed-not-aligned',
|
2020-05-12 23:24:50 +02:00
|
|
|
'-Wuninitialized', # older GCC versions have -Wmaybe-uninitialized enabled by this switch, which is not accurate
|
|
|
|
# so just warn, not error
|
2019-12-24 01:56:07 +01:00
|
|
|
'-Winit-self',
|
2019-12-23 04:48:17 +01:00
|
|
|
'-Werror=implicit-fallthrough=2', # clang incompatible without "=2"
|
2021-07-02 18:27:45 +02:00
|
|
|
'-Werror=logical-op',
|
|
|
|
'-Werror=write-strings',
|
2023-02-03 16:51:50 +01:00
|
|
|
'-Werror=sizeof-pointer-memaccess',
|
|
|
|
'-Werror=sizeof-array-div',
|
|
|
|
'-Werror=sizeof-pointer-div',
|
2023-02-03 17:01:15 +01:00
|
|
|
'-Werror=string-compare',
|
|
|
|
'-Werror=use-after-free=3',
|
|
|
|
'-Werror=sequence-point',
|
2021-07-02 18:27:45 +02:00
|
|
|
# '-Werror=format=2',
|
2019-11-04 23:01:33 +01:00
|
|
|
# '-Wdouble-promotion', # disable warning flood
|
2019-10-05 02:06:51 +02:00
|
|
|
'-Wstrict-aliasing',
|
2022-08-06 19:16:27 +02:00
|
|
|
'-Wmisleading-indentation',
|
2019-10-05 02:06:51 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
c_compiler_optional_flags = [
|
2019-12-02 00:13:23 +01:00
|
|
|
'-Werror=incompatible-pointer-types',
|
2019-10-18 05:20:27 +02:00
|
|
|
'-Werror=implicit-function-declaration',
|
|
|
|
'-Werror=int-conversion',
|
2019-10-05 02:06:51 +02:00
|
|
|
'-Werror=implicit-int',
|
|
|
|
'-Werror=strict-prototypes',
|
|
|
|
'-Werror=old-style-declaration',
|
|
|
|
'-Werror=old-style-definition',
|
2019-12-23 04:48:17 +01:00
|
|
|
'-Werror=declaration-after-statement',
|
2020-02-08 17:13:46 +01:00
|
|
|
'-Werror=enum-conversion',
|
2021-07-02 18:27:45 +02:00
|
|
|
'-Werror=jump-misses-init',
|
|
|
|
'-Werror=strict-prototypes',
|
|
|
|
# '-Werror=nested-externs',
|
2020-02-08 17:13:46 +01:00
|
|
|
'-fnonconst-initializers' # owcc
|
2019-09-27 23:23:21 +02:00
|
|
|
]
|
|
|
|
|
2021-01-29 01:33:14 +01:00
|
|
|
cflags, linkflags = conf.get_optimization_flags()
|
2019-10-11 03:12:07 +02:00
|
|
|
|
2023-02-05 02:09:32 +01:00
|
|
|
# on the Switch, allow undefined symbols by default, which is needed for libsolder to work
|
2023-02-08 00:52:48 +01:00
|
|
|
# we'll specifically disallow them for the engine executable
|
|
|
|
# additionally, shared libs are linked without standard libs, we'll add those back in the engine wscript
|
2023-02-05 02:09:32 +01:00
|
|
|
if conf.env.DEST_OS == 'nswitch':
|
|
|
|
linkflags.remove('-Wl,--no-undefined')
|
|
|
|
conf.env.append_unique('LINKFLAGS_cshlib', ['-nostdlib', '-nostartfiles'])
|
|
|
|
conf.env.append_unique('LINKFLAGS_cxxshlib', ['-nostdlib', '-nostartfiles'])
|
|
|
|
|
2019-10-11 03:12:07 +02:00
|
|
|
# And here C++ flags starts to be treated separately
|
|
|
|
cxxflags = list(cflags)
|
2021-09-05 23:04:27 +02:00
|
|
|
if conf.env.COMPILER_CC != 'msvc' and not conf.options.DISABLE_WERROR:
|
2021-01-29 01:33:14 +01:00
|
|
|
conf.check_cc(cflags=cflags, linkflags=linkflags, msg='Checking for required C flags')
|
|
|
|
conf.check_cxx(cxxflags=cflags, linkflags=linkflags, msg='Checking for required C++ flags')
|
2019-12-03 00:35:23 +01:00
|
|
|
|
|
|
|
conf.env.append_unique('CFLAGS', cflags)
|
|
|
|
conf.env.append_unique('CXXFLAGS', cxxflags)
|
|
|
|
conf.env.append_unique('LINKFLAGS', linkflags)
|
2019-10-05 02:06:51 +02:00
|
|
|
|
2019-10-11 06:40:40 +02:00
|
|
|
cxxflags += conf.filter_cxxflags(compiler_optional_flags, cflags)
|
2019-10-18 05:20:27 +02:00
|
|
|
cflags += conf.filter_cflags(compiler_optional_flags + c_compiler_optional_flags, cflags)
|
2019-09-27 23:59:09 +02:00
|
|
|
|
2023-01-14 07:35:30 +01:00
|
|
|
# check if we need to use irix linkflags
|
|
|
|
if conf.env.DEST_OS == 'irix' and conf.env.COMPILER_CC == 'gcc':
|
|
|
|
linkflags.remove('-Wl,--no-undefined')
|
|
|
|
linkflags.append('-Wl,--unresolved-symbols=ignore-all')
|
|
|
|
# check if we're in a sgug environment
|
|
|
|
if 'sgug' in os.environ['LD_LIBRARYN32_PATH']:
|
|
|
|
linkflags.append('-lc')
|
|
|
|
|
2019-10-11 03:12:07 +02:00
|
|
|
conf.env.append_unique('CFLAGS', cflags)
|
|
|
|
conf.env.append_unique('CXXFLAGS', cxxflags)
|
|
|
|
conf.env.append_unique('LINKFLAGS', linkflags)
|
2018-10-24 19:12:32 +02:00
|
|
|
|
2021-03-05 13:57:52 +01:00
|
|
|
conf.env.ENABLE_UTILS = conf.options.ENABLE_UTILS
|
2022-01-15 04:24:57 +01:00
|
|
|
conf.env.ENABLE_FUZZER = conf.options.ENABLE_FUZZER
|
2018-12-13 06:08:03 +01:00
|
|
|
conf.env.DEDICATED = conf.options.DEDICATED
|
2019-02-19 15:49:09 +01:00
|
|
|
conf.env.SINGLE_BINARY = conf.options.SINGLE_BINARY or conf.env.DEDICATED
|
2018-11-05 03:57:32 +01:00
|
|
|
|
2022-09-10 19:54:34 +02:00
|
|
|
conf.env.NANOGL = conf.options.NANOGL or conf.options.ALL_RENDERERS
|
|
|
|
conf.env.GLWES = conf.options.GLWES or conf.options.ALL_RENDERERS
|
|
|
|
conf.env.GL4ES = conf.options.GL4ES or conf.options.ALL_RENDERERS
|
|
|
|
conf.env.GL = conf.options.GL or conf.options.ALL_RENDERERS
|
|
|
|
conf.env.SOFT = conf.options.SOFT or conf.options.ALL_RENDERERS
|
2023-02-16 19:19:30 +01:00
|
|
|
conf.env.VULKAN = conf.options.VULKAN or conf.options.ALL_RENDERERS
|
2022-09-10 19:54:34 +02:00
|
|
|
|
2022-09-11 01:12:44 +02:00
|
|
|
conf.env.GAMEDIR = conf.options.GAMEDIR
|
|
|
|
conf.define('XASH_GAMEDIR', conf.options.GAMEDIR)
|
|
|
|
|
2022-12-17 21:16:49 +01:00
|
|
|
# check if we can use C99 stdint
|
|
|
|
conf.define('STDINT_H', 'stdint.h' if conf.check_cc(header_name='stdint.h', mandatory=False) else 'pstdint.h')
|
|
|
|
|
|
|
|
# check if we can use alloca.h or malloc.h
|
|
|
|
if conf.check_cc(header_name='alloca.h', mandatory=False):
|
|
|
|
conf.define('ALLOCA_H', 'alloca.h')
|
|
|
|
elif conf.check_cc(header_name='malloc.h', mandatory=False):
|
|
|
|
conf.define('ALLOCA_H', 'malloc.h')
|
|
|
|
|
2018-12-13 06:08:03 +01:00
|
|
|
if conf.env.DEST_OS != 'win32':
|
2023-02-05 02:09:32 +01:00
|
|
|
if conf.env.DEST_OS == 'nswitch':
|
2023-02-08 00:52:48 +01:00
|
|
|
conf.check_cfg(package='solder', args='--cflags --libs', uselib_store='SOLDER', mandatory=True)
|
|
|
|
if conf.env.HAVE_SOLDER and conf.env.LIB_SOLDER and conf.options.BUILD_TYPE == 'debug':
|
|
|
|
conf.env.LIB_SOLDER[0] += 'd' # load libsolderd in debug mode
|
2023-02-05 02:09:32 +01:00
|
|
|
else:
|
|
|
|
conf.check_cc(lib='dl', mandatory=False)
|
2019-09-19 16:07:41 +02:00
|
|
|
|
2019-11-04 23:01:33 +01:00
|
|
|
if not conf.env.LIB_M: # HACK: already added in xcompile!
|
|
|
|
conf.check_cc(lib='m')
|
2022-11-16 23:23:33 +01:00
|
|
|
|
|
|
|
if conf.env.DEST_OS == 'android':
|
|
|
|
conf.check_cc(lib='log')
|
2018-12-13 06:08:03 +01:00
|
|
|
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
|
2022-12-17 21:16:49 +01:00
|
|
|
a = [ 'user32', 'shell32', 'gdi32', 'advapi32', 'dbghelp', 'psapi', 'ws2_32' ]
|
2021-06-14 00:13:28 +02:00
|
|
|
if conf.env.COMPILER_CC == 'msvc':
|
|
|
|
for i in a:
|
|
|
|
conf.start_msg('Checking for MSVC library')
|
|
|
|
conf.check_lib_msvc(i)
|
|
|
|
conf.end_msg(i)
|
|
|
|
else:
|
|
|
|
for i in a:
|
|
|
|
conf.check_cc(lib = i)
|
2018-10-24 19:12:32 +02:00
|
|
|
|
2021-03-01 19:46:58 +01:00
|
|
|
# check if we can use C99 tgmath
|
|
|
|
if conf.check_cc(header_name='tgmath.h', mandatory=False):
|
|
|
|
if conf.env.COMPILER_CC == 'msvc':
|
|
|
|
conf.define('_CRT_SILENCE_NONCONFORMING_TGMATH_H', 1)
|
|
|
|
tgmath_usable = conf.check_cc(fragment='''#include<tgmath.h>
|
2021-03-06 22:28:57 +01:00
|
|
|
const float val = 2, val2 = 3;
|
|
|
|
int main(void){ return (int)(-asin(val) + cos(val2)); }''',
|
2021-03-01 19:46:58 +01:00
|
|
|
msg='Checking if tgmath.h is usable', mandatory=False, use='M')
|
|
|
|
conf.define_cond('HAVE_TGMATH_H', tgmath_usable)
|
|
|
|
else:
|
|
|
|
conf.undefine('HAVE_TGMATH_H')
|
|
|
|
|
2022-02-01 17:42:38 +01:00
|
|
|
# set _FILE_OFFSET_BITS=64 for filesystems with 64-bit inodes
|
|
|
|
if conf.env.DEST_OS != 'win32' and conf.env.DEST_SIZEOF_VOID_P == 4:
|
2022-06-12 03:25:09 +02:00
|
|
|
# check was borrowed from libarchive source code
|
|
|
|
file_offset_bits_usable = conf.check_cc(fragment='''
|
|
|
|
#define _FILE_OFFSET_BITS 64
|
|
|
|
#include <sys/types.h>
|
|
|
|
#define KB ((off_t)1024)
|
|
|
|
#define MB ((off_t)1024 * KB)
|
|
|
|
#define GB ((off_t)1024 * MB)
|
|
|
|
#define TB ((off_t)1024 * GB)
|
|
|
|
int t2[(((64 * GB -1) % 671088649) == 268434537)
|
|
|
|
&& (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1];
|
|
|
|
int main(void) { return 0; }''',
|
2022-02-01 17:42:38 +01:00
|
|
|
msg='Checking if _FILE_OFFSET_BITS can be defined to 64', mandatory=False)
|
|
|
|
if file_offset_bits_usable:
|
|
|
|
conf.define('_FILE_OFFSET_BITS', 64)
|
|
|
|
else: conf.undefine('_FILE_OFFSET_BITS')
|
|
|
|
|
2022-06-29 03:00:35 +02:00
|
|
|
if conf.env.DEST_OS != 'win32':
|
2022-06-29 01:43:09 +02:00
|
|
|
strcasestr_frag = '''#include <string.h>
|
|
|
|
int main(int argc, char **argv) { strcasestr(argv[1], argv[2]); return 0; }'''
|
2022-12-17 21:16:49 +01:00
|
|
|
strchrnul_frag = '''#include <string.h>
|
|
|
|
int main(int argc, char **argv) { strchrnul(argv[1], 'x'); return 0; }'''
|
|
|
|
|
|
|
|
def check_gnu_function(frag, msg, define):
|
|
|
|
if conf.check_cc(msg=msg, mandatory=False, fragment=frag):
|
|
|
|
conf.define(define, 1)
|
|
|
|
elif conf.check_cc(msg='... with _GNU_SOURCE?', mandatory=False, fragment=frag, defines='_GNU_SOURCE=1'):
|
|
|
|
conf.define(define, 1)
|
|
|
|
conf.define('_GNU_SOURCE', 1)
|
|
|
|
check_gnu_function(strcasestr_frag, 'Checking for strcasestr', 'HAVE_STRCASESTR')
|
|
|
|
check_gnu_function(strchrnul_frag, 'Checking for strchrnul', 'HAVE_STRCHRNUL')
|
2021-12-03 07:22:19 +01:00
|
|
|
|
2018-05-29 00:02:32 +02:00
|
|
|
# indicate if we are packaging for Linux/BSD
|
2021-11-25 14:52:28 +01:00
|
|
|
if conf.options.PACKAGING:
|
2022-10-02 21:28:53 +02:00
|
|
|
conf.env.LIBDIR = conf.env.BINDIR = conf.env.LIBDIR + '/xash3d'
|
2021-03-05 13:57:52 +01:00
|
|
|
conf.env.SHAREDIR = '${PREFIX}/share/xash3d'
|
2018-05-29 00:02:32 +02:00
|
|
|
else:
|
2023-02-05 02:09:32 +01:00
|
|
|
if sys.platform != 'win32' and conf.env.DEST_OS != 'android':
|
2021-11-27 03:57:01 +01:00
|
|
|
conf.env.PREFIX = '/'
|
|
|
|
|
2021-03-05 13:57:52 +01:00
|
|
|
conf.env.SHAREDIR = conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX
|
2018-10-08 21:38:59 +02:00
|
|
|
|
2022-08-19 03:03:53 +02:00
|
|
|
if not conf.options.BUILD_BUNDLED_DEPS:
|
|
|
|
# check if we can use system opus
|
2022-08-31 18:48:42 +02:00
|
|
|
conf.define('CUSTOM_MODES', 1)
|
|
|
|
|
|
|
|
# try to link with export that only exists with CUSTOM_MODES defined
|
2022-08-31 04:44:20 +02:00
|
|
|
if conf.check_pkg('opus', 'opus', '''#include <opus_custom.h>
|
2022-08-31 18:48:42 +02:00
|
|
|
int main(void){ return !opus_custom_encoder_init(0, 0, 0); }''', fatal = False):
|
2022-08-19 03:03:53 +02:00
|
|
|
conf.env.HAVE_SYSTEM_OPUS = True
|
2022-08-31 18:48:42 +02:00
|
|
|
else:
|
|
|
|
conf.undefine('CUSTOM_MODES')
|
2022-08-19 03:03:53 +02:00
|
|
|
|
2019-10-11 02:10:08 +02:00
|
|
|
conf.define('XASH_BUILD_COMMIT', conf.env.GIT_VERSION if conf.env.GIT_VERSION else 'notset')
|
2021-01-29 01:33:14 +01:00
|
|
|
conf.define('XASH_LOW_MEMORY', conf.options.LOW_MEMORY)
|
2019-10-26 07:12:59 +02:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
for i in SUBDIRS:
|
2019-11-04 23:01:33 +01:00
|
|
|
if not i.is_enabled(conf):
|
2019-02-19 15:49:09 +01:00
|
|
|
continue
|
|
|
|
|
2019-04-10 23:15:48 +02:00
|
|
|
conf.add_subproject(i.name)
|
2018-05-28 17:17:25 +02:00
|
|
|
|
|
|
|
def build(bld):
|
2022-10-04 02:02:49 +02:00
|
|
|
# don't clean QtCreator files and reconfigure saved options
|
|
|
|
bld.clean_files = bld.bldnode.ant_glob('**',
|
|
|
|
excl='*.user configuration.py .lock* *conf_check_*/** config.log %s/*' % Build.CACHE_DIR,
|
|
|
|
quiet=True, generator=True)
|
|
|
|
|
2019-11-17 21:31:25 +01:00
|
|
|
bld.load('xshlib')
|
2021-05-09 15:32:53 +02:00
|
|
|
|
2019-02-19 15:49:09 +01:00
|
|
|
for i in SUBDIRS:
|
2019-11-04 23:01:33 +01:00
|
|
|
if not i.is_enabled(bld):
|
2019-02-19 15:49:09 +01:00
|
|
|
continue
|
|
|
|
|
2019-04-10 23:15:48 +02:00
|
|
|
bld.add_subproject(i.name)
|