1# Copyright © 2017 Intel Corporation
2
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9
10# The above copyright notice and this permission notice shall be included in
11# all copies or substantial portions of the Software.
12
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
20
21subdir('glcpp')
22
23bison_command = []
24if yacc_is_bison
25  bison_command = [
26    prog_bison, '-o', '@OUTPUT0@', '-p', '_mesa_glsl_', '--defines=@OUTPUT1@',
27    '@INPUT@',
28  ]
29else
30  bison_command = [
31    prog_bison, '-o', '@OUTPUT0@', '-p', '_mesa_glsl_', '-H', '@OUTPUT1@',
32    '@INPUT@',
33  ]
34endif
35
36glsl_parser = custom_target(
37  'glsl_parser',
38  input : 'glsl_parser.yy',
39  output : ['glsl_parser.cpp', 'glsl_parser.h'],
40  command : bison_command
41)
42
43glsl_lexer_cpp = custom_target(
44  'glsl_lexer_cpp',
45  input : 'glsl_lexer.ll',
46  output : 'glsl_lexer.cpp',
47  command : [prog_flex_cpp, '-o', '@OUTPUT@', '@INPUT@'],
48)
49
50ir_expression_operation_constant_h = custom_target(
51  'ir_expression_operation_constant.h',
52  input : 'ir_expression_operation.py',
53  output : 'ir_expression_operation_constant.h',
54  command : [prog_python, '@INPUT@', 'constant'],
55  capture : true,
56)
57
58ir_expression_operation_strings_h = custom_target(
59  'ir_expression_operation_strings.h',
60  input : 'ir_expression_operation.py',
61  output : 'ir_expression_operation_strings.h',
62  command : [prog_python, '@INPUT@', 'strings'],
63  capture : true,
64)
65
66float64_glsl_h = custom_target(
67  'float64_glsl.h',
68  input : [files_xxd, 'float64.glsl'],
69  output : 'float64_glsl.h',
70  command : [prog_python, '@INPUT@', '@OUTPUT@', '-n', 'float64_source'],
71)
72
73files_libglsl = files(
74  'ast.h',
75  'ast_array_index.cpp',
76  'ast_expr.cpp',
77  'ast_function.cpp',
78  'ast_to_hir.cpp',
79  'ast_type.cpp',
80  'builtin_functions.cpp',
81  'builtin_functions.h',
82  'builtin_int64.h',
83  'builtin_types.cpp',
84  'builtin_variables.cpp',
85  'generate_ir.cpp',
86  'gl_nir_lower_atomics.c',
87  'gl_nir_lower_images.c',
88  'gl_nir_lower_buffers.c',
89  'gl_nir_lower_samplers.c',
90  'gl_nir_lower_samplers_as_deref.c',
91  'gl_nir_link_atomics.c',
92  'gl_nir_link_uniform_blocks.c',
93  'gl_nir_link_uniform_initializers.c',
94  'gl_nir_link_uniforms.c',
95  'gl_nir_link_xfb.c',
96  'gl_nir_linker.c',
97  'gl_nir_linker.h',
98  'gl_nir.h',
99  'glsl_parser_extras.cpp',
100  'glsl_parser_extras.h',
101  'glsl_symbol_table.cpp',
102  'glsl_symbol_table.h',
103  'glsl_to_nir.cpp',
104  'glsl_to_nir.h',
105  'hir_field_selection.cpp',
106  'ir_array_refcount.cpp',
107  'ir_array_refcount.h',
108  'ir_basic_block.cpp',
109  'ir_basic_block.h',
110  'ir_builder.cpp',
111  'ir_builder.h',
112  'ir_clone.cpp',
113  'ir_constant_expression.cpp',
114  'ir.cpp',
115  'ir.h',
116  'ir_equals.cpp',
117  'ir_expression_flattening.cpp',
118  'ir_expression_flattening.h',
119  'ir_function_can_inline.cpp',
120  'ir_function_detect_recursion.cpp',
121  'ir_function_inlining.h',
122  'ir_function.cpp',
123  'ir_hierarchical_visitor.cpp',
124  'ir_hierarchical_visitor.h',
125  'ir_hv_accept.cpp',
126  'ir_optimization.h',
127  'ir_print_visitor.cpp',
128  'ir_print_visitor.h',
129  'ir_reader.cpp',
130  'ir_reader.h',
131  'ir_rvalue_visitor.cpp',
132  'ir_rvalue_visitor.h',
133  'ir_set_program_inouts.cpp',
134  'ir_uniform.h',
135  'ir_validate.cpp',
136  'ir_variable_refcount.cpp',
137  'ir_variable_refcount.h',
138  'ir_visitor.h',
139  'linker.cpp',
140  'linker.h',
141  'linker_util.h',
142  'linker_util.cpp',
143  'link_atomics.cpp',
144  'link_functions.cpp',
145  'link_interface_blocks.cpp',
146  'link_uniforms.cpp',
147  'link_uniform_initializers.cpp',
148  'link_uniform_block_active_visitor.cpp',
149  'link_uniform_block_active_visitor.h',
150  'link_uniform_blocks.cpp',
151  'link_varyings.cpp',
152  'link_varyings.h',
153  'list.h',
154  'loop_analysis.cpp',
155  'loop_analysis.h',
156  'loop_unroll.cpp',
157  'lower_blend_equation_advanced.cpp',
158  'lower_buffer_access.cpp',
159  'lower_buffer_access.h',
160  'lower_builtins.cpp',
161  'lower_const_arrays_to_uniforms.cpp',
162  'lower_cs_derived.cpp',
163  'lower_discard.cpp',
164  'lower_discard_flow.cpp',
165  'lower_distance.cpp',
166  'lower_if_to_cond_assign.cpp',
167  'lower_instructions.cpp',
168  'lower_int64.cpp',
169  'lower_jumps.cpp',
170  'lower_mat_op_to_vec.cpp',
171  'lower_offset_array.cpp',
172  'lower_packed_varyings.cpp',
173  'lower_named_interface_blocks.cpp',
174  'lower_packing_builtins.cpp',
175  'lower_precision.cpp',
176  'lower_subroutine.cpp',
177  'lower_tess_level.cpp',
178  'lower_variable_index_to_cond_assign.cpp',
179  'lower_vec_index_to_cond_assign.cpp',
180  'lower_vec_index_to_swizzle.cpp',
181  'lower_vector.cpp',
182  'lower_vector_derefs.cpp',
183  'lower_vector_insert.cpp',
184  'lower_vertex_id.cpp',
185  'lower_output_reads.cpp',
186  'lower_shared_reference.cpp',
187  'lower_ubo_reference.cpp',
188  'lower_xfb_varying.cpp',
189  'opt_algebraic.cpp',
190  'opt_array_splitting.cpp',
191  'opt_conditional_discard.cpp',
192  'opt_constant_folding.cpp',
193  'opt_constant_propagation.cpp',
194  'opt_constant_variable.cpp',
195  'opt_copy_propagation_elements.cpp',
196  'opt_dead_builtin_variables.cpp',
197  'opt_dead_builtin_varyings.cpp',
198  'opt_dead_code.cpp',
199  'opt_dead_code_local.cpp',
200  'opt_dead_functions.cpp',
201  'opt_flatten_nested_if_blocks.cpp',
202  'opt_flip_matrices.cpp',
203  'opt_function_inlining.cpp',
204  'opt_if_simplification.cpp',
205  'opt_minmax.cpp',
206  'opt_rebalance_tree.cpp',
207  'opt_redundant_jumps.cpp',
208  'opt_structure_splitting.cpp',
209  'opt_swizzle.cpp',
210  'opt_tree_grafting.cpp',
211  'opt_vectorize.cpp',
212  'program.h',
213  'propagate_invariance.cpp',
214  's_expression.cpp',
215  's_expression.h',
216  'string_to_uint_map.cpp',
217  'string_to_uint_map.h',
218  'serialize.cpp',
219  'serialize.h',
220  'shader_cache.cpp',
221  'shader_cache.h',
222)
223
224files_libglsl_standalone = files(
225  'ir_builder_print_visitor.cpp',
226  'ir_builder_print_visitor.h',
227  'opt_add_neg_to_sub.h',
228  'standalone_scaffolding.cpp',
229  'standalone_scaffolding.h',
230  'standalone.cpp',
231  'standalone.h',
232)
233
234libglsl = static_library(
235  'glsl',
236  [files_libglsl, glsl_parser, glsl_lexer_cpp, ir_expression_operation_h,
237   ir_expression_operation_strings_h, ir_expression_operation_constant_h,
238   float64_glsl_h],
239  c_args : [c_msvc_compat_args, no_override_init_args],
240  cpp_args : [cpp_msvc_compat_args],
241  gnu_symbol_visibility : 'hidden',
242  link_with : libglcpp,
243  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_compiler],
244  dependencies : idep_nir,
245  build_by_default : false,
246)
247
248libglsl_standalone = static_library(
249  'glsl_standalone',
250  [files_libglsl_standalone, ir_expression_operation_h],
251  c_args : [c_msvc_compat_args, no_override_init_args],
252  cpp_args : [cpp_msvc_compat_args],
253  gnu_symbol_visibility : 'hidden',
254  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
255  link_with : [libglsl, libglsl_util, libglcpp_standalone],
256  dependencies : [idep_mesautil, idep_getopt],
257  build_by_default : false,
258)
259
260glsl_compiler = executable(
261  'glsl_compiler',
262  'main.cpp',
263  c_args : [c_msvc_compat_args, no_override_init_args],
264  cpp_args : [cpp_msvc_compat_args],
265  gnu_symbol_visibility : 'hidden',
266  dependencies : [dep_clock, dep_thread, idep_getopt, idep_mesautil],
267  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
268  link_with : [libglsl_standalone],
269  build_by_default : with_tools.contains('glsl'),
270  install : with_tools.contains('glsl'),
271)
272
273glsl_test = executable(
274  'glsl_test',
275  ['test.cpp', 'test_optpass.cpp', 'test_optpass.h',
276   ir_expression_operation_h],
277  c_args : [c_msvc_compat_args, no_override_init_args],
278  cpp_args : [cpp_msvc_compat_args],
279  gnu_symbol_visibility : 'hidden',
280  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
281  dependencies : [dep_clock, dep_thread, idep_getopt, idep_mesautil],
282  link_with : [libglsl, libglsl_standalone, libglsl_util],
283  build_by_default : with_tools.contains('glsl'),
284  install : with_tools.contains('glsl'),
285)
286
287if with_any_opengl and with_tests
288  subdir('tests')
289endif
290