2018-05-28 17:17:25 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# a1batross, mittorn, 2018
|
|
|
|
|
|
|
|
from __future__ import print_function
|
2018-06-17 13:30:59 +02:00
|
|
|
from waflib import Logs, Options
|
2018-05-28 17:17:25 +02:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2018-06-17 13:30:59 +02:00
|
|
|
VERSION = '0.99'
|
|
|
|
APPNAME = 'xash3d-fwgs'
|
|
|
|
SUBDIRS = [ 'game_launch', 'mainui', 'vgui_support', 'engine' ]
|
|
|
|
top = '.'
|
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
def get_git_version():
|
|
|
|
# try grab the current version number from git
|
2018-06-17 13:30:59 +02:00
|
|
|
version = 'notset'
|
|
|
|
if os.path.exists('.git'):
|
2018-05-28 17:17:25 +02:00
|
|
|
try:
|
2018-06-17 13:30:59 +02:00
|
|
|
version = os.popen('git describe --dirty --always').read().strip()
|
2018-05-28 17:17:25 +02:00
|
|
|
except Exception as e:
|
2018-06-17 13:30:59 +02:00
|
|
|
pass
|
2018-05-28 17:17:25 +02:00
|
|
|
|
2018-06-17 13:30:59 +02:00
|
|
|
if(len(version) == 0):
|
|
|
|
version = 'notset'
|
2018-05-28 17:17:25 +02:00
|
|
|
|
2018-06-17 13:30:59 +02:00
|
|
|
return version
|
2018-05-28 17:17:25 +02:00
|
|
|
|
|
|
|
def options(opt):
|
|
|
|
opt.load('compiler_cxx compiler_c')
|
|
|
|
if sys.platform == 'win32':
|
2018-06-14 20:22:17 +02:00
|
|
|
opt.load('msvc msvs')
|
2018-05-28 17:17:25 +02:00
|
|
|
|
|
|
|
opt.add_option(
|
2018-06-17 13:30:59 +02:00
|
|
|
'--dedicated', action = 'store_true', dest = 'DEDICATED', default = False,
|
2018-05-28 17:17:25 +02:00
|
|
|
help = 'build Xash Dedicated Server(XashDS)')
|
|
|
|
|
|
|
|
opt.add_option(
|
2018-06-17 13:30:59 +02:00
|
|
|
'--64bits', action = 'store_true', dest = 'ALLOW64', default = False,
|
2018-05-28 17:17:25 +02:00
|
|
|
help = 'allow targetting 64-bit engine')
|
|
|
|
|
|
|
|
opt.add_option(
|
2018-06-17 13:30:59 +02:00
|
|
|
'--release', action = 'store_true', dest = 'RELEASE', default = False,
|
2018-05-28 17:17:25 +02:00
|
|
|
help = 'strip debug info from binary and enable optimizations')
|
2018-06-17 13:30:59 +02:00
|
|
|
|
|
|
|
opt.add_option(
|
|
|
|
'--no-download-deps', action = 'store_false', dest = 'AUTODL', default = True,
|
|
|
|
help = 'don\'t try to download dependencies from network')
|
2018-05-29 00:02:32 +02:00
|
|
|
|
|
|
|
opt.add_option(
|
|
|
|
'--win-style-install', action = 'store_true', dest = 'WIN_INSTALL', default = False,
|
|
|
|
help = 'install like Windows build, ignore prefix, useful for development')
|
2018-05-28 17:17:25 +02:00
|
|
|
|
2018-10-04 11:05:33 +02:00
|
|
|
opt.add_option(
|
|
|
|
'--no-gcc-colors', action = 'store_false', dest = 'GCC_COLORS', default = True,
|
|
|
|
help = 'do not enable gcc colors')
|
|
|
|
|
2018-10-22 00:01:22 +02:00
|
|
|
opt.add_option(
|
|
|
|
'--sdl2', action='store', type='string', dest = 'SDL2_PATH', default = None,
|
|
|
|
help = 'SDL2 path to build(required for Windows)')
|
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
opt.recurse(SUBDIRS)
|
2018-06-17 13:30:59 +02:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
def configure(conf):
|
2018-06-17 13:30:59 +02:00
|
|
|
conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC
|
2018-05-28 17:17:25 +02:00
|
|
|
conf.load('compiler_cxx compiler_c')
|
2018-06-17 13:30:59 +02:00
|
|
|
if sys.platform == 'win32':
|
|
|
|
conf.load('msvc msvs')
|
|
|
|
|
|
|
|
# Check if we have 64-bit toolchain
|
|
|
|
conf.env.DEST_64BIT = False # predict state
|
|
|
|
try:
|
2018-06-14 19:34:51 +02:00
|
|
|
conf.check_cc(
|
2018-10-24 19:12:32 +02:00
|
|
|
fragment='''int main( void )
|
|
|
|
{
|
|
|
|
int check[sizeof(void*) == 4 ? 1: -1];
|
|
|
|
return 0;
|
|
|
|
}''',
|
2018-06-17 13:30:59 +02:00
|
|
|
msg = 'Checking if compiler create 32 bit code')
|
|
|
|
except conf.errors.ConfigurationError:
|
|
|
|
# Program not compiled, we have 64 bit
|
|
|
|
conf.env.DEST_64BIT = True
|
2018-10-24 19:12:32 +02:00
|
|
|
|
2018-06-17 13:30:59 +02:00
|
|
|
if(conf.env.DEST_64BIT):
|
2018-06-14 19:34:51 +02:00
|
|
|
if(not conf.options.ALLOW64):
|
2018-06-17 13:30:59 +02:00
|
|
|
conf.env.append_value('LINKFLAGS', ['-m32'])
|
|
|
|
conf.env.append_value('CFLAGS', ['-m32'])
|
|
|
|
conf.env.append_value('CXXFLAGS', ['-m32'])
|
2018-06-14 19:34:51 +02:00
|
|
|
Logs.info('NOTE: will build engine with 64-bit toolchain using -m32')
|
|
|
|
else:
|
|
|
|
Logs.warn('WARNING: 64-bit engine may be unstable')
|
2018-10-24 19:12:32 +02:00
|
|
|
|
2018-06-14 19:34:51 +02:00
|
|
|
if(conf.env.COMPILER_CC != 'msvc'):
|
|
|
|
if(conf.env.COMPILER_CC == 'gcc'):
|
2018-06-17 13:30:59 +02:00
|
|
|
conf.env.append_unique('LINKFLAGS', ['-Wl,--no-undefined'])
|
2018-06-14 19:34:51 +02:00
|
|
|
if(conf.options.RELEASE):
|
2018-06-17 13:30:59 +02:00
|
|
|
conf.env.append_unique('CFLAGS', ['-O2'])
|
|
|
|
conf.env.append_unique('CXXFLAGS', ['-O2'])
|
2018-06-14 19:34:51 +02:00
|
|
|
else:
|
2018-10-04 11:05:33 +02:00
|
|
|
conf.env.append_unique('CFLAGS', ['-Og', '-g'])
|
2018-06-17 13:30:59 +02:00
|
|
|
conf.env.append_unique('CXXFLAGS', ['-Og', '-g'])
|
2018-10-04 11:05:33 +02:00
|
|
|
if conf.options.GCC_COLORS:
|
|
|
|
conf.env.append_unique('CFLAGS', ['-fdiagnostics-color=always'])
|
|
|
|
conf.env.append_unique('CXXFLAGS', ['-fdiagnostics-color=always'])
|
2018-06-14 20:22:17 +02:00
|
|
|
else:
|
2018-06-17 13:30:59 +02:00
|
|
|
if(conf.options.RELEASE):
|
|
|
|
conf.env.append_unique('CFLAGS', ['/O2'])
|
|
|
|
conf.env.append_unique('CXXFLAGS', ['/O2'])
|
|
|
|
else:
|
|
|
|
conf.env.append_unique('CFLAGS', ['/Z7'])
|
|
|
|
conf.env.append_unique('CXXFLAGS', ['/Z7'])
|
|
|
|
conf.env.append_unique('LINKFLAGS', ['/DEBUG'])
|
2018-10-24 19:12:32 +02:00
|
|
|
conf.env.append_unique('DEFINES', '_USING_V110_SDK71_') # Force XP compability
|
|
|
|
|
|
|
|
# Force XP compability, all build targets should add
|
|
|
|
# subsystem=bld.env.MSVC_SUBSYSTEM
|
|
|
|
# TODO: wrapper around bld.stlib, bld.shlib and so on?
|
|
|
|
conf.env.MSVC_SUBSYSTEM = 'WINDOWS,5.01'
|
2018-06-14 19:34:51 +02:00
|
|
|
|
|
|
|
if(conf.env.DEST_OS != 'win32'):
|
|
|
|
conf.check( lib='dl' )
|
|
|
|
conf.check( lib='m' )
|
|
|
|
conf.check( lib='pthread' )
|
2018-10-24 19:12:32 +02:00
|
|
|
|
2018-05-28 17:17:25 +02:00
|
|
|
conf.env.DEDICATED = conf.options.DEDICATED
|
2018-06-17 13:30:59 +02:00
|
|
|
conf.env.SINGLE_BINARY = conf.options.DEDICATED # We don't need game launcher on dedicated
|
2018-10-24 19:12:32 +02:00
|
|
|
|
2018-05-29 00:02:32 +02:00
|
|
|
# indicate if we are packaging for Linux/BSD
|
|
|
|
if(not conf.options.WIN_INSTALL and
|
|
|
|
conf.env.DEST_OS != 'win32' and
|
|
|
|
conf.env.DEST_OS != 'darwin'):
|
|
|
|
conf.env.LIBDIR = conf.env.BINDIR = '${PREFIX}/lib/xash3d'
|
|
|
|
else:
|
2018-10-08 21:38:59 +02:00
|
|
|
conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX
|
|
|
|
|
2018-06-17 13:30:59 +02:00
|
|
|
conf.start_msg('Checking git hash')
|
|
|
|
git_version = get_git_version()
|
|
|
|
conf.end_msg(git_version)
|
|
|
|
conf.env.append_unique('DEFINES', 'XASH_BUILD_COMMIT="' + git_version + '"')
|
2018-05-28 17:17:25 +02:00
|
|
|
|
|
|
|
for i in SUBDIRS:
|
|
|
|
conf.setenv(i, conf.env) # derive new env from global one
|
|
|
|
conf.env.ENVNAME = i
|
2018-06-17 13:30:59 +02:00
|
|
|
conf.msg(msg='Configuring ' + i, result='in progress', color='BLUE')
|
2018-05-28 17:17:25 +02:00
|
|
|
# configure in standalone env
|
|
|
|
conf.recurse(i)
|
2018-06-17 13:30:59 +02:00
|
|
|
conf.msg(msg='Configuring ' + i, result='done', color='BLUE')
|
2018-05-28 17:17:25 +02:00
|
|
|
conf.setenv('')
|
|
|
|
|
|
|
|
def build(bld):
|
|
|
|
for i in SUBDIRS:
|
|
|
|
bld.recurse(SUBDIRS)
|