MSVC & Win32 wscript fixes

This commit is contained in:
Alibek Omarov 2018-06-14 20:34:51 +03:00
parent 473810fc0c
commit 572705bc08
3 changed files with 74 additions and 48 deletions

View File

@ -14,6 +14,7 @@ def options(opt):
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')
@ -30,6 +31,12 @@ def configure(conf):
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
conf.env.append_unique('DEFINES', 'XASH_SDL')
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)))
@ -37,11 +44,17 @@ 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' ]
libs += [ 'DL', 'M', 'PTHREAD' ]
else:
libs += ['USER32', 'SHELL32', 'GDI32', 'ADVAPI32']
source += bld.path.ant_glob(['platform/win32/*.c'])
source = bld.path.ant_glob([
source += bld.path.ant_glob([
'common/*.c',
'common/imagelib/*.c',
'common/soundlib/*.c',

View File

@ -16,7 +16,8 @@ def configure(conf):
return
# check for dedicated server build
if conf.env.DEST_OS != 'win32' and not conf.env.DEDICATED:
if not conf.env.DEDICATED:
if conf.env.DEST_OS != 'win32': # We need SDL2 for showing messagebox in case launcher has failed
# TODO: add way to specify SDL2 path, move to separate function
try:
conf.check_cfg(
@ -28,15 +29,20 @@ def configure(conf):
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')
else:
conf.check(lib='USER32')
def get_subproject_name(ctx):
return os.path.basename(os.path.realpath(str(ctx.path)))
def build(bld):
if bld.env.SINGLE_BINARY:
return
bld.load_envs()
bld.env = bld.all_envs[get_subproject_name(bld)]
source = 'game.cpp'
source = ['game.cpp']
includes = '. ../common'
libs = []
@ -47,7 +53,8 @@ def build(bld):
else:
# compile resource on Windows
bld.load('winres')
source += 'game.rc'
libs += ['USER32']
source += ['game.rc']
bld(
source = source,

10
wscript
View File

@ -49,7 +49,9 @@ def options(opt):
opt.recurse(SUBDIRS)
def configure(conf):
conf.env.MSVC_TARGETS = ['x86']
conf.load('compiler_cxx compiler_c')
if(conf.env.COMPILER_CC != 'msvc'):
conf.check_cc(
fragment='''
#include <stdio.h>
@ -59,8 +61,11 @@ def configure(conf):
define_ret = True,
uselib_store = 'SIZEOF_VOID_P',
msg = 'Checking sizeof(void*)')
else:
conf.env.SIZEOF_VOID_P = '4' # TODO: detect target
if(conf.env.SIZEOF_VOID_P != '4' and not conf.options.ALLOW64):
if(int(conf.env.SIZEOF_VOID_P) != 4):
if(not conf.options.ALLOW64):
conf.env.append_value('LINKFLAGS', '-m32')
conf.env.append_value('CFLAGS', '-m32')
conf.env.append_value('CXXFLAGS', '-m32')
@ -68,9 +73,9 @@ def configure(conf):
else:
Logs.warn('WARNING: 64-bit engine may be unstable')
if(conf.env.COMPILER_CC != 'msvc'):
if(conf.env.COMPILER_CC == 'gcc'):
conf.env.append_value('LINKFLAGS', '-Wl,--no-undefined')
if(conf.options.RELEASE):
conf.env.append_unique('CFLAGS', '-O2')
conf.env.append_unique('CXXFLAGS', '-O2')
@ -80,6 +85,7 @@ def configure(conf):
conf.env.append_unique('CXXFLAGS', '-Og')
conf.env.append_unique('CXXFLAGS', '-g')
if(conf.env.DEST_OS != 'win32'):
conf.check( lib='dl' )
conf.check( lib='m' )
conf.check( lib='pthread' )