wscript: add options for low memory, async ns resolve and swap allocator

This commit is contained in:
mittorn 2019-10-26 12:12:59 +07:00
parent feb01b270e
commit ba1347a8ce
2 changed files with 24 additions and 11 deletions

View File

@ -14,6 +14,10 @@ def options(opt):
help = 'enable console input from stdin (always enabled for dedicated) [default: %default]')
grp.add_option('--fbdev', action = 'store_true', dest = 'FBDEV_SW', default = False,
help = 'build fbdev-only software-only engine')
grp.add_option('--no-async-resolve', action = 'store_true', dest = 'NO_ASYNC_RESOLVE', default = False,
help = 'disable asynchronous name resolution')
grp.add_option('--custom-swap-allocator', action = 'store_true', dest = 'CUSTOM_SWAP', default = False,
help = 'enable custom swap allocator. For devices with no swap support')
opt.load('sdl2')
@ -29,6 +33,7 @@ def configure(conf):
elif conf.options.FBDEV_SW:
conf.define('XASH_FBDEV', 1)
conf.check_cc( lib = 'asound' )
conf.check_cc( lib = 'rt' )
else:
conf.load('sdl2')
if not conf.env.HAVE_SDL2:
@ -38,8 +43,15 @@ def configure(conf):
if conf.options.USE_SELECT == None:
conf.options.USE_SELECT = conf.options.DEDICATED
conf.define_cond('SINGLE_BINARY', conf.env.SINGLE_BINARY)
if not conf.env.DEST_OS in ['win32', 'android'] and not conf.options.NO_ASYNC_RESOLVE:
conf.check_cc( lib='pthread' )
if conf.options.CUSTOM_SWAP:
conf.define('XASH_CUSTOM_SWAP',1)
conf.env.CUSTOM_SWAP = True
conf.define_cond('SINGLE_BINARY', conf.env.SINGLE_BINARY)
conf.define_cond('XASH_NO_ASYNC_NS_RESOLVE', conf.options.NO_ASYNC_RESOLVE)
conf.define_cond('XASH_USE_SELECT', conf.options.USE_SELECT or conf.options.DEDICATED)
conf.define_cond('SUPPORT_BSP2_FORMAT', conf.options.SUPPORT_BSP2_FORMAT)
conf.define_cond('XASH_64BIT', conf.env.DEST_SIZEOF_VOID_P != 4)
@ -57,8 +69,9 @@ def build(bld):
# basic build: dedicated only, no dependencies
if bld.env.DEST_OS != 'win32':
libs += [ 'DL' , 'M' , 'RT', 'PTHREAD']
libs += [ 'DL' , 'M' , 'RT', 'PTHREAD', 'ASOUND']
source += bld.path.ant_glob(['platform/posix/*.c'])
else:
libs += ['USER32', 'SHELL32', 'GDI32', 'ADVAPI32', 'DBGHELP', 'PSAPI', 'WS2_32' ]
source += bld.path.ant_glob(['platform/win32/*.c'])
@ -66,7 +79,8 @@ def build(bld):
if bld.env.DEST_OS == 'linux':
source += bld.path.ant_glob(['platform/linux/*.c'])
source += bld.path.ant_glob(['platform/stub/*.c'])
if bld.env.CUSTOM_SWAP:
source += bld.path.ant_glob(['platform/swap/*.c'])
if bld.env.HAVE_SDL2:
libs.append('SDL2')
@ -83,11 +97,6 @@ def build(bld):
'client/vgui/*.c',
'client/avi/*.c'])
if bld.env.DEST_OS == 'linux' and not bld.env.HAVE_SDL2:
libs.append('RT')
if not bld.env.DEDICATED:
libs.append('ASOUND')
# HACK: public headers must be put before common, so we don't get wrong mathlib included
includes = ['common', 'server', 'client', 'client/vgui', '.', '../public', '../common', '../pm_shared' ]

View File

@ -64,6 +64,9 @@ def options(opt):
grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False,
help = 'enable polyhedral optimization if possible [default: %default]')
grp.add_option('--low-memory', action = 'store', dest = 'LOW_MEMORY', default = 0,
help = 'enable low memory mode (only for devices have <128 ram)')
opt.load('subproject')
opt.add_subproject(subdirs())
@ -250,8 +253,6 @@ def configure(conf):
if not conf.env.LIB_M: # HACK: already added in xcompile!
conf.check_cc( lib='m' )
if conf.env.DEST_OS != 'android': # Android has pthread directly in libc
conf.check_cc( lib='pthread' )
else:
# Common Win32 libraries
# Don't check them more than once, to save time
@ -287,6 +288,9 @@ def configure(conf):
conf.define('XASH_BUILD_COMMIT', conf.env.GIT_VERSION if conf.env.GIT_VERSION else 'notset')
if conf.options.LOW_MEMORY:
conf.define('XASH_LOW_MEMORY', int(conf.options.LOW_MEMORY))
for i in SUBDIRS:
if conf.env.SINGLE_BINARY and i.singlebin:
continue