All pastes #2051931 Raw Edit

Untitled

public text v1 · immutable
#2051931 ·published 2011-04-29 15:41 UTC
rendered paste body
import os
import sys

import waflib
from waflib import Configure, Build, Logs, Utils, Task

Configure.autoconfig = True

class SelfTests(Build.BuildContext):
    cmd = 'selftests'
    fun = 'selftests'

def get_executable_extension():
    return '.exe' if sys.platform == 'win32' else ''

APPNAME = 'Dewi'
VERSION = '0.1'

top = '.'

out = 'build'

def options(opts):
    # MSVC not supported yet
    opts.load('gcc c_tests c_config')

def configure(conf):
    conf.check_waf_version(mini = '1.6.4')
    conf.load('gcc c_tests c_config')
    conf.load('arch cstd', 'support')
    conf.check_inline()
    conf.check_large_file()
    conf.check_library()
    headers = ( 'stdio.h', 'stdlib.h', 'assert.h', 'stdint.h', 'errno.h',
        'locale.h', 'string.h', 'limits.h' )
    for header in headers:
    	conf.check_cc(header_name = header)
    conf.check_endianness()
    conf.check_c_standard_compliance('C99')
    conf.check_path_separator()
    conf.check_os()
    conf.write_config_header('config.h')

def build(bld):
    bld.recurse('src tests', name = 'build')

def selftests(bld):
    bld.env.asserts = False
    build(bld)

    class SelftestsLauncher(Task.Task):
        def __init__(self, *args, **kw):
            if not 'test_dir' in kw:
            	raise Configure.ConfigurationException('Missing test_dir')
            self._test_dir = kw['test_dir']
            del kw['test_dir']
            Task.Task.__init__(self, *args, **kw)

        def run(self):
            return self.exec_command('%s %s' % (
                self.inputs[0].abspath(), self._test_dir))

    launcher = Task.always_run(SelftestsLauncher)(env = bld.env,
        test_dir = bld.path.find_dir('testdata').abspath())
    launcher.set_inputs(bld.path.find_resource(
        os.path.join('tests', 'dewitests' + get_executable_extension())))
    bld.add_to_group(launcher)

# vim:sts=4 sw=4 ts=4 si ci et syn=python fdm=marker ff=unix number