078b400e9d9f14ab651a9b62019ec4f422b35eb6
[mesa.git] / src / glsl / SConscript
1 import common
2
3 Import('*')
4
5 from sys import executable as python_cmd
6
7 env = env.Clone()
8
9 env.Prepend(CPPPATH = [
10 '#src/mapi',
11 '#src/mesa',
12 '#src/glsl',
13 ])
14
15 if env['platform'] == 'windows':
16 env.Prepend(CPPPATH = ['#src/talloc'])
17
18 sources = [
19 'glcpp/glcpp-lex.c',
20 'glcpp/glcpp-parse.c',
21 'glcpp/pp.c',
22 'ast_expr.cpp',
23 'ast_function.cpp',
24 'ast_to_hir.cpp',
25 'ast_type.cpp',
26 'glsl_lexer.cpp',
27 'glsl_parser.cpp',
28 'glsl_parser_extras.cpp',
29 'glsl_types.cpp',
30 'glsl_symbol_table.cpp',
31 'hir_field_selection.cpp',
32 'ir_basic_block.cpp',
33 'ir_clone.cpp',
34 'ir_constant_expression.cpp',
35 'ir.cpp',
36 'ir_expression_flattening.cpp',
37 'ir_function_can_inline.cpp',
38 'ir_function.cpp',
39 'ir_hierarchical_visitor.cpp',
40 'ir_hv_accept.cpp',
41 'ir_import_prototypes.cpp',
42 'ir_print_visitor.cpp',
43 'ir_reader.cpp',
44 'ir_rvalue_visitor.cpp',
45 'ir_set_program_inouts.cpp',
46 'ir_validate.cpp',
47 'ir_variable.cpp',
48 'ir_variable_refcount.cpp',
49 'linker.cpp',
50 'link_functions.cpp',
51 'loop_analysis.cpp',
52 'loop_controls.cpp',
53 'loop_unroll.cpp',
54 'lower_discard.cpp',
55 'lower_if_to_cond_assign.cpp',
56 'lower_instructions.cpp',
57 'lower_jumps.cpp',
58 'lower_mat_op_to_vec.cpp',
59 'lower_noise.cpp',
60 'lower_variable_index_to_cond_assign.cpp',
61 'lower_vec_index_to_cond_assign.cpp',
62 'lower_vec_index_to_swizzle.cpp',
63 'lower_vector.cpp',
64 'opt_algebraic.cpp',
65 'opt_constant_folding.cpp',
66 'opt_constant_propagation.cpp',
67 'opt_constant_variable.cpp',
68 'opt_copy_propagation.cpp',
69 'opt_dead_code.cpp',
70 'opt_dead_code_local.cpp',
71 'opt_dead_functions.cpp',
72 'opt_discard_simplification.cpp',
73 'opt_function_inlining.cpp',
74 'opt_if_simplification.cpp',
75 'opt_noop_swizzle.cpp',
76 'opt_redundant_jumps.cpp',
77 'opt_structure_splitting.cpp',
78 'opt_swizzle_swizzle.cpp',
79 'opt_tree_grafting.cpp',
80 'ralloc.c',
81 's_expression.cpp',
82 'strtod.c',
83 ]
84
85
86 if env['platform'] == common.host_platform:
87 if env['msvc']:
88 env.Prepend(CPPPATH = ['#/src/getopt'])
89 env.PrependUnique(LIBS = [getopt])
90
91 if env['platform'] == 'windows':
92 env.Prepend(CPPPATH = ['#src/talloc'])
93 env.Prepend(LIBS = [talloc])
94 else:
95 env.Prepend(CPPPATH = ['#include'])
96 env.Prepend(LIBS = ['talloc'])
97
98 builtin_compiler = env.Program(
99 target = 'builtin_compiler',
100 source = sources + ['main.cpp', 'builtin_stubs.cpp',
101 '#src/mesa/program/hash_table.c',
102 '#src/mesa/program/symbol_table.c'],
103 )
104
105 builtin_glsl_function = env.CodeGenerate(
106 target = 'builtin_function.cpp',
107 script = 'builtins/tools/generate_builtins.py',
108 source = builtin_compiler,
109 command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
110 )
111
112 env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))
113
114 if env['msvc']:
115 # There is no LD_LIBRARY_PATH equivalent on Windows. We need to ensure
116 # talloc.dll is on the same dir as builtin_function.
117 talloc_dll_src = talloc.dir.File('talloc.dll')
118 talloc_dll_dst = builtin_compiler[0].dir.File('talloc.dll')
119 talloc_dll = env.Command(talloc_dll_dst, talloc_dll_src, Copy(talloc_dll_dst, talloc_dll_src))
120 env.Depends('builtin_function.cpp', talloc_dll)
121
122 Export('builtin_glsl_function')
123
124 if common.cross_compiling:
125 Return()
126
127 sources += builtin_glsl_function
128
129 glsl = env.ConvenienceLibrary(
130 target = 'glsl',
131 source = sources,
132 )
133
134 Export('glsl')
135
136 # FIXME: We can't build the programs because there's a cyclic dependency between tis directory and src/mesa
137 Return()
138
139 env = env.Clone()
140
141 if env['platform'] == 'windows':
142 env.PrependUnique(LIBS = [
143 'user32',
144 ])
145
146 env.Prepend(LIBS = [glsl, talloc])
147
148 env.Program(
149 target = 'glsl2',
150 source = [
151 'main.cpp',
152 ]
153 )
154
155 env.Program(
156 target = 'glcpp',
157 source = ['glcpp/glcpp.c'],
158 )