xash3d-fwgs/engine/wscript

111 lines
3.0 KiB
Python

#! /usr/bin/env python
# encoding: utf-8
# mittorn, 2018
from waflib import Logs
import os
top = '.'
def options(opt):
opt.add_option(
'--sdl2', action='store', type='string', dest = 'SDL2_PATH', default = None,
help = 'SDL2 path to build(required for Windows)')
opt.add_option(
'--enable-bsp2', action = 'store_true', dest = 'SUPPORT_BSP2_FORMAT', default = False,
help = 'build engine with BSP2 map support(recommended for Quake, breaks compability!)')
def configure(conf):
# check for dedicated server build
if conf.options.DEDICATED:
if(conf.env.DEST_OS == 'linux'):
conf.check( lib='rt' )
conf.env.append_unique('DEFINES', 'SINGLE_BINARY')
conf.env.append_unique('DEFINES', 'XASH_DEDICATED')
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:
if(conf.options.SDL2_PATH):
conf.start_msg('Configuring SDL2 by provided path')
conf.env.HAVE_SDL2 = 1
conf.env.INCLUDES_SDL2 = [os.path.abspath(os.path.join(conf.options.SDL2_PATH, 'include'))]
conf.env.LIBPATH_SDL2 = [os.path.abspath(os.path.join(conf.options.SDL2_PATH, 'lib/x86'))]
conf.env.LIB_SDL2 = ['SDL2']
conf.end_msg('ok')
else:
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
conf.env.append_unique('DEFINES', 'XASH_SDL')
if(conf.options.SUPPORT_BSP2_FORMAT):
conf.env.append_unique('DEFINES', 'SUPPORT_BSP2_FORMAT')
if conf.env.DEST_OS == 'win32':
conf.check( lib='USER32' )
conf.check( lib='SHELL32' )
conf.check( lib='GDI32' )
conf.check( lib='ADVAPI32' )
def get_subproject_name(ctx):
return os.path.basename(os.path.realpath(str(ctx.path)))
def build(bld):
bld.load_envs()
bld.env = bld.all_envs[get_subproject_name(bld)]
libs = []
source = []
# basic build: dedicated only, no dependencies
if bld.env.DEST_OS != 'win32':
libs += [ 'DL', 'M', 'PTHREAD' ]
else:
libs += ['USER32', 'SHELL32', 'GDI32', 'ADVAPI32']
source += bld.path.ant_glob(['platform/win32/*.c'])
source += bld.path.ant_glob([
'common/*.c',
'common/imagelib/*.c',
'common/soundlib/*.c',
'common/soundlib/libmpg/*.c',
'server/*.c'])
# add client files and sdl2 library
if not bld.env.DEDICATED:
libs.append( 'SDL2' )
source += bld.path.ant_glob([
'client/*.c',
'client/vgui/*.c',
'client/avi/*.c',
'platform/sdl/*.c'])
else:
if(bld.env.DEST_OS == 'linux'):
libs.append('RT')
includes = ['common', 'server', 'client', 'client/vgui', '.', '../common', '../pm_shared' ]
if(bld.env.SINGLE_BINARY):
bld(
source = source,
target = 'xash',
features = 'c cprogram',
includes = includes,
use = libs,
install_path = bld.env.BINDIR
)
else:
bld.shlib(
source = source,
target = 'xash',
features = 'c',
includes = includes,
use = libs,
install_path = bld.env.LIBDIR
)