5 from sys import executable as python_cmd
9 env.Prepend(CPPPATH = [
17 # Make glcpp/glcpp-parse.h and glsl_parser.h reacheable from the include path
18 env.Append(CPPPATH = [Dir('.').abspath])
20 env.Append(YACCFLAGS = '-d')
22 parser_env = env.Clone()
23 parser_env.Append(YACCFLAGS = [
24 '--defines=%s' % File('glsl_parser.h').abspath,
28 glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l')
29 glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y')
30 glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll')
31 glsl_parser = parser_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy')
43 'glsl_parser_extras.cpp',
45 'glsl_symbol_table.cpp',
46 'hir_field_selection.cpp',
49 'ir_constant_expression.cpp',
51 'ir_expression_flattening.cpp',
52 'ir_function_can_inline.cpp',
53 'ir_function_detect_recursion.cpp',
55 'ir_hierarchical_visitor.cpp',
57 'ir_import_prototypes.cpp',
58 'ir_print_visitor.cpp',
60 'ir_rvalue_visitor.cpp',
61 'ir_set_program_inouts.cpp',
64 'ir_variable_refcount.cpp',
71 'lower_if_to_cond_assign.cpp',
72 'lower_instructions.cpp',
74 'lower_mat_op_to_vec.cpp',
76 'lower_variable_index_to_cond_assign.cpp',
77 'lower_vec_index_to_cond_assign.cpp',
78 'lower_vec_index_to_swizzle.cpp',
81 'opt_constant_folding.cpp',
82 'opt_constant_propagation.cpp',
83 'opt_constant_variable.cpp',
84 'opt_copy_propagation.cpp',
85 'opt_copy_propagation_elements.cpp',
87 'opt_dead_code_local.cpp',
88 'opt_dead_functions.cpp',
89 'opt_discard_simplification.cpp',
90 'opt_function_inlining.cpp',
91 'opt_if_simplification.cpp',
92 'opt_noop_swizzle.cpp',
93 'opt_redundant_jumps.cpp',
94 'opt_structure_splitting.cpp',
95 'opt_swizzle_swizzle.cpp',
96 'opt_tree_grafting.cpp',
103 env.Prepend(CPPPATH = ['#/src/getopt'])
104 env.PrependUnique(LIBS = [getopt])
106 if env['crosscompile'] and not env['embedded']:
107 Import('builtin_glsl_function')
109 # Copy these files to avoid generation object files into src/mesa/program
110 env.Prepend(CPPPATH = ['#src/mesa/program'])
111 env.Command('hash_table.c', '#src/mesa/program/hash_table.c', Copy('$TARGET', '$SOURCE'))
112 env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
114 main_obj = env.StaticObject('main.cpp')
116 mesa_objs = env.StaticObject([
121 builtin_compiler = env.Program(
122 target = 'builtin_compiler',
123 source = main_obj + glsl_sources + ['builtin_stubs.cpp'] + mesa_objs,
126 # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll
127 # depends on glsl_parser.h
128 env.Depends(builtin_compiler, glsl_parser)
130 builtin_glsl_function = env.CodeGenerate(
131 target = 'builtin_function.cpp',
132 script = 'builtins/tools/generate_builtins.py',
133 source = builtin_compiler,
134 command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
137 env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))
139 Export('builtin_glsl_function')
145 glsl_sources += builtin_glsl_function
147 glsl = env.ConvenienceLibrary(
149 source = glsl_sources,
152 # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on
154 env.Depends(glsl, glsl_parser)
158 # Skip building these programs as they will cause SCons error "Two environments
159 # with different actions were specified for the same target"
160 if env['crosscompile'] or env['embedded']:
165 if env['platform'] == 'windows':
166 env.PrependUnique(LIBS = [
170 env.Prepend(LIBS = [glsl])
174 source = main_obj + mesa_objs,
176 env.Alias('glsl2', glsl2)
179 target = 'glcpp/glcpp',
180 source = ['glcpp/glcpp.c'] + mesa_objs,
182 env.Alias('glcpp', glcpp)