~jesse-barker/glcompbench/fade

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import os
import Options

out = 'build'
top = '.'

VERSION = '2011.07'
APPNAME = 'glcompbench'

def option_list_cb(option, opt, value, parser):
    value = value.split(',')
    setattr(parser.values, option.dest, value)

def options(opt):
    opt.tool_options('compiler_cc')
    opt.tool_options('compiler_cxx')

    opt.add_option('--no-debug', action='store_false', dest = 'debug', default = True, help='disable compiler debug information')
    opt.add_option('--no-opt', action='store_false', dest = 'opt', default = True, help='disable compiler optimizations')
    opt.add_option('--data-path', action='store', dest = 'data_path', help='the path to install the data to')

    opt.add_option('--with-flavors', type = 'string', action='callback',
                   callback=option_list_cb,
                   dest = 'flavors',
                   help = "a list of flavors to build (glx, egl-gl, egl-es2, all)")
    opt.parser.set_default('flavors', ['egl-es2'])

def configure(ctx):
    ctx.check_tool('compiler_cxx')

    Options.options.flavors = set(Options.options.flavors)

    # Special 'all' flavor
    if 'all' in Options.options.flavors:
        Options.options.flavors.remove('all')
        Options.options.flavors |= set(['glx', 'egl-gl', 'egl-es2'])

    # Ensure the flavors are valid
    for flavor in Options.options.flavors:
        if flavor not in ('glx', 'egl-es2', 'egl-gl'):
            ctx.fatal('Unknown flavor: %s. Supported flavors are glx, egl-gl and egl-es2' % flavor)

    ctx.env.BUILD_GLX = 'glx' in Options.options.flavors
    ctx.env.BUILD_EGL_ES2 = 'egl-es2' in Options.options.flavors
    ctx.env.BUILD_EGL_GL = 'egl-gl' in Options.options.flavors

    # Check required headers
    req_headers = ['inttypes.h', 'stdint.h', 'sys/time.h']
    for header in req_headers:
        ctx.check_cxx(header_name = header, mandatory = True)

    # Check for required libs
    req_libs = [('m', 'm')]
    for (lib, uselib) in req_libs:
        ctx.check_cxx(lib = lib, uselib_store = uselib)

    # Check required functions
    req_funcs = [('gettimeofday', 'sys/time.h', []) ,('sqrt', 'math.h', ['m']),
                 ('strtol', 'stdlib.h', []), ('strtoul', 'stdlib.h', [])]
    for func, header, uselib in req_funcs:
        ctx.check_cxx(function_name = func, header_name = header, uselib = uselib, mandatory = True)

    # Check required packages
    req_pkgs = [('x11', 'x11'), ('xdamage', 'xdamage'),
                ('xcomposite', 'xcomposite'), ('pixman-1', 'pixman'),
                ('xext', 'xext'), ('xrender', 'xrender')]
    for (pkg, uselib) in req_pkgs:
        ctx.check_cfg(package = pkg, uselib_store = uselib, args = '--cflags --libs',
                mandatory = True)

    # Check conditional packages
    req_pkgs = [('egl', 'egl', ctx.env.BUILD_EGL_ES2 or ctx.env.BUILD_EGL_GL),
                ('glesv2', 'glesv2', ctx.env.BUILD_EGL_ES2),
                ('gl', 'gl', ctx.env.BUILD_GLX or ctx.env.BUILD_EGL_GL)]
    for (pkg, uselib, check_for) in req_pkgs:
        if check_for:
            ctx.check_cfg(package = pkg, uselib_store = uselib, args = '--cflags --libs',
                          mandatory = True)

    ctx.env.append_unique('CXXFLAGS', '-Wall -Wextra'.split(' '))

    # Prepend -O# and -g flags so that they can be overriden by the CFLAGS environment variable
    if Options.options.opt:
        ctx.env.prepend_value('CXXFLAGS', '-O2')
    if Options.options.debug:
        ctx.env.prepend_value('CXXFLAGS', '-g')

    if Options.options.data_path is None:
        Options.options.data_path = os.path.join(ctx.env.PREFIX, 'share/glcompbench')

    ctx.env.append_unique('GLCOMPBENCH_DATA_PATH', Options.options.data_path)
    ctx.env.append_unique('DEFINES', 'GLCOMPBENCH_DATA_PATH="%s"' % Options.options.data_path)
    ctx.env.append_unique('DEFINES', 'GLCOMPBENCH_VERSION="%s"' % VERSION)
    ctx.env.GLCOMPBENCH_VERSION = VERSION

    ctx.msg("Prefix", ctx.env.PREFIX, color='PINK')
    ctx.msg("Data path", Options.options.data_path, color='PINK')
    ctx.msg("Building flavors", Options.options.flavors, color='PINK')

def build(ctx):
    ctx.recurse('src')
    ctx.recurse('data')
    ctx.recurse('doc')

def dist(ctx):
    ctx.algo = 'tar.gz'