Source

pyGAP / game / wscript

#!/usr/bin/env python
# encoding: utf-8

from waflib import Options, Utils
from tools import config

top = '.'
SVG = False

def options(opt):
    opt.load('compiler_cxx')
    config.options(opt)
    opt.add_option('-d', '--debug', action='store_true', default=False,
                   dest='debug', help='Debug mode.')
    opt.add_option('-I', '--includes', type='string', default='',
                   dest='includes', help='Specify additional include path.')


def configure(conf):
    conf.load('compiler_cxx')
    config.configure(conf)

    conf.env.INCLUDES.extend(conf.options.includes.split(';'))

    msvc = conf.env.COMPILER_CXX == 'msvc'
    win32 = Utils.unversioned_sys_platform() == 'win32'

    if conf.options.zip == 'zlib':
        conf.env.STLIB_ZIP = 'zlibstat' if msvc else 'z'
    elif conf.options.zip == 'lzma':
        conf.env.STLIB_ZIP = 'lzma'
    else:
        conf.fatal('compression unsupported')
    conf.define('COMPRESSION_%s' % conf.options.zip.upper(), 1)
    conf.define('COMPRESSION_LIB', conf.options.zip)

    if msvc:
        conf.define('MSVC', 1)
        conf.env.cxxflags = ['/EHsc']
        conf.env.linkflags = ['%s.lib' % lib for lib in conf.env.libs]
        conf.env.linkflags.append('/NODEFAULTLIB:LIBCMT');
        if conf.options.debug:
            conf.env.cxxflags.extend(('/Z7', '/O2', '/DDEBUG'))
            conf.env.linkflags.append('/Debug')
    else:
        conf.env.cxxflags = ['-m64' if conf.env.m64 else '-m32']
        conf.env.linkflags = conf.env.cxxflags
        if conf.options.debug:
            conf.env.cxxflags.extend(('-g', '-DDEBUG'))
        conf.env.linkflags.extend('-l%s' % lib for lib in conf.env.libs)

    if conf.options.debug:
        conf.env.cxxflags.append('-DDEBUG')

    if win32:
        conf.env.cxxflags.extend(('-mwindows' if not msvc else '',
                                  '/DWIN32',
                                  '-DWINVER=0x0601',
                                  '-D_WIN32_WINNT=0x0601'))

    if conf.options.warning:
        #conf.env.cxxflags.append('-Wdouble-promotion')
        conf.env.cxxflags.extend(('-Wall', '-Wextra', '-Weffc++', '-pedantic'))


def build(bld):
    Options.lockfile = '.lock-waf%s' % bld.env.target
    if config.PEP8:
        bld(source=bld.path.ant_glob('tools/**/*.py **/wscript'))

    bld.recurse('assets')
    #bld.program(source=bld.path.ant_glob('''src/**/*.cpp'''),
    bld.program(source=bld.path.ant_glob('''
                                         engine/**/*.cpp
                                         game/*_%(platform)s.cpp
                                         ''' % {'platform': bld.env.platform}),
                includes=['engine', 'game', '%s/assets/inc' % bld.env.target],
                cxxflags=bld.env.cxxflags,
                linkflags=bld.env.linkflags,
                target='game', use='ZIP')