From 063eb151c4b554c6a78990bf488ee1276bf91123 Mon Sep 17 00:00:00 2001 From: mittorn Date: Tue, 1 May 2018 03:04:30 +0700 Subject: [PATCH] waf options for dedicated server and 64-bits --- contib/mittorn/wscript | 61 +++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/contib/mittorn/wscript b/contib/mittorn/wscript index 457d2d2c..882b79a8 100644 --- a/contib/mittorn/wscript +++ b/contib/mittorn/wscript @@ -10,33 +10,64 @@ top = '.' def options(opt): opt.load('compiler_c') # opt.load('msvs') + opt.add_option('--dedicated', action = 'store_true', help = 'build dedicated server only' ) + opt.add_option('--64bits', dest = 'amd64', action = 'store_true', help = 'build 64-bit engine on x86_64' ) + + def configure(conf): conf.load('compiler_c') conf.env.append_unique('CFLAGS', '-O2') - conf.env.append_unique('DEFINES', 'XASH_SDL') conf.env.append_unique('DEFINES', 'SINGLE_BINARY') conf.env.append_value('LINKFLAGS', '-ldl') conf.env.append_value('LINKFLAGS', '-lm') conf.env.append_value('LINKFLAGS', '-pthread') - conf.env.append_value('LINKFLAGS', '-m32') - conf.env.append_value('CFLAGS', '-m32') - conf.check_cfg(path='sdl2-config', args='--cflags --libs', package='', uselib_store='SDL2') + + # check for 64-bit builds + # TODO: check 32-bit toolchain and dependencies + if conf.env.DEST_CPU == 'x86_64' and not conf.options.amd64: + conf.env.append_value('LINKFLAGS', '-m32') + conf.env.append_value('CFLAGS', '-m32') + print('NOTE: will build engine with 64-bit toolchain using -m32') + else: + print('Warning: 64bit engine may be unstable') + + # check for dedicated server build + if conf.options.dedicated: + conf.env.append_unique('DEFINES', 'XASH_DEDICATED') + conf.env.dedicated = True + else: + # TODO: add way to specify SDL2 path, move to separate function + try: + conf.check_cfg(path='sdl2-config', args='--cflags --libs', package='', msg='Checking for SDL2', uselib_store='SDL2') + except conf.errors.ConfigurationError: + conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated') + conf.env.append_unique('DEFINES', 'XASH_SDL') def build(bld): - bld( - target = 'xash', - features = 'c cprogram', - includes = ['../common', '../pm_shared', 'common', 'server', 'client', 'client/vgui', '.' ], - source = bld.path.ant_glob([ + # basic build: dedicated only, no dependencies + use = []; + source = bld.path.ant_glob([ 'common/*.c', 'common/imagelib/*.c', 'common/soundlib/*.c', 'common/soundlib/libmpg/*.c', - 'client/*.c', - 'client/vgui/*.c', - 'client/avi/*.c', - 'server/*.c', - 'platform/sdl/*.c']), - use = ['SDL2', 'm', 'pthread'] + 'server/*.c']) + + # add client files and sdl2 library + if not bld.env.dedicated: + use += ['SDL2'] + source += bld.path.ant_glob([ + 'client/*.c', + 'client/vgui/*.c', + 'client/avi/*.c', + 'platform/sdl/*.c']) + + + bld( + target = 'xash', + features = 'c cprogram', + includes = ['../common', '../pm_shared', 'common', 'server', 'client', 'client/vgui', '.' ], + source = source, + use = use )