SConscript 3.97 KB
Newer Older
1 2 3 4
import common

Import('*')

5 6
from sys import executable as python_cmd

7 8
env = env.Clone()

9 10 11
env.Prepend(CPPPATH = [
    '#src/mapi',
    '#src/mesa',
José Fonseca's avatar
José Fonseca committed
12
    '#src/glsl',
13 14 15 16 17
])

if env['platform'] == 'windows':
    env.Prepend(CPPPATH = ['#src/talloc'])

18
sources = [
19 20 21 22 23 24 25 26 27 28 29
    'glcpp/glcpp-lex.c',
    'glcpp/glcpp-parse.c',
    'glcpp/pp.c',
    'ast_expr.cpp',
    'ast_function.cpp',
    'ast_to_hir.cpp',
    'ast_type.cpp',
    'glsl_lexer.cpp',
    'glsl_parser.cpp',
    'glsl_parser_extras.cpp',
    'glsl_types.cpp',
30
    'glsl_symbol_table.cpp',
31 32 33
    'hir_field_selection.cpp',
    'ir_basic_block.cpp',
    'ir_clone.cpp',
34
    'ir_constant_expression.cpp',
35 36 37 38 39 40 41 42 43
    'ir.cpp',
    'ir_expression_flattening.cpp',
    'ir_function_can_inline.cpp',
    'ir_function.cpp',
    'ir_hierarchical_visitor.cpp',
    'ir_hv_accept.cpp',
    'ir_import_prototypes.cpp',
    'ir_print_visitor.cpp',
    'ir_reader.cpp',
José Fonseca's avatar
José Fonseca committed
44
    'ir_rvalue_visitor.cpp',
45 46 47 48 49 50
    'ir_set_program_inouts.cpp',
    'ir_validate.cpp',
    'ir_variable.cpp',
    'ir_variable_refcount.cpp',
    'linker.cpp',
    'link_functions.cpp',
51 52 53
    'loop_analysis.cpp',
    'loop_controls.cpp',
    'loop_unroll.cpp',
54
    'lower_discard.cpp',
55
    'lower_if_to_cond_assign.cpp',
56
    'lower_instructions.cpp',
57 58
    'lower_jumps.cpp',
    'lower_mat_op_to_vec.cpp',
59
    'lower_noise.cpp',
60
    'lower_variable_index_to_cond_assign.cpp',
61 62
    'lower_vec_index_to_cond_assign.cpp',
    'lower_vec_index_to_swizzle.cpp',
63
    'lower_vector.cpp',
64 65 66 67 68 69 70 71
    'opt_algebraic.cpp',
    'opt_constant_folding.cpp',
    'opt_constant_propagation.cpp',
    'opt_constant_variable.cpp',
    'opt_copy_propagation.cpp',
    'opt_dead_code.cpp',
    'opt_dead_code_local.cpp',
    'opt_dead_functions.cpp',
72
    'opt_discard_simplification.cpp',
73 74
    'opt_function_inlining.cpp',
    'opt_if_simplification.cpp',
75 76
    'opt_noop_swizzle.cpp',
    'opt_redundant_jumps.cpp',
77 78 79
    'opt_structure_splitting.cpp',
    'opt_swizzle_swizzle.cpp',
    'opt_tree_grafting.cpp',
80
    's_expression.cpp',
81
    'strtod.c',
José Fonseca's avatar
José Fonseca committed
82
] 
83

84

José Fonseca's avatar
José Fonseca committed
85 86 87 88
if env['platform'] == common.host_platform:
    if env['msvc']:
        env.Prepend(CPPPATH = ['#/src/getopt'])
        env.PrependUnique(LIBS = [getopt])
89

José Fonseca's avatar
José Fonseca committed
90 91 92 93 94
    if env['platform'] == 'windows':
        env.Prepend(CPPPATH = ['#src/talloc'])
        env.Prepend(LIBS = [talloc])
    else:
        env.Prepend(LIBS = ['talloc'])
95

José Fonseca's avatar
José Fonseca committed
96 97 98 99 100 101
    builtin_compiler = env.Program(
        target = 'builtin_compiler',
        source = sources + ['main.cpp', 'builtin_stubs.cpp',
                            '#src/mesa/program/hash_table.c',
                            '#src/mesa/program/symbol_table.c'],
    )
102

José Fonseca's avatar
José Fonseca committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
    builtin_glsl_function = env.CodeGenerate(
        target = 'builtin_function.cpp',
        script = 'builtins/tools/generate_builtins.py',
        source = builtin_compiler,
        command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
    )

    env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))

    if env['msvc']:
        # There is no LD_LIBRARY_PATH equivalent on Windows. We need to ensure
        # talloc.dll is on the same dir as builtin_function.
        talloc_dll_src = talloc.dir.File('talloc.dll')
        talloc_dll_dst = builtin_compiler[0].dir.File('talloc.dll')
        talloc_dll = env.Command(talloc_dll_dst, talloc_dll_src, Copy(talloc_dll_dst, talloc_dll_src))
        env.Depends('builtin_function.cpp', talloc_dll)

    Export('builtin_glsl_function')
121

José Fonseca's avatar
José Fonseca committed
122 123
    if common.cross_compiling:
        Return()
124

José Fonseca's avatar
José Fonseca committed
125
sources += builtin_glsl_function
126

José Fonseca's avatar
José Fonseca committed
127
glsl = env.ConvenienceLibrary(
128
    target = 'glsl',
José Fonseca's avatar
José Fonseca committed
129
    source = sources,
130 131 132 133
)

Export('glsl')

134 135 136
# FIXME: We can't build the programs because there's a cyclic dependency between tis directory and src/mesa
Return()

137 138 139 140 141 142 143
env = env.Clone()

if env['platform'] == 'windows':
    env.PrependUnique(LIBS = [
        'user32',
    ])

144
env.Prepend(LIBS = [glsl, talloc])
145 146

env.Program(
147 148 149 150
    target = 'glsl2',
    source = [
        'main.cpp',
    ]
151 152 153
)

env.Program(
154 155
    target = 'glcpp',
    source = ['glcpp/glcpp.c'],
156
)