2018-05-28 17:17:25 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# mittorn, 2018
|
|
|
|
|
|
|
|
from waflib import Logs
|
|
|
|
import os
|
|
|
|
|
|
|
|
top = '.'
|
|
|
|
|
|
|
|
def options(opt):
|
2018-07-10 16:29:05 +02:00
|
|
|
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!)')
|
2018-05-28 17:17:25 +02:00
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
# check for dedicated server build
|
|
|
|
if conf.options.DEDICATED:
|
2018-06-14 19:34:51 +02:00
|
|
|
if(conf.env.DEST_OS == 'linux'):
|
|
|
|
conf.check( lib='rt' )
|
2018-05-28 17:17:25 +02:00
|
|
|
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:
|
2018-10-08 21:27:54 +02:00
|
|
|
if(conf.options.SDL2_PATH):
|
|
|
|
conf.start_msg('Configuring SDL2 by provided path')
|
|
|
|
conf.env.HAVE_SDL2 = 1
|
2018-11-18 20:48:52 +01:00
|
|
|
conf.env.INCLUDES_SDL2 = [
|
|
|
|
os.path.abspath(os.path.join(conf.options.SDL2_PATH, 'include')),
|
2018-11-18 20:56:30 +01:00
|
|
|
os.path.abspath(os.path.join(conf.options.SDL2_PATH, 'include/SDL2'))
|
2018-11-18 20:48:52 +01:00
|
|
|
]
|
2018-11-18 16:52:57 +01:00
|
|
|
libpath = 'lib'
|
|
|
|
if(conf.env.COMPILER_CC == 'msvc'):
|
|
|
|
libpath = 'lib/x86'
|
|
|
|
conf.env.LIBPATH_SDL2 = [os.path.abspath(os.path.join(conf.options.SDL2_PATH, libpath))]
|
2018-10-08 21:27:54 +02:00
|
|
|
conf.env.LIB_SDL2 = ['SDL2']
|
2018-11-18 20:48:52 +01:00
|
|
|
conf.end_msg('yes: {0}, {1}, {2}'.format(conf.env.LIB_SDL2, conf.env.LIBPATH_SDL2, conf.env.INCLUDES_SDL2))
|
2018-10-08 21:27:54 +02:00
|
|
|
else:
|
|
|
|
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
|
2018-05-28 17:17:25 +02:00
|
|
|
conf.env.append_unique('DEFINES', 'XASH_SDL')
|
|
|
|
|
2018-07-10 16:29:05 +02:00
|
|
|
if(conf.options.SUPPORT_BSP2_FORMAT):
|
|
|
|
conf.env.append_unique('DEFINES', 'SUPPORT_BSP2_FORMAT')
|
|
|
|
|
2018-06-14 19:34:51 +02:00
|
|
|
if conf.env.DEST_OS == 'win32':
|
2018-11-18 21:59:23 +01:00
|
|
|
conf.check( lib='user32' )
|
|
|
|
conf.check( lib='shell32' )
|
|
|
|
conf.check( lib='gdi32' )
|
|
|
|
conf.check( lib='advapi32' )
|
|
|
|
conf.check( lib='dbghelp' )
|
2018-11-18 23:19:24 +01:00
|
|
|
conf.check( lib='psapi' )
|
2018-10-24 19:17:44 +02:00
|
|
|
conf.env.append_unique('DEFINES', 'DBGHELP')
|
2018-06-14 19:34:51 +02:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
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)]
|
|
|
|
|
2018-06-14 19:34:51 +02:00
|
|
|
libs = []
|
2018-10-22 00:47:12 +02:00
|
|
|
source = bld.path.ant_glob([
|
|
|
|
'common/*.c',
|
|
|
|
'common/imagelib/*.c',
|
|
|
|
'common/soundlib/*.c',
|
|
|
|
'common/soundlib/libmpg/*.c',
|
|
|
|
'server/*.c'])
|
2018-06-14 19:34:51 +02:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
# basic build: dedicated only, no dependencies
|
|
|
|
if bld.env.DEST_OS != 'win32':
|
2018-11-18 23:19:24 +01:00
|
|
|
libs += [ 'DL' , 'M', 'PTHREAD' ]
|
2018-10-22 00:47:12 +02:00
|
|
|
source += bld.path.ant_glob(['platform/posix/*.c'])
|
2018-06-14 19:34:51 +02:00
|
|
|
else:
|
2018-11-18 23:19:24 +01:00
|
|
|
libs += ['USER32', 'SHELL32', 'GDI32', 'ADVAPI32', 'DBGHELP', 'PSAPI']
|
2018-06-14 19:34:51 +02:00
|
|
|
source += bld.path.ant_glob(['platform/win32/*.c'])
|
|
|
|
|
2018-11-16 14:32:16 +01:00
|
|
|
if bld.env.DEST_OS == 'linux':
|
|
|
|
source += bld.path.ant_glob(['platform/linux/*.c'])
|
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
# 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')
|
2018-11-18 21:59:23 +01:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
includes = ['common', 'server', 'client', 'client/vgui', '.', '../common', '../pm_shared' ]
|
|
|
|
|
|
|
|
if(bld.env.SINGLE_BINARY):
|
|
|
|
bld(
|
|
|
|
source = source,
|
|
|
|
target = 'xash',
|
|
|
|
features = 'c cprogram',
|
|
|
|
includes = includes,
|
2018-05-29 00:02:32 +02:00
|
|
|
use = libs,
|
2018-10-24 19:12:32 +02:00
|
|
|
install_path = bld.env.BINDIR,
|
|
|
|
subsystem = bld.env.MSVC_SUBSYSTEM
|
2018-05-28 17:17:25 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
bld.shlib(
|
|
|
|
source = source,
|
|
|
|
target = 'xash',
|
|
|
|
features = 'c',
|
|
|
|
includes = includes,
|
2018-05-29 00:02:32 +02:00
|
|
|
use = libs,
|
2018-10-24 19:12:32 +02:00
|
|
|
install_path = bld.env.LIBDIR,
|
|
|
|
subsystem = bld.env.MSVC_SUBSYSTEM
|
2018-05-28 17:17:25 +02:00
|
|
|
)
|