mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-15 05:29:51 +01:00
MSVC & Win32 wscript fixes
This commit is contained in:
parent
473810fc0c
commit
572705bc08
@ -14,7 +14,8 @@ def options(opt):
|
|||||||
def configure(conf):
|
def configure(conf):
|
||||||
# check for dedicated server build
|
# check for dedicated server build
|
||||||
if conf.options.DEDICATED:
|
if conf.options.DEDICATED:
|
||||||
conf.check( lib='rt' )
|
if(conf.env.DEST_OS == 'linux'):
|
||||||
|
conf.check( lib='rt' )
|
||||||
conf.env.append_unique('DEFINES', 'SINGLE_BINARY')
|
conf.env.append_unique('DEFINES', 'SINGLE_BINARY')
|
||||||
conf.env.append_unique('DEFINES', 'XASH_DEDICATED')
|
conf.env.append_unique('DEFINES', 'XASH_DEDICATED')
|
||||||
else:
|
else:
|
||||||
@ -30,6 +31,12 @@ def configure(conf):
|
|||||||
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
|
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
|
||||||
conf.env.append_unique('DEFINES', 'XASH_SDL')
|
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):
|
def get_subproject_name(ctx):
|
||||||
return os.path.basename(os.path.realpath(str(ctx.path)))
|
return os.path.basename(os.path.realpath(str(ctx.path)))
|
||||||
|
|
||||||
@ -37,11 +44,17 @@ def build(bld):
|
|||||||
bld.load_envs()
|
bld.load_envs()
|
||||||
bld.env = bld.all_envs[get_subproject_name(bld)]
|
bld.env = bld.all_envs[get_subproject_name(bld)]
|
||||||
|
|
||||||
|
libs = []
|
||||||
|
source = []
|
||||||
|
|
||||||
# basic build: dedicated only, no dependencies
|
# basic build: dedicated only, no dependencies
|
||||||
if bld.env.DEST_OS != 'win32':
|
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/*.c',
|
||||||
'common/imagelib/*.c',
|
'common/imagelib/*.c',
|
||||||
'common/soundlib/*.c',
|
'common/soundlib/*.c',
|
||||||
|
@ -16,27 +16,33 @@ def configure(conf):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# check for dedicated server build
|
# check for dedicated server build
|
||||||
if conf.env.DEST_OS != 'win32' and not conf.env.DEDICATED:
|
if not conf.env.DEDICATED:
|
||||||
# TODO: add way to specify SDL2 path, move to separate function
|
if conf.env.DEST_OS != 'win32': # We need SDL2 for showing messagebox in case launcher has failed
|
||||||
try:
|
# TODO: add way to specify SDL2 path, move to separate function
|
||||||
conf.check_cfg(
|
try:
|
||||||
path='sdl2-config',
|
conf.check_cfg(
|
||||||
args='--cflags --libs',
|
path='sdl2-config',
|
||||||
package='',
|
args='--cflags --libs',
|
||||||
msg='Checking for SDL2',
|
package='',
|
||||||
uselib_store='SDL2')
|
msg='Checking for SDL2',
|
||||||
except conf.errors.ConfigurationError:
|
uselib_store='SDL2')
|
||||||
conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated')
|
except conf.errors.ConfigurationError:
|
||||||
conf.env.append_unique('DEFINES', 'XASH_SDL')
|
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):
|
def get_subproject_name(ctx):
|
||||||
return os.path.basename(os.path.realpath(str(ctx.path)))
|
return os.path.basename(os.path.realpath(str(ctx.path)))
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
|
if bld.env.SINGLE_BINARY:
|
||||||
|
return
|
||||||
|
|
||||||
bld.load_envs()
|
bld.load_envs()
|
||||||
bld.env = bld.all_envs[get_subproject_name(bld)]
|
bld.env = bld.all_envs[get_subproject_name(bld)]
|
||||||
|
|
||||||
source = 'game.cpp'
|
source = ['game.cpp']
|
||||||
includes = '. ../common'
|
includes = '. ../common'
|
||||||
libs = []
|
libs = []
|
||||||
|
|
||||||
@ -47,7 +53,8 @@ def build(bld):
|
|||||||
else:
|
else:
|
||||||
# compile resource on Windows
|
# compile resource on Windows
|
||||||
bld.load('winres')
|
bld.load('winres')
|
||||||
source += 'game.rc'
|
libs += ['USER32']
|
||||||
|
source += ['game.rc']
|
||||||
|
|
||||||
bld(
|
bld(
|
||||||
source = source,
|
source = source,
|
||||||
|
64
wscript
64
wscript
@ -49,40 +49,46 @@ def options(opt):
|
|||||||
opt.recurse(SUBDIRS)
|
opt.recurse(SUBDIRS)
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
|
conf.env.MSVC_TARGETS = ['x86']
|
||||||
conf.load('compiler_cxx compiler_c')
|
conf.load('compiler_cxx compiler_c')
|
||||||
conf.check_cc(
|
if(conf.env.COMPILER_CC != 'msvc'):
|
||||||
fragment='''
|
conf.check_cc(
|
||||||
#include <stdio.h>
|
fragment='''
|
||||||
int main( void ) { printf("%ld", sizeof( void * )); return 0; }
|
#include <stdio.h>
|
||||||
''',
|
int main( void ) { printf("%ld", sizeof( void * )); return 0; }
|
||||||
execute = True,
|
''',
|
||||||
define_ret = True,
|
execute = True,
|
||||||
uselib_store = 'SIZEOF_VOID_P',
|
define_ret = True,
|
||||||
msg = 'Checking sizeof(void*)')
|
uselib_store = 'SIZEOF_VOID_P',
|
||||||
|
msg = 'Checking sizeof(void*)')
|
||||||
if(conf.env.SIZEOF_VOID_P != '4' and not conf.options.ALLOW64):
|
|
||||||
conf.env.append_value('LINKFLAGS', '-m32')
|
|
||||||
conf.env.append_value('CFLAGS', '-m32')
|
|
||||||
conf.env.append_value('CXXFLAGS', '-m32')
|
|
||||||
Logs.info('NOTE: will build engine with 64-bit toolchain using -m32')
|
|
||||||
else:
|
else:
|
||||||
Logs.warn('WARNING: 64-bit engine may be unstable')
|
conf.env.SIZEOF_VOID_P = '4' # TODO: detect target
|
||||||
|
|
||||||
if(conf.env.COMPILER_CC == 'gcc'):
|
if(int(conf.env.SIZEOF_VOID_P) != 4):
|
||||||
conf.env.append_value('LINKFLAGS', '-Wl,--no-undefined')
|
if(not conf.options.ALLOW64):
|
||||||
|
conf.env.append_value('LINKFLAGS', '-m32')
|
||||||
|
conf.env.append_value('CFLAGS', '-m32')
|
||||||
|
conf.env.append_value('CXXFLAGS', '-m32')
|
||||||
|
Logs.info('NOTE: will build engine with 64-bit toolchain using -m32')
|
||||||
|
else:
|
||||||
|
Logs.warn('WARNING: 64-bit engine may be unstable')
|
||||||
|
|
||||||
if(conf.options.RELEASE):
|
if(conf.env.COMPILER_CC != 'msvc'):
|
||||||
conf.env.append_unique('CFLAGS', '-O2')
|
if(conf.env.COMPILER_CC == 'gcc'):
|
||||||
conf.env.append_unique('CXXFLAGS', '-O2')
|
conf.env.append_value('LINKFLAGS', '-Wl,--no-undefined')
|
||||||
else:
|
if(conf.options.RELEASE):
|
||||||
conf.env.append_unique('CFLAGS', '-Og')
|
conf.env.append_unique('CFLAGS', '-O2')
|
||||||
conf.env.append_unique('CFLAGS', '-g')
|
conf.env.append_unique('CXXFLAGS', '-O2')
|
||||||
conf.env.append_unique('CXXFLAGS', '-Og')
|
else:
|
||||||
conf.env.append_unique('CXXFLAGS', '-g')
|
conf.env.append_unique('CFLAGS', '-Og')
|
||||||
|
conf.env.append_unique('CFLAGS', '-g')
|
||||||
|
conf.env.append_unique('CXXFLAGS', '-Og')
|
||||||
|
conf.env.append_unique('CXXFLAGS', '-g')
|
||||||
|
|
||||||
conf.check( lib='dl' )
|
if(conf.env.DEST_OS != 'win32'):
|
||||||
conf.check( lib='m' )
|
conf.check( lib='dl' )
|
||||||
conf.check( lib='pthread' )
|
conf.check( lib='m' )
|
||||||
|
conf.check( lib='pthread' )
|
||||||
|
|
||||||
conf.env.DEDICATED = conf.options.DEDICATED
|
conf.env.DEDICATED = conf.options.DEDICATED
|
||||||
conf.env.SINGLE_BINARY = conf.options.DEDICATED
|
conf.env.SINGLE_BINARY = conf.options.DEDICATED
|
||||||
|
Loading…
Reference in New Issue
Block a user