2018-05-28 17:17:25 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# mittorn, 2018
|
|
|
|
|
|
|
|
from waflib import Logs
|
2021-02-28 13:39:22 +01:00
|
|
|
from waflib.extras import pthread
|
2018-05-28 17:17:25 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
top = '.'
|
|
|
|
|
|
|
|
def options(opt):
|
2019-02-19 14:33:14 +01:00
|
|
|
grp = opt.add_option_group('Engine options')
|
|
|
|
|
2019-11-04 23:35:20 +01:00
|
|
|
grp.add_option('--enable-fbdev', action = 'store_true', dest = 'FBDEV_SW', default = False,
|
2019-10-21 20:41:44 +02:00
|
|
|
help = 'build fbdev-only software-only engine')
|
2019-11-04 23:35:20 +01:00
|
|
|
|
2019-10-28 06:31:29 +01:00
|
|
|
grp.add_option('--disable-async-resolve', action = 'store_true', dest = 'NO_ASYNC_RESOLVE', default = False,
|
2019-11-04 23:35:20 +01:00
|
|
|
help = 'disable multithreaded operations(asynchronous name resolution)')
|
|
|
|
|
2019-10-28 06:31:29 +01:00
|
|
|
grp.add_option('--enable-custom-swap', action = 'store_true', dest = 'CUSTOM_SWAP', default = False,
|
2019-10-26 07:12:59 +02:00
|
|
|
help = 'enable custom swap allocator. For devices with no swap support')
|
2019-01-28 15:09:06 +01:00
|
|
|
|
2019-10-24 11:42:20 +02:00
|
|
|
grp.add_option('--enable-legacy-sdl', action = 'store_true', dest = 'SDL12', default = False,
|
2024-05-25 03:58:28 +02:00
|
|
|
help = 'enable using SDL1.2 instead of SDL2(not recommended) [default: %(default)s]')
|
2019-11-17 21:31:25 +01:00
|
|
|
|
|
|
|
grp.add_option('--enable-static-binary', action = 'store_true', dest = 'STATIC', default = False,
|
2024-05-25 03:58:28 +02:00
|
|
|
help = 'build static binary(not recommended, --single-binary required) [default: %(default)s]')
|
2019-10-24 11:42:20 +02:00
|
|
|
|
2021-06-20 18:55:31 +02:00
|
|
|
grp.add_option('--enable-engine-tests', action = 'store_true', dest = 'ENGINE_TESTS', default = False,
|
2024-05-25 03:58:28 +02:00
|
|
|
help = 'embed tests into the engine, jump into them by -runtests command line switch [default: %(default)s]')
|
2021-06-20 18:55:31 +02:00
|
|
|
|
2022-01-15 04:24:57 +01:00
|
|
|
grp.add_option('--enable-engine-fuzz', action = 'store_true', dest = 'ENGINE_FUZZ', default = False,
|
2024-05-25 03:58:28 +02:00
|
|
|
help = 'add LLVM libFuzzer [default: %(default)s]' )
|
2022-01-15 04:24:57 +01:00
|
|
|
|
2024-07-17 19:43:38 +02:00
|
|
|
grp.add_option('--enable-ffmpeg', action = 'store_true', dest = 'FFMPEG', default = False,
|
|
|
|
help = '') # hidden option, does nothing
|
|
|
|
|
2022-08-15 06:33:18 +02:00
|
|
|
opt.load('sdl2')
|
2018-05-28 17:17:25 +02:00
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
# check for dedicated server build
|
|
|
|
if conf.options.DEDICATED:
|
2019-10-11 02:10:08 +02:00
|
|
|
conf.define('XASH_DEDICATED', 1)
|
2020-02-08 17:13:46 +01:00
|
|
|
elif conf.env.DEST_OS == 'dos':
|
|
|
|
conf.options.STATIC = True
|
|
|
|
conf.options.NO_ASYNC_RESOLVE = True
|
|
|
|
if not conf.check_cc( fragment='int main(){ int i = socket();}', lib = 'wattcpwl', mandatory=False ):
|
|
|
|
conf.define('XASH_NO_NETWORK',1)
|
2023-02-05 02:09:32 +01:00
|
|
|
elif conf.env.DEST_OS == 'nswitch':
|
2023-02-08 00:52:48 +01:00
|
|
|
# re-enable undefined reference errors
|
|
|
|
conf.env.CXXFLAGS += ['-Wl,--no-undefined']
|
|
|
|
conf.env.CFLAGS += ['-Wl,--no-undefined']
|
2023-12-02 18:25:51 +01:00
|
|
|
# allow the SDL2 sanity check to complete properly by linking in lm normally
|
|
|
|
conf.env.LDFLAGS += ['-lm']
|
2023-02-05 02:09:32 +01:00
|
|
|
conf.load('sdl2')
|
|
|
|
if not conf.env.HAVE_SDL2:
|
|
|
|
conf.fatal('SDL2 not availiable! Install switch-sdl2!')
|
|
|
|
conf.define('XASH_SDL', 2)
|
2023-02-13 20:53:17 +01:00
|
|
|
# then remove them to avoid them getting linked to shared objects
|
2023-12-02 18:25:51 +01:00
|
|
|
conf.env.LIB_SDL2.remove('stdc++') # remove libstdc++ linking from SDL2, we link it later
|
2023-02-08 00:52:48 +01:00
|
|
|
conf.env.LDFLAGS.remove('-lm')
|
2023-02-13 20:53:17 +01:00
|
|
|
elif conf.env.DEST_OS == 'psvita':
|
|
|
|
# allow the SDL2 sanity check to complete properly by linking in some deps missing from the pkg-config file
|
|
|
|
extra_libs = ['-lstdc++', '-lm', '-lSceShaccCgExt', '-lSceShaccCg_stub', '-ltaihen_stub', '-lSceKernelDmacMgr_stub']
|
|
|
|
conf.env.LDFLAGS += extra_libs
|
|
|
|
conf.load('sdl2')
|
|
|
|
if not conf.env.HAVE_SDL2:
|
|
|
|
conf.fatal('SDL2 not availiable! Install switch-sdl2!')
|
|
|
|
conf.define('XASH_SDL', 2)
|
|
|
|
# then remove them to avoid them getting linked to shared objects
|
|
|
|
for lib in extra_libs:
|
|
|
|
conf.env.LDFLAGS.remove(lib)
|
2019-10-21 20:41:44 +02:00
|
|
|
elif conf.options.FBDEV_SW:
|
2019-11-24 01:01:43 +01:00
|
|
|
# unused, XASH_LINUX without XASH_SDL gives fbdev & alsa support
|
|
|
|
# conf.define('XASH_FBDEV', 1)
|
2019-10-26 07:12:59 +02:00
|
|
|
conf.check_cc( lib = 'asound' )
|
2019-10-24 11:42:20 +02:00
|
|
|
elif conf.options.SDL12:
|
|
|
|
conf.define('XASH_SDL', 12)
|
|
|
|
conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' )
|
|
|
|
conf.env.HAVE_SDL2 = True
|
2018-12-20 08:15:08 +01:00
|
|
|
else:
|
2018-12-13 06:03:26 +01:00
|
|
|
conf.load('sdl2')
|
2024-10-10 05:13:56 +02:00
|
|
|
if conf.options.SDL3:
|
|
|
|
if not conf.env.HAVE_SDL3:
|
|
|
|
conf.fatal('SDL3 not available! If you want to build dedicated server, specify --dedicated')
|
|
|
|
conf.define('XASH_SDL', 3)
|
|
|
|
else:
|
|
|
|
if not conf.env.HAVE_SDL2:
|
|
|
|
conf.fatal('SDL2 not available! If you want to build dedicated server, specify --dedicated')
|
|
|
|
conf.define('XASH_SDL', 2)
|
2019-01-28 15:09:06 +01:00
|
|
|
|
2021-06-05 09:54:37 +02:00
|
|
|
if conf.env.DEST_OS == 'haiku':
|
|
|
|
conf.env.LIB_HAIKU = ['network']
|
|
|
|
conf.env.LIBPATH_HAIKU = ['/boot/system/lib']
|
|
|
|
|
2024-10-10 18:06:26 +02:00
|
|
|
if conf.env.DEST_OS == 'wasi':
|
|
|
|
conf.options.NO_ASYNC_RESOLVE = True
|
|
|
|
conf.env.append_unique('CFLAGS', '-mllvm')
|
|
|
|
conf.env.append_unique('CFLAGS', '-wasm-enable-sjlj')
|
|
|
|
|
2024-11-07 05:41:37 +01:00
|
|
|
if conf.env.DEST_OS == 'sunos':
|
|
|
|
conf.check_cc(lib='socket')
|
|
|
|
|
2019-11-17 21:31:25 +01:00
|
|
|
if conf.options.STATIC:
|
|
|
|
conf.env.STATIC = True
|
|
|
|
conf.define('XASH_NO_LIBDL',1)
|
|
|
|
|
2019-10-26 07:12:59 +02:00
|
|
|
if not conf.env.DEST_OS in ['win32', 'android'] and not conf.options.NO_ASYNC_RESOLVE:
|
2024-01-23 19:23:23 +01:00
|
|
|
conf.check_pthreads(mode='c')
|
2019-10-26 07:12:59 +02:00
|
|
|
|
2023-12-27 02:14:19 +01:00
|
|
|
if conf.env.DEST_OS == 'linux':
|
|
|
|
conf.check_cc(lib='rt')
|
|
|
|
|
2020-01-19 02:28:37 +01:00
|
|
|
if hasattr(conf.options, 'DLLEMU'):
|
|
|
|
conf.define_cond('XASH_DLL_LOADER', conf.options.DLLEMU)
|
|
|
|
|
ci: migrate to GitHub Actions
* travis: disable build, disable deploy, add free aarch64/ppc64le/s390x builds
* scripts: cleanup of old CI scripts
* scripts: now port to GitHub Actions
* actions: fix extras checkout
* github: remove codeql action, turned out not to be very useful
* github: remove quiet flag on wget
* github: are we allowed to use envvars?
* github: add needed dependencies for linux
* github: install wget for windows
* scripts: convert our CPU architecture naming into what AppImage uses
* github: run scripts with bash explicitly
* github: first try to upload to GitHub Releases, enable amd64 win32 builds
* Use our uploadtool fork
* ci: include android, motomagx build for gha, refactor cirrus and travis ci scripts
* gha: try to fix build
* travis: try to fix build
* gha: try to fix upload, fix win32 build
* gha: use curl instead of wget, as it's preinstalled for windows. Fix Android build
* gha: add llvm repository, install clang-12 for android
* gha: motomagx: fail fast
* gha: android: explicitly set clang-12 as compiler and llvm-strip-12 as strip
* waifulib: xcompile: respect environment variables when using host compiler for Android
* waifulib: xcompile: use correct environ dict
* gha: try to fix -fuse-ld=lld with clang-12
* waifulib: xcompile: fix typo
* scripts: xcompile: fix motomagx build
* mainui: upgrade
* gha: fix android build, last time
* engine: wscript: disable crashhandler for magx
2021-07-03 19:21:09 +02:00
|
|
|
if conf.env.MAGX:
|
|
|
|
conf.define('XASH_CRASHHANDLER', 0)
|
|
|
|
|
2021-06-20 18:55:31 +02:00
|
|
|
conf.env.ENGINE_TESTS = conf.options.ENGINE_TESTS
|
|
|
|
|
2022-01-15 04:24:57 +01:00
|
|
|
if conf.options.ENGINE_FUZZ:
|
|
|
|
conf.env.append_unique('CFLAGS', '-fsanitize=fuzzer-no-link')
|
|
|
|
conf.env.append_unique('LINKFLAGS', '-fsanitize=fuzzer')
|
|
|
|
|
2024-08-21 11:06:35 +02:00
|
|
|
conf.define('ENGINE_DLL', 1)
|
|
|
|
|
2021-06-20 18:55:31 +02:00
|
|
|
conf.define_cond('XASH_ENGINE_TESTS', conf.env.ENGINE_TESTS)
|
2019-11-17 21:31:25 +01:00
|
|
|
conf.define_cond('XASH_STATIC_LIBS', conf.env.STATIC_LINKING)
|
2019-11-04 23:40:06 +01:00
|
|
|
conf.define_cond('XASH_CUSTOM_SWAP', conf.options.CUSTOM_SWAP)
|
2023-12-30 21:45:17 +01:00
|
|
|
conf.define_cond('XASH_ENABLE_MAIN', conf.env.DISABLE_LAUNCHER)
|
2019-10-26 07:12:59 +02:00
|
|
|
conf.define_cond('XASH_NO_ASYNC_NS_RESOLVE', conf.options.NO_ASYNC_RESOLVE)
|
2019-10-11 02:10:08 +02:00
|
|
|
conf.define_cond('DBGHELP', conf.env.DEST_OS == 'win32')
|
|
|
|
conf.define_cond('PSAPI_VERSION', conf.env.DEST_OS == 'win32') # will be defined as 1
|
2019-05-30 06:38:53 +02:00
|
|
|
|
2023-03-23 23:50:53 +01:00
|
|
|
for refdll in conf.refdlls:
|
|
|
|
refdll.register_define(conf)
|
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
def build(bld):
|
2022-09-10 18:57:04 +02:00
|
|
|
# public includes for renderers and utils use
|
|
|
|
bld(name = 'engine_includes', export_includes = '. common common/imagelib', use = 'filesystem_includes')
|
|
|
|
|
2019-10-27 23:47:18 +01:00
|
|
|
is_cxx_link = False
|
2024-12-02 16:47:48 +01:00
|
|
|
libs = [ 'engine_includes', 'public', 'dllemu', 'werror', 'opus', 'libvorbis', 'libvorbisfile', 'libopusfile' ]
|
2021-06-20 18:55:31 +02:00
|
|
|
|
|
|
|
# basic build: dedicated only
|
2018-10-22 00:47:12 +02:00
|
|
|
source = bld.path.ant_glob([
|
2019-04-08 19:38:10 +02:00
|
|
|
'common/*.c',
|
2018-10-22 00:47:12 +02:00
|
|
|
'common/imagelib/*.c',
|
|
|
|
'common/soundlib/*.c',
|
|
|
|
'server/*.c'])
|
2018-06-14 19:34:51 +02:00
|
|
|
|
2021-06-20 18:55:31 +02:00
|
|
|
if bld.env.ENGINE_TESTS:
|
|
|
|
source += bld.path.ant_glob(['tests/*.c'])
|
|
|
|
|
2020-02-08 17:13:46 +01:00
|
|
|
if bld.env.DEST_OS == 'win32':
|
|
|
|
libs += ['USER32', 'SHELL32', 'GDI32', 'ADVAPI32', 'DBGHELP', 'PSAPI', 'WS2_32' ]
|
|
|
|
source += bld.path.ant_glob(['platform/win32/*.c'])
|
2023-02-13 20:53:17 +01:00
|
|
|
elif bld.env.DEST_OS not in ['dos', 'nswitch', 'psvita']: #posix
|
2023-10-28 09:10:03 +02:00
|
|
|
libs += [ 'M', 'RT', 'PTHREAD', 'ASOUND']
|
2019-11-17 21:31:25 +01:00
|
|
|
if not bld.env.STATIC:
|
|
|
|
libs += ['DL']
|
2018-10-22 00:47:12 +02:00
|
|
|
source += bld.path.ant_glob(['platform/posix/*.c'])
|
2018-06-14 19:34:51 +02:00
|
|
|
|
2018-11-16 14:32:16 +01:00
|
|
|
if bld.env.DEST_OS == 'linux':
|
|
|
|
source += bld.path.ant_glob(['platform/linux/*.c'])
|
|
|
|
|
2023-01-14 07:35:30 +01:00
|
|
|
if bld.env.DEST_OS == 'irix':
|
|
|
|
source += bld.path.ant_glob(['platform/irix/*.c'])
|
|
|
|
|
2020-02-08 17:13:46 +01:00
|
|
|
if bld.env.DEST_OS == 'dos':
|
|
|
|
source += bld.path.ant_glob(['platform/dos/*.c'])
|
|
|
|
source += bld.path.ant_glob(['platform/stub/s_stub.c'])
|
|
|
|
|
2021-06-05 09:54:37 +02:00
|
|
|
if bld.env.DEST_OS == 'haiku':
|
|
|
|
libs.append('HAIKU')
|
2020-02-08 17:13:46 +01:00
|
|
|
|
2019-11-04 23:35:20 +01:00
|
|
|
if bld.get_define('XASH_CUSTOM_SWAP'):
|
2019-11-17 21:31:25 +01:00
|
|
|
source += bld.path.ant_glob(['platform/misc/kmalloc.c', 'platform/misc/sbrk.c'])
|
|
|
|
|
|
|
|
if bld.env.STATIC_LINKING:
|
|
|
|
source += bld.path.ant_glob(['platform/misc/lib_static.c'])
|
|
|
|
is_cxx_link = True
|
2019-10-21 20:41:44 +02:00
|
|
|
|
2024-10-10 05:13:56 +02:00
|
|
|
if bld.env.HAVE_SDL2 or bld.env.HAVE_SDL3:
|
|
|
|
libs.append('SDL3' if bld.env.HAVE_SDL3 else 'SDL2')
|
2018-12-20 07:48:22 +01:00
|
|
|
source += bld.path.ant_glob(['platform/sdl/*.c'])
|
|
|
|
|
2019-10-27 23:47:18 +01:00
|
|
|
if bld.env.MAGX:
|
|
|
|
libs.append('MAGX')
|
|
|
|
is_cxx_link = True
|
|
|
|
|
2019-09-19 16:07:41 +02:00
|
|
|
if bld.env.DEST_OS == 'android':
|
2020-07-08 03:48:46 +02:00
|
|
|
libs += ['LOG']
|
2024-10-24 16:54:09 +02:00
|
|
|
source += bld.path.ant_glob(['platform/android/*.cpp', 'platform/android/*.c', 'platform/linux/*.c'])
|
2018-12-20 07:48:22 +01:00
|
|
|
|
2023-02-05 02:09:32 +01:00
|
|
|
if bld.env.DEST_OS == 'nswitch':
|
|
|
|
libs += [ 'SOLDER' ]
|
|
|
|
source += bld.path.ant_glob(['platform/posix/*.c'])
|
|
|
|
source += bld.path.ant_glob(['platform/nswitch/*.c'])
|
2023-02-13 20:53:17 +01:00
|
|
|
# HACK: link in the entirety of libstdc++ so that dynamic libs could use all of it without manual exporting
|
|
|
|
# we can't do this right away because std::filesystem will complain about not having pathconf(),
|
|
|
|
# which we have defined in sys_nswitch.c
|
2023-12-02 18:25:51 +01:00
|
|
|
bld.env.LDFLAGS += ['-v', '-Wl,--whole-archive', '-lstdc++', '-Wl,--no-whole-archive', '-lm']
|
2023-02-13 20:53:17 +01:00
|
|
|
|
|
|
|
if bld.env.DEST_OS == 'psvita':
|
|
|
|
libs += [ 'VRTLD' ]
|
|
|
|
source += bld.path.ant_glob(['platform/posix/*.c'])
|
|
|
|
source += bld.path.ant_glob(['platform/psvita/*.c'])
|
2023-02-14 23:41:11 +01:00
|
|
|
# HACK: link in the entirety of libstdc++ so that dynamic libs could use all of it without manual exporting
|
2023-02-13 20:53:17 +01:00
|
|
|
# also link in all the funky dependencies that aren't in SDL2's LDFLAGS
|
|
|
|
bld.env.LDFLAGS += [
|
|
|
|
'-Wl,--whole-archive',
|
|
|
|
'-lstdc++',
|
|
|
|
'-lpthread',
|
|
|
|
'-Wl,--no-whole-archive',
|
|
|
|
'-lm',
|
|
|
|
'-lSceShaccCgExt',
|
2023-02-14 23:41:11 +01:00
|
|
|
'-lkubridge_stub',
|
2023-02-13 20:53:17 +01:00
|
|
|
'-ltaihen_stub',
|
2023-02-14 23:41:11 +01:00
|
|
|
'-lSceShaccCg_stub',
|
2023-02-13 20:53:17 +01:00
|
|
|
'-lSceKernelModulemgr_stub',
|
|
|
|
'-lSceSblSsMgr_stub',
|
|
|
|
'-lSceVshBridge_stub',
|
|
|
|
'-lSceKernelDmacMgr_stub'
|
|
|
|
]
|
2023-02-05 02:09:32 +01:00
|
|
|
|
2024-11-07 05:41:37 +01:00
|
|
|
if bld.env.DEST_OS == 'sunos':
|
|
|
|
libs.append('SOCKET')
|
|
|
|
|
2018-12-20 07:48:22 +01:00
|
|
|
# add client files
|
2018-05-28 17:17:25 +02:00
|
|
|
if not bld.env.DEDICATED:
|
|
|
|
source += bld.path.ant_glob([
|
|
|
|
'client/*.c',
|
|
|
|
'client/vgui/*.c',
|
2024-12-02 17:30:55 +01:00
|
|
|
'client/avi/*.c',
|
|
|
|
'client/soundlib/*.c',
|
|
|
|
'client/soundlib/libmpg/*.c',
|
|
|
|
])
|
2024-10-10 18:06:26 +02:00
|
|
|
is_cxx_link = True
|
2024-12-01 17:04:10 +01:00
|
|
|
libs += ['bzip2', 'MultiEmulator']
|
2022-08-25 18:33:16 +02:00
|
|
|
|
2024-10-23 22:22:23 +02:00
|
|
|
rpath = bld.env.DEFAULT_RPATH
|
2018-05-28 17:17:25 +02:00
|
|
|
|
2023-02-13 20:53:17 +01:00
|
|
|
# Switch and PSVita have custom parameters
|
|
|
|
if bld.env.DEST_OS in ['nswitch', 'psvita']:
|
2024-10-23 22:22:23 +02:00
|
|
|
rpath = None
|
|
|
|
install_path = None
|
|
|
|
features = 'cxx c cxxprogram cprogram'
|
|
|
|
# Always build as shared library on Android
|
|
|
|
elif bld.env.DISABLE_LAUNCHER and bld.env.DEST_OS != 'android':
|
|
|
|
install_path = bld.env.BINDIR
|
|
|
|
if bld.env.STATIC:
|
|
|
|
features = 'cxx c cxxprogram_static cprogram_static'
|
|
|
|
elif is_cxx_link:
|
|
|
|
features = 'cxx c cxxprogram cprogram'
|
|
|
|
else:
|
|
|
|
features = 'c cprogram'
|
2018-05-28 17:17:25 +02:00
|
|
|
else:
|
2024-10-23 22:22:23 +02:00
|
|
|
install_path = bld.env.LIBDIR
|
|
|
|
if is_cxx_link:
|
|
|
|
features = 'cxx c cxxshlib cshlib'
|
2023-02-05 02:09:32 +01:00
|
|
|
else:
|
2024-10-23 22:22:23 +02:00
|
|
|
features = 'c cshlib'
|
|
|
|
|
|
|
|
bld(source = source,
|
|
|
|
target = 'xash',
|
|
|
|
features = features,
|
2024-12-02 17:30:55 +01:00
|
|
|
includes = 'server client client/vgui common/soundlib',
|
2024-10-23 22:22:23 +02:00
|
|
|
use = libs,
|
|
|
|
install_path = install_path,
|
|
|
|
nro_install_path = bld.env.BINDIR,
|
|
|
|
nacp = 'platform/nswitch/xash3d-fwgs.nacp',
|
|
|
|
icon = 'platform/nswitch/icon.jpg',
|
|
|
|
sce_sys = 'platform/psvita/sce_sys',
|
|
|
|
title_id = 'XASH10000',
|
|
|
|
app_name = 'xash3d-fwgs',
|
|
|
|
rpath = rpath,
|
|
|
|
)
|