blob: 067b4d451a6239601952e1009df1f51210cf746c [file] [log] [blame]
Ryan Harrisondbc13af2022-02-21 15:19:07 +00001# Copyright 2021 The Tint Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import("//build_overrides/build.gni")
16import("../../tint_overrides_with_defaults.gni")
17
dan sinclair77bf2332022-06-22 12:40:43 +000018if (tint_build_unittests) {
19 import("//testing/test.gni")
20}
21
Ryan Harrisondbc13af2022-02-21 15:19:07 +000022###############################################################################
23# Common - Configs, etc. shared across targets
24###############################################################################
25
26config("tint_common_config") {
27 include_dirs = [
28 "${target_gen_dir}",
29 "${tint_root_dir}/",
30 "${tint_spirv_headers_dir}/include",
31 "${tint_spirv_tools_dir}/",
32 "${tint_spirv_tools_dir}/include",
33 ]
34}
35
36config("tint_public_config") {
37 defines = []
38 if (tint_build_spv_reader) {
39 defines += [ "TINT_BUILD_SPV_READER=1" ]
40 } else {
41 defines += [ "TINT_BUILD_SPV_READER=0" ]
42 }
43
44 if (tint_build_spv_writer) {
45 defines += [ "TINT_BUILD_SPV_WRITER=1" ]
46 } else {
47 defines += [ "TINT_BUILD_SPV_WRITER=0" ]
48 }
49
50 if (tint_build_wgsl_reader) {
51 defines += [ "TINT_BUILD_WGSL_READER=1" ]
52 } else {
53 defines += [ "TINT_BUILD_WGSL_READER=0" ]
54 }
55
56 if (tint_build_wgsl_writer) {
57 defines += [ "TINT_BUILD_WGSL_WRITER=1" ]
58 } else {
59 defines += [ "TINT_BUILD_WGSL_WRITER=0" ]
60 }
61
62 if (tint_build_msl_writer) {
63 defines += [ "TINT_BUILD_MSL_WRITER=1" ]
64 } else {
65 defines += [ "TINT_BUILD_MSL_WRITER=0" ]
66 }
67
68 if (tint_build_hlsl_writer) {
69 defines += [ "TINT_BUILD_HLSL_WRITER=1" ]
70 } else {
71 defines += [ "TINT_BUILD_HLSL_WRITER=0" ]
72 }
73
74 if (tint_build_glsl_writer) {
75 defines += [ "TINT_BUILD_GLSL_WRITER=1" ]
76 } else {
77 defines += [ "TINT_BUILD_GLSL_WRITER=0" ]
78 }
79
80 include_dirs = [
81 "${tint_root_dir}/",
82 "${tint_root_dir}/include/",
83 "${tint_spirv_headers_dir}/include",
84 ]
85}
86
87config("tint_config") {
88 include_dirs = []
89 if (tint_build_spv_reader || tint_build_spv_writer) {
90 include_dirs += [ "${tint_spirv_tools_dir}/include/" ]
91 }
92}
93
94###############################################################################
95# Helper library for IO operations
96# Only to be used by tests and sample executable
97###############################################################################
98source_set("tint_utils_io") {
99 sources = [
100 "utils/io/command.h",
101 "utils/io/tmpfile.h",
102 ]
103
104 if (is_linux || is_mac) {
105 sources += [ "utils/io/command_posix.cc" ]
106 sources += [ "utils/io/tmpfile_posix.cc" ]
107 } else if (is_win) {
108 sources += [ "utils/io/command_windows.cc" ]
109 sources += [ "utils/io/tmpfile_windows.cc" ]
110 } else {
111 sources += [ "utils/io/command_other.cc" ]
112 sources += [ "utils/io/tmpfile_other.cc" ]
113 }
114
115 public_deps = [ ":libtint_core_all_src" ]
116}
117
118###############################################################################
119# Helper library for validating generated shaders
120# As this depends on tint_utils_io, this is only to be used by tests and sample
121# executable
122###############################################################################
123source_set("tint_val") {
124 sources = [
125 "val/hlsl.cc",
126 "val/msl.cc",
127 "val/val.h",
128 ]
129 public_deps = [ ":tint_utils_io" ]
130}
131
132###############################################################################
133# Library - Tint core and optional modules of libtint
134###############################################################################
135# libtint source sets are divided into a non-optional core in :libtint_core_src
136# and optional :libtint_*_src subsets, because ninja does not like having
137# multiple source files with the same name, like function.cc, in the same
138# source set
139# target.
140#
141# Targets that want to use tint as a library should depend on ":libtint" and
142# use the build flags to control what is included, instead of trying to specify
143# the subsets that they want.
144
145template("libtint_source_set") {
146 source_set(target_name) {
147 forward_variables_from(invoker, "*", [ "configs" ])
148
149 if (!defined(invoker.deps)) {
150 deps = []
151 }
152 deps += [
153 "${tint_spirv_headers_dir}:spv_headers",
154 "${tint_spirv_tools_dir}:spvtools_core_enums_unified1",
155 "${tint_spirv_tools_dir}:spvtools_core_tables_unified1",
156 "${tint_spirv_tools_dir}:spvtools_headers",
157 "${tint_spirv_tools_dir}:spvtools_language_header_cldebuginfo100",
158 "${tint_spirv_tools_dir}:spvtools_language_header_debuginfo",
159 "${tint_spirv_tools_dir}:spvtools_language_header_vkdebuginfo100",
160 ]
161
162 if (defined(invoker.configs)) {
163 configs += invoker.configs
164 }
165 configs += [ ":tint_common_config" ]
166 if (build_with_chromium) {
167 configs -= [ "//build/config/compiler:chromium_code" ]
168 configs += [ "//build/config/compiler:no_chromium_code" ]
169 }
170
171 if (!defined(invoker.public_configs)) {
172 public_configs = []
173 }
174 public_configs += [ ":tint_public_config" ]
175 }
176}
177
178libtint_source_set("libtint_core_all_src") {
179 sources = [
Dan Sinclair749abea2022-11-02 17:07:25 +0000180 "ast/access.cc",
181 "ast/access.h",
182 "ast/address_space.cc",
183 "ast/address_space.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000184 "ast/alias.cc",
185 "ast/alias.h",
186 "ast/array.cc",
187 "ast/array.h",
188 "ast/assignment_statement.cc",
189 "ast/assignment_statement.h",
190 "ast/ast_type.cc", # TODO(bclayton) - rename to type.cc
191 "ast/atomic.cc",
192 "ast/atomic.h",
193 "ast/attribute.cc",
194 "ast/attribute.h",
195 "ast/binary_expression.cc",
196 "ast/binary_expression.h",
197 "ast/binding_attribute.cc",
198 "ast/binding_attribute.h",
199 "ast/bitcast_expression.cc",
200 "ast/bitcast_expression.h",
201 "ast/block_statement.cc",
202 "ast/block_statement.h",
203 "ast/bool.cc",
204 "ast/bool.h",
205 "ast/bool_literal_expression.cc",
206 "ast/bool_literal_expression.h",
dan sinclairb8b0c212022-10-20 22:45:50 +0000207 "ast/break_if_statement.cc",
208 "ast/break_if_statement.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000209 "ast/break_statement.cc",
210 "ast/break_statement.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000211 "ast/builtin_attribute.cc",
212 "ast/builtin_attribute.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000213 "ast/builtin_value.cc",
214 "ast/builtin_value.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000215 "ast/call_expression.cc",
216 "ast/call_expression.h",
217 "ast/call_statement.cc",
218 "ast/call_statement.h",
dan sinclairf148f082022-10-19 15:55:02 +0000219 "ast/case_selector.cc",
220 "ast/case_selector.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000221 "ast/case_statement.cc",
222 "ast/case_statement.h",
James Price49241862022-03-31 22:30:10 +0000223 "ast/compound_assignment_statement.cc",
224 "ast/compound_assignment_statement.h",
Ben Clayton7ee32452022-06-20 20:46:22 +0000225 "ast/const.cc",
226 "ast/const.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000227 "ast/continue_statement.cc",
228 "ast/continue_statement.h",
229 "ast/depth_multisampled_texture.cc",
230 "ast/depth_multisampled_texture.h",
231 "ast/depth_texture.cc",
232 "ast/depth_texture.h",
233 "ast/disable_validation_attribute.cc",
234 "ast/disable_validation_attribute.h",
235 "ast/discard_statement.cc",
236 "ast/discard_statement.h",
Zhaoming Jiang7098d3d2022-04-27 02:27:52 +0000237 "ast/enable.cc",
238 "ast/enable.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000239 "ast/expression.cc",
240 "ast/expression.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000241 "ast/extension.cc",
242 "ast/extension.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000243 "ast/external_texture.cc",
244 "ast/external_texture.h",
Zhaoming Jiang62bfd312022-05-13 12:01:11 +0000245 "ast/f16.cc",
246 "ast/f16.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000247 "ast/f32.cc",
248 "ast/f32.h",
249 "ast/fallthrough_statement.cc",
250 "ast/fallthrough_statement.h",
251 "ast/float_literal_expression.cc",
252 "ast/float_literal_expression.h",
253 "ast/for_loop_statement.cc",
254 "ast/for_loop_statement.h",
255 "ast/function.cc",
256 "ast/function.h",
257 "ast/group_attribute.cc",
258 "ast/group_attribute.h",
259 "ast/i32.cc",
260 "ast/i32.h",
261 "ast/id_attribute.cc",
262 "ast/id_attribute.h",
263 "ast/identifier_expression.cc",
264 "ast/identifier_expression.h",
265 "ast/if_statement.cc",
266 "ast/if_statement.h",
James Priceebe97412022-04-07 13:42:45 +0000267 "ast/increment_decrement_statement.cc",
268 "ast/increment_decrement_statement.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000269 "ast/index_accessor_expression.cc",
270 "ast/index_accessor_expression.h",
271 "ast/int_literal_expression.cc",
272 "ast/int_literal_expression.h",
273 "ast/internal_attribute.cc",
274 "ast/internal_attribute.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000275 "ast/interpolate_attribute.cc",
276 "ast/interpolate_attribute.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000277 "ast/invariant_attribute.cc",
278 "ast/invariant_attribute.h",
Ben Claytondcdf66e2022-06-17 12:48:51 +0000279 "ast/let.cc",
280 "ast/let.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000281 "ast/literal_expression.cc",
282 "ast/literal_expression.h",
283 "ast/location_attribute.cc",
284 "ast/location_attribute.h",
285 "ast/loop_statement.cc",
286 "ast/loop_statement.h",
287 "ast/matrix.cc",
288 "ast/matrix.h",
289 "ast/member_accessor_expression.cc",
290 "ast/member_accessor_expression.h",
291 "ast/module.cc",
292 "ast/module.h",
293 "ast/multisampled_texture.cc",
294 "ast/multisampled_texture.h",
295 "ast/node.cc",
296 "ast/node.h",
dan sinclair256f1112022-07-22 16:05:06 +0000297 "ast/node_id.h",
Ben Claytondcdf66e2022-06-17 12:48:51 +0000298 "ast/override.cc",
299 "ast/override.h",
300 "ast/parameter.cc",
301 "ast/parameter.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000302 "ast/phony_expression.cc",
303 "ast/phony_expression.h",
304 "ast/pipeline_stage.cc",
305 "ast/pipeline_stage.h",
306 "ast/pointer.cc",
307 "ast/pointer.h",
308 "ast/return_statement.cc",
309 "ast/return_statement.h",
310 "ast/sampled_texture.cc",
311 "ast/sampled_texture.h",
312 "ast/sampler.cc",
313 "ast/sampler.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000314 "ast/stage_attribute.cc",
315 "ast/stage_attribute.h",
316 "ast/statement.cc",
317 "ast/statement.h",
Ben Claytonbfd1a812022-08-02 23:16:25 +0000318 "ast/static_assert.cc",
319 "ast/static_assert.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000320 "ast/storage_texture.cc",
321 "ast/storage_texture.h",
322 "ast/stride_attribute.cc",
323 "ast/stride_attribute.h",
324 "ast/struct.cc",
325 "ast/struct.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000326 "ast/struct_member.cc",
327 "ast/struct_member.h",
328 "ast/struct_member_align_attribute.cc",
329 "ast/struct_member_align_attribute.h",
330 "ast/struct_member_offset_attribute.cc",
331 "ast/struct_member_offset_attribute.h",
332 "ast/struct_member_size_attribute.cc",
333 "ast/struct_member_size_attribute.h",
334 "ast/switch_statement.cc",
335 "ast/switch_statement.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000336 "ast/texel_format.cc",
337 "ast/texel_format.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000338 "ast/texture.cc",
339 "ast/texture.h",
340 "ast/traverse_expressions.h",
341 "ast/type.h",
342 "ast/type_decl.cc",
343 "ast/type_decl.h",
344 "ast/type_name.cc",
345 "ast/type_name.h",
346 "ast/u32.cc",
347 "ast/u32.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000348 "ast/unary_op.cc",
349 "ast/unary_op.h",
350 "ast/unary_op_expression.cc",
351 "ast/unary_op_expression.h",
Ben Claytondcdf66e2022-06-17 12:48:51 +0000352 "ast/var.cc",
353 "ast/var.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000354 "ast/variable.cc",
355 "ast/variable.h",
356 "ast/variable_decl_statement.cc",
357 "ast/variable_decl_statement.h",
358 "ast/vector.cc",
359 "ast/vector.h",
360 "ast/void.cc",
361 "ast/void.h",
dan sinclair49d1a2d2022-06-16 12:01:27 +0000362 "ast/while_statement.cc",
363 "ast/while_statement.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000364 "ast/workgroup_attribute.cc",
365 "ast/workgroup_attribute.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000366 "castable.cc",
367 "castable.h",
368 "clone_context.cc",
369 "clone_context.h",
370 "debug.cc",
371 "debug.h",
372 "demangler.cc",
373 "demangler.h",
374 "diagnostic/diagnostic.cc",
375 "diagnostic/diagnostic.h",
376 "diagnostic/formatter.cc",
377 "diagnostic/formatter.h",
378 "diagnostic/printer.cc",
379 "diagnostic/printer.h",
380 "inspector/entry_point.cc",
381 "inspector/entry_point.h",
382 "inspector/inspector.cc",
383 "inspector/inspector.h",
384 "inspector/resource_binding.cc",
385 "inspector/resource_binding.h",
386 "inspector/scalar.cc",
387 "inspector/scalar.h",
Ben Claytonc2eccfc2022-05-25 15:04:24 +0000388 "number.cc",
Zhaoming Jiang62bfd312022-05-13 12:01:11 +0000389 "number.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000390 "program.cc",
391 "program.h",
392 "program_builder.cc",
393 "program_builder.h",
394 "program_id.cc",
395 "program_id.h",
396 "reader/reader.cc",
397 "reader/reader.h",
Stephen White863d9ed2022-09-02 19:19:10 +0000398 "reflection.h",
Ben Clayton451eee02022-06-01 23:57:20 +0000399 "resolver/const_eval.cc",
400 "resolver/const_eval.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000401 "resolver/dependency_graph.cc",
402 "resolver/dependency_graph.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000403 "resolver/init_conv_intrinsic.cc",
404 "resolver/init_conv_intrinsic.h",
Ben Claytone1325162022-05-06 15:13:01 +0000405 "resolver/intrinsic_table.cc",
406 "resolver/intrinsic_table.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000407 "resolver/intrinsic_table.inl",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000408 "resolver/resolver.cc",
409 "resolver/resolver.h",
dan sinclairbb62ef02022-04-19 15:00:44 +0000410 "resolver/sem_helper.cc",
411 "resolver/sem_helper.h",
James Pricebe656f72022-05-11 22:05:15 +0000412 "resolver/uniformity.cc",
413 "resolver/uniformity.h",
dan sinclairf05575b2022-04-21 13:40:16 +0000414 "resolver/validator.cc",
415 "resolver/validator.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000416 "scope_stack.h",
Ben Clayton23696b12022-05-18 21:56:28 +0000417 "sem/abstract_float.h",
418 "sem/abstract_int.h",
419 "sem/abstract_numeric.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000420 "sem/array.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000421 "sem/atomic.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000422 "sem/behavior.h",
423 "sem/binding_point.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000424 "sem/bool.h",
dan sinclairb8b0c212022-10-20 22:45:50 +0000425 "sem/break_if_statement.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000426 "sem/builtin.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000427 "sem/builtin_type.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000428 "sem/call.h",
429 "sem/call_target.h",
430 "sem/constant.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000431 "sem/depth_multisampled_texture.h",
432 "sem/depth_texture.h",
Ben Clayton83bd7382022-07-15 23:46:31 +0000433 "sem/evaluation_stage.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000434 "sem/expression.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000435 "sem/external_texture.h",
Zhaoming Jiang62bfd312022-05-13 12:01:11 +0000436 "sem/f16.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000437 "sem/f32.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000438 "sem/for_loop_statement.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000439 "sem/i32.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000440 "sem/if_statement.h",
Antonio Maioranodfeaf2902022-06-24 20:34:00 +0000441 "sem/index_accessor_expression.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000442 "sem/info.h",
443 "sem/loop_statement.h",
Ben Clayton932418e2022-05-24 21:42:03 +0000444 "sem/materialize.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000445 "sem/matrix.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000446 "sem/module.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000447 "sem/multisampled_texture.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000448 "sem/node.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000449 "sem/parameter_usage.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000450 "sem/pipeline_stage_set.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000451 "sem/pointer.h",
452 "sem/reference.h",
453 "sem/sampled_texture.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000454 "sem/sampler.h",
dan sinclair41e4d9a2022-05-01 14:40:55 +0000455 "sem/sampler_texture_pair.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000456 "sem/storage_texture.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000457 "sem/switch_statement.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000458 "sem/texture.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000459 "sem/type.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000460 "sem/type_conversion.h",
dan sinclair6e77b472022-10-20 13:38:28 +0000461 "sem/type_initializer.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000462 "sem/type_manager.h",
463 "sem/type_mappings.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000464 "sem/u32.h",
465 "sem/vector.h",
466 "sem/void.h",
dan sinclair49d1a2d2022-06-16 12:01:27 +0000467 "sem/while_statement.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000468 "source.cc",
469 "source.h",
470 "symbol.cc",
471 "symbol.h",
472 "symbol_table.cc",
473 "symbol_table.h",
474 "text/unicode.cc",
475 "text/unicode.h",
476 "traits.h",
Stephen White863d9ed2022-09-02 19:19:10 +0000477 "transform/add_block_attribute.cc",
478 "transform/add_block_attribute.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000479 "transform/add_empty_entry_point.cc",
480 "transform/add_empty_entry_point.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000481 "transform/array_length_from_uniform.cc",
482 "transform/array_length_from_uniform.h",
483 "transform/binding_remapper.cc",
484 "transform/binding_remapper.h",
Ben Clayton27aa57c2022-02-22 23:13:39 +0000485 "transform/builtin_polyfill.cc",
486 "transform/builtin_polyfill.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000487 "transform/calculate_array_length.cc",
488 "transform/calculate_array_length.h",
489 "transform/canonicalize_entry_point_io.cc",
490 "transform/canonicalize_entry_point_io.h",
Corentin Wallez98a7cd12022-10-11 09:52:25 +0000491 "transform/clamp_frag_depth.cc",
492 "transform/clamp_frag_depth.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000493 "transform/combine_samplers.cc",
494 "transform/combine_samplers.h",
495 "transform/decompose_memory_access.cc",
496 "transform/decompose_memory_access.h",
497 "transform/decompose_strided_array.cc",
498 "transform/decompose_strided_array.h",
499 "transform/decompose_strided_matrix.cc",
500 "transform/decompose_strided_matrix.h",
James Price791b4352022-05-11 13:50:33 +0000501 "transform/disable_uniformity_analysis.cc",
502 "transform/disable_uniformity_analysis.h",
Corentin Wallezb28d6c82022-04-07 11:36:06 +0000503 "transform/expand_compound_assignment.cc",
504 "transform/expand_compound_assignment.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000505 "transform/first_index_offset.cc",
506 "transform/first_index_offset.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000507 "transform/for_loop_to_loop.cc",
508 "transform/for_loop_to_loop.h",
509 "transform/localize_struct_array_assignment.cc",
510 "transform/localize_struct_array_assignment.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000511 "transform/manager.cc",
512 "transform/manager.h",
James Price5de8b432022-10-31 14:49:03 +0000513 "transform/merge_return.cc",
514 "transform/merge_return.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000515 "transform/module_scope_var_to_entry_point_param.cc",
516 "transform/module_scope_var_to_entry_point_param.h",
517 "transform/multiplanar_external_texture.cc",
518 "transform/multiplanar_external_texture.h",
519 "transform/num_workgroups_from_uniform.cc",
520 "transform/num_workgroups_from_uniform.h",
Ben Claytona92f4252022-10-27 14:36:49 +0000521 "transform/packed_vec3.cc",
522 "transform/packed_vec3.h",
Stephen White05d8b022022-09-13 19:48:51 +0000523 "transform/pad_structs.cc",
524 "transform/pad_structs.h",
Ben Clayton7ebcfc72022-06-27 20:20:25 +0000525 "transform/promote_initializers_to_let.cc",
526 "transform/promote_initializers_to_let.h",
Antonio Maioranoc25ddf42022-03-15 15:03:03 +0000527 "transform/promote_side_effects_to_decl.cc",
528 "transform/promote_side_effects_to_decl.h",
Antonio Maioranob3497102022-03-31 15:02:25 +0000529 "transform/remove_continue_in_switch.cc",
530 "transform/remove_continue_in_switch.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000531 "transform/remove_phonies.cc",
532 "transform/remove_phonies.h",
533 "transform/remove_unreachable_statements.cc",
534 "transform/remove_unreachable_statements.h",
535 "transform/renamer.cc",
536 "transform/renamer.h",
537 "transform/robustness.cc",
538 "transform/robustness.h",
539 "transform/simplify_pointers.cc",
540 "transform/simplify_pointers.h",
541 "transform/single_entry_point.cc",
542 "transform/single_entry_point.h",
Antonio Maiorano268d7b82022-06-24 22:28:23 +0000543 "transform/spirv_atomic.cc",
544 "transform/spirv_atomic.h",
Ben Clayton657e61d2022-09-01 22:12:19 +0000545 "transform/std140.cc",
546 "transform/std140.h",
dan sinclair256f1112022-07-22 16:05:06 +0000547 "transform/substitute_override.cc",
548 "transform/substitute_override.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000549 "transform/transform.cc",
550 "transform/transform.h",
551 "transform/unshadow.cc",
552 "transform/unshadow.h",
Antonio Maiorano66d66682022-03-28 20:51:32 +0000553 "transform/unwind_discard_functions.cc",
554 "transform/unwind_discard_functions.h",
Antonio Maioranoc2e9bb72022-03-30 20:11:35 +0000555 "transform/utils/get_insertion_point.cc",
556 "transform/utils/get_insertion_point.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000557 "transform/utils/hoist_to_decl_before.cc",
558 "transform/utils/hoist_to_decl_before.h",
559 "transform/var_for_dynamic_index.cc",
560 "transform/var_for_dynamic_index.h",
Zhaoming Jiang426b47e2022-09-01 03:08:20 +0000561 "transform/vectorize_matrix_conversions.cc",
562 "transform/vectorize_matrix_conversions.h",
dan sinclair6e77b472022-10-20 13:38:28 +0000563 "transform/vectorize_scalar_matrix_initializers.cc",
564 "transform/vectorize_scalar_matrix_initializers.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000565 "transform/vertex_pulling.cc",
566 "transform/vertex_pulling.h",
dan sinclair49d1a2d2022-06-16 12:01:27 +0000567 "transform/while_to_loop.cc",
568 "transform/while_to_loop.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000569 "transform/zero_init_workgroup_memory.cc",
570 "transform/zero_init_workgroup_memory.h",
Ben Clayton7cbd8202022-05-05 15:34:41 +0000571 "utils/bitcast.h",
Ben Claytone43034b2022-07-21 23:32:24 +0000572 "utils/bitset.h",
Ben Clayton4cb13292022-03-04 21:09:24 +0000573 "utils/block_allocator.h",
Ben Clayton9707e6b2022-05-25 19:28:55 +0000574 "utils/compiler_macros.h",
575 "utils/concat.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000576 "utils/crc32.h",
577 "utils/debugger.cc",
578 "utils/debugger.h",
579 "utils/enum_set.h",
Ben Clayton648bd7b2022-09-02 11:40:19 +0000580 "utils/foreach_macro.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000581 "utils/hash.h",
Ben Claytone3725112022-11-02 19:46:49 +0000582 "utils/hashmap_base.h",
Ben Claytone13160e2022-08-17 16:28:23 +0000583 "utils/hashmap.h",
584 "utils/hashset.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000585 "utils/map.h",
586 "utils/math.h",
587 "utils/scoped_assignment.h",
Ben Claytond04c54e2022-10-11 17:53:07 +0000588 "utils/string.cc",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000589 "utils/string.h",
Ben Claytone2283192022-03-05 00:29:15 +0000590 "utils/unique_allocator.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000591 "utils/unique_vector.h",
Ben Clayton3bc20e32022-07-21 19:34:05 +0000592 "utils/vector.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000593 "writer/append_vector.cc",
594 "writer/append_vector.h",
595 "writer/array_length_from_uniform_options.cc",
596 "writer/array_length_from_uniform_options.h",
Ben Clayton1a567782022-10-14 13:38:27 +0000597 "writer/check_supported_extensions.cc",
598 "writer/check_supported_extensions.h",
Antonio Maiorano4e98fb02022-05-02 19:49:19 +0000599 "writer/flatten_bindings.cc",
600 "writer/flatten_bindings.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000601 "writer/float_to_string.cc",
602 "writer/float_to_string.h",
Antonio Maioranoa730eb72022-04-06 13:57:54 +0000603 "writer/generate_external_texture_bindings.cc",
604 "writer/generate_external_texture_bindings.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000605 "writer/text.cc",
606 "writer/text.h",
607 "writer/text_generator.cc",
608 "writer/text_generator.h",
609 "writer/writer.cc",
610 "writer/writer.h",
611 ]
612
613 if (is_linux) {
614 sources += [ "diagnostic/printer_linux.cc" ]
615 } else if (is_win) {
616 sources += [ "diagnostic/printer_windows.cc" ]
617 } else {
618 sources += [ "diagnostic/printer_other.cc" ]
619 }
620}
621
622libtint_source_set("libtint_sem_src") {
623 sources = [
Ben Clayton94328872022-04-29 09:14:15 +0000624 "sem/abstract_float.cc",
625 "sem/abstract_float.h",
626 "sem/abstract_int.cc",
627 "sem/abstract_int.h",
628 "sem/abstract_numeric.cc",
629 "sem/abstract_numeric.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000630 "sem/array.cc",
631 "sem/array.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000632 "sem/atomic.cc",
633 "sem/atomic.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000634 "sem/behavior.cc",
635 "sem/behavior.h",
636 "sem/binding_point.h",
637 "sem/block_statement.cc",
Ben Clayton01004b72022-04-28 18:49:04 +0000638 "sem/bool.cc",
639 "sem/bool.h",
dan sinclairb8b0c212022-10-20 22:45:50 +0000640 "sem/break_if_statement.cc",
641 "sem/break_if_statement.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000642 "sem/builtin.cc",
643 "sem/builtin.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000644 "sem/builtin_type.cc",
645 "sem/builtin_type.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000646 "sem/call.cc",
647 "sem/call.h",
648 "sem/call_target.cc",
649 "sem/call_target.h",
650 "sem/constant.cc",
651 "sem/constant.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000652 "sem/depth_multisampled_texture.cc",
653 "sem/depth_multisampled_texture.h",
654 "sem/depth_texture.cc",
655 "sem/depth_texture.h",
Ben Clayton83bd7382022-07-15 23:46:31 +0000656 "sem/evaluation_stage.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000657 "sem/expression.cc",
658 "sem/expression.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000659 "sem/external_texture.cc",
660 "sem/external_texture.h",
Zhaoming Jiang62bfd312022-05-13 12:01:11 +0000661 "sem/f16.cc",
662 "sem/f16.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000663 "sem/f32.cc",
664 "sem/f32.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000665 "sem/for_loop_statement.cc",
666 "sem/for_loop_statement.h",
667 "sem/function.cc",
Ben Clayton01004b72022-04-28 18:49:04 +0000668 "sem/i32.cc",
669 "sem/i32.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000670 "sem/if_statement.cc",
671 "sem/if_statement.h",
Antonio Maioranodfeaf2902022-06-24 20:34:00 +0000672 "sem/index_accessor_expression.cc",
673 "sem/index_accessor_expression.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000674 "sem/info.cc",
675 "sem/info.h",
676 "sem/loop_statement.cc",
677 "sem/loop_statement.h",
Ben Clayton2081ee42022-05-19 19:32:29 +0000678 "sem/materialize.cc",
679 "sem/materialize.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000680 "sem/matrix.cc",
681 "sem/matrix.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000682 "sem/member_accessor_expression.cc",
683 "sem/module.cc",
684 "sem/module.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000685 "sem/multisampled_texture.cc",
686 "sem/multisampled_texture.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000687 "sem/node.cc",
688 "sem/node.h",
Dan Sinclair749abea2022-11-02 17:07:25 +0000689 "sem/parameter_usage.cc",
690 "sem/parameter_usage.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000691 "sem/pipeline_stage_set.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000692 "sem/pointer.cc",
693 "sem/pointer.h",
694 "sem/reference.cc",
695 "sem/reference.h",
696 "sem/sampled_texture.cc",
697 "sem/sampled_texture.h",
698 "sem/sampler.cc",
699 "sem/sampler.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000700 "sem/statement.cc",
Ben Clayton01004b72022-04-28 18:49:04 +0000701 "sem/storage_texture.cc",
702 "sem/storage_texture.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000703 "sem/struct.cc",
704 "sem/switch_statement.cc",
705 "sem/switch_statement.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000706 "sem/texture.cc",
707 "sem/texture.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000708 "sem/type.cc",
709 "sem/type.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000710 "sem/type_conversion.cc",
711 "sem/type_conversion.h",
dan sinclair6e77b472022-10-20 13:38:28 +0000712 "sem/type_initializer.cc",
713 "sem/type_initializer.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000714 "sem/type_manager.cc",
715 "sem/type_manager.h",
716 "sem/type_mappings.h",
Ben Clayton01004b72022-04-28 18:49:04 +0000717 "sem/u32.cc",
718 "sem/u32.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000719 "sem/variable.cc",
Ben Clayton01004b72022-04-28 18:49:04 +0000720 "sem/vector.cc",
721 "sem/vector.h",
722 "sem/void.cc",
723 "sem/void.h",
dan sinclair49d1a2d2022-06-16 12:01:27 +0000724 "sem/while_statement.cc",
725 "sem/while_statement.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000726 ]
727
728 public_deps = [ ":libtint_core_all_src" ]
729}
730
731libtint_source_set("libtint_core_src") {
732 public_deps = [
733 ":libtint_core_all_src",
734 ":libtint_sem_src",
735 ]
736}
737
738libtint_source_set("libtint_spv_reader_src") {
739 sources = [
740 "reader/spirv/construct.cc",
741 "reader/spirv/construct.h",
742 "reader/spirv/entry_point_info.cc",
743 "reader/spirv/entry_point_info.h",
744 "reader/spirv/enum_converter.cc",
745 "reader/spirv/enum_converter.h",
746 "reader/spirv/fail_stream.h",
747 "reader/spirv/function.cc",
748 "reader/spirv/function.h",
749 "reader/spirv/namer.cc",
750 "reader/spirv/namer.h",
751 "reader/spirv/parser.cc",
752 "reader/spirv/parser.h",
753 "reader/spirv/parser_impl.cc",
754 "reader/spirv/parser_impl.h",
755 "reader/spirv/parser_type.cc",
756 "reader/spirv/parser_type.h",
757 "reader/spirv/usage.cc",
758 "reader/spirv/usage.h",
759 ]
760
761 public_deps = [
762 ":libtint_core_src",
763 "${tint_spirv_tools_dir}/:spvtools_opt",
764 ]
765
766 public_configs = [ "${tint_spirv_tools_dir}/:spvtools_internal_config" ]
767}
768
769libtint_source_set("libtint_spv_writer_src") {
770 sources = [
771 "writer/spirv/binary_writer.cc",
772 "writer/spirv/binary_writer.h",
773 "writer/spirv/builder.cc",
774 "writer/spirv/builder.h",
775 "writer/spirv/function.cc",
776 "writer/spirv/function.h",
777 "writer/spirv/generator.cc",
778 "writer/spirv/generator.h",
Antonio Maioranob5c46c32022-04-11 21:10:20 +0000779 "writer/spirv/generator_impl.cc",
780 "writer/spirv/generator_impl.h",
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000781 "writer/spirv/instruction.cc",
782 "writer/spirv/instruction.h",
783 "writer/spirv/operand.cc",
784 "writer/spirv/operand.h",
785 "writer/spirv/scalar_constant.h",
786 ]
787
788 public_deps = [ ":libtint_core_src" ]
789}
790
791libtint_source_set("libtint_wgsl_reader_src") {
792 sources = [
793 "reader/wgsl/lexer.cc",
794 "reader/wgsl/lexer.h",
795 "reader/wgsl/parser.cc",
796 "reader/wgsl/parser.h",
797 "reader/wgsl/parser_impl.cc",
798 "reader/wgsl/parser_impl.h",
799 "reader/wgsl/parser_impl_detail.h",
800 "reader/wgsl/token.cc",
801 "reader/wgsl/token.h",
802 ]
803
804 public_deps = [ ":libtint_core_src" ]
805}
806
807libtint_source_set("libtint_wgsl_writer_src") {
808 sources = [
809 "writer/wgsl/generator.cc",
810 "writer/wgsl/generator.h",
811 "writer/wgsl/generator_impl.cc",
812 "writer/wgsl/generator_impl.h",
813 ]
814
815 public_deps = [ ":libtint_core_src" ]
816}
817
818libtint_source_set("libtint_msl_writer_src") {
819 sources = [
820 "writer/msl/generator.cc",
821 "writer/msl/generator.h",
822 "writer/msl/generator_impl.cc",
823 "writer/msl/generator_impl.h",
824 ]
825
826 public_deps = [ ":libtint_core_src" ]
827}
828
829libtint_source_set("libtint_hlsl_writer_src") {
830 sources = [
831 "writer/hlsl/generator.cc",
832 "writer/hlsl/generator.h",
833 "writer/hlsl/generator_impl.cc",
834 "writer/hlsl/generator_impl.h",
835 ]
836
837 public_deps = [ ":libtint_core_src" ]
838}
839
840libtint_source_set("libtint_glsl_writer_src") {
841 sources = [
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000842 "writer/glsl/generator.cc",
843 "writer/glsl/generator.h",
844 "writer/glsl/generator_impl.cc",
845 "writer/glsl/generator_impl.h",
846 ]
847
848 public_deps = [ ":libtint_core_src" ]
849}
850
dan sinclair6c5db2a2022-11-01 13:15:36 +0000851# Template to help invoke code generator for tint template files.
852#
853# Variables:
854# input: The prefix for the template to generate, does not include the .tmpl extension
855template("tint_intrinsic_generator") {
856 _sources = [
857 "${invoker.input}.tmpl",
858 "${tint_root_dir}/src/tint/intrinsics.def",
859 ]
860
861 _outputs = [ "${target_gen_dir}/${invoker.input}" ]
862
863 _script = "${tint_root_dir}/generator/tint_gen_template.py"
864 _args = [
865 "--output",
866 rebase_path(root_gen_dir),
867 "--template",
868 "src/tint/" + invoker.input + ".tmpl",
869 ]
870
871 action("${target_name}") {
872 script = _script
873 outputs = _outputs
874 sources = _sources
875 args = _args
876 }
877}
878
879# Template to help invoke code generator for tint template files for source files. By default this
880# will generate a `h` and `cc` build rule for the provided `input`
881#
882# Variables:
883# input: The prefix for the template, minus the file extension and .tmpl
884#
885# bench: set true to generate a bench template
886#
887# test: set true to generate a test template
888template("tint_intrinsic_src_generator") {
889 tint_intrinsic_generator("${target_name}_h") {
890 input = "${invoker.input}.h"
891 }
892 tint_intrinsic_generator("${target_name}_cc") {
893 input = "${invoker.input}.cc"
894 }
895
896 if (defined(invoker.bench) && invoker.bench) {
897 tint_intrinsic_generator("${target_name}_bench") {
898 input = "${invoker.input}_bench.cc"
899 }
900 }
901 if (defined(invoker.test) && invoker.test) {
902 tint_intrinsic_generator("${target_name}_test") {
903 input = "${invoker.input}_test.cc"
904 }
905 }
906
907 source_set(target_name) {
Dan Sinclair749abea2022-11-02 17:07:25 +0000908 deps = [
dan sinclair6c5db2a2022-11-01 13:15:36 +0000909 ":${target_name}_cc",
910 ":${target_name}_h",
911 ]
912
913 if (defined(invoker.bench) && invoker.bench) {
Dan Sinclair749abea2022-11-02 17:07:25 +0000914 deps += [ ":${target_name}_bench" ]
dan sinclair6c5db2a2022-11-01 13:15:36 +0000915 }
916 if (defined(invoker.test) && invoker.test) {
Dan Sinclair749abea2022-11-02 17:07:25 +0000917 deps += [ ":${target_name}_test" ]
dan sinclair6c5db2a2022-11-01 13:15:36 +0000918 }
919 }
920}
921
922tint_intrinsic_generator("tint_intrinsics_inl") {
923 input = "resolver/intrinsic_table.inl"
924}
925
926tint_intrinsic_src_generator("tint_init_conv_intrinsic") {
927 input = "resolver/init_conv_intrinsic"
928}
929
930tint_intrinsic_src_generator("tint_sem_builtin_type") {
931 input = "sem/builtin_type"
932}
933
934tint_intrinsic_src_generator("tint_sem_parameter_usage") {
935 input = "sem/parameter_usage"
936}
937
938tint_intrinsic_src_generator("tint_ast_extension") {
939 input = "ast/extension"
940 bench = true
941 test = true
942}
943
944tint_intrinsic_src_generator("tint_ast_access") {
945 input = "ast/access"
946}
947
948tint_intrinsic_src_generator("tint_ast_builtin_value") {
949 input = "ast/builtin_value"
950 bench = true
951 test = true
952}
953
954tint_intrinsic_src_generator("tint_ast_texel_format") {
955 input = "ast/texel_format"
956 bench = true
957 test = true
958}
959
960tint_intrinsic_src_generator("tint_ast_address_space") {
961 input = "ast/address_space"
962 bench = true
963 test = true
964}
965
966tint_intrinsic_src_generator("tint_ast_interpolate_attribute") {
967 input = "ast/interpolate_attribute"
968}
969
970libtint_source_set("tint_gen_deps") {
Dan Sinclair749abea2022-11-02 17:07:25 +0000971 deps = [
dan sinclair6c5db2a2022-11-01 13:15:36 +0000972 ":tint_ast_access",
973 ":tint_ast_address_space",
974 ":tint_ast_builtin_value",
975 ":tint_ast_extension",
976 ":tint_ast_interpolate_attribute",
977 ":tint_ast_texel_format",
978 ":tint_init_conv_intrinsic",
979 ":tint_intrinsics_inl",
980 ":tint_sem_builtin_type",
981 ":tint_sem_parameter_usage",
982 ]
983}
984
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000985source_set("libtint") {
986 public_deps = [ ":libtint_core_src" ]
987
988 if (tint_build_spv_reader) {
989 public_deps += [ ":libtint_spv_reader_src" ]
990 }
991
992 if (tint_build_spv_writer) {
993 public_deps += [ ":libtint_spv_writer_src" ]
994 }
995
996 if (tint_build_wgsl_reader) {
997 public_deps += [ ":libtint_wgsl_reader_src" ]
998 }
999
1000 if (tint_build_wgsl_writer) {
1001 public_deps += [ ":libtint_wgsl_writer_src" ]
1002 }
1003
1004 if (tint_build_msl_writer) {
1005 public_deps += [ ":libtint_msl_writer_src" ]
1006 }
1007
1008 if (tint_build_hlsl_writer) {
1009 public_deps += [ ":libtint_hlsl_writer_src" ]
1010 }
1011
1012 if (tint_build_glsl_writer) {
1013 public_deps += [ ":libtint_glsl_writer_src" ]
1014 }
1015
1016 configs += [ ":tint_common_config" ]
1017 public_configs = [ ":tint_public_config" ]
1018
1019 if (build_with_chromium) {
1020 configs -= [ "//build/config/compiler:chromium_code" ]
1021 configs += [ "//build/config/compiler:no_chromium_code" ]
1022 }
1023}
dan sinclair889a4992022-06-17 13:01:59 +00001024
dan sinclair77bf2332022-06-22 12:40:43 +00001025if (tint_build_unittests) {
1026 ###############################################################################
1027 # Gtest Gmock - Handle building inside and outside of Chromium.
1028 ###############################################################################
1029 # When building outside of Chromium we need to define our own targets for GTest
1030 # and GMock. However when compiling inside of Chromium we need to reuse the
1031 # existing targets, both because Chromium has a special harness for swarming
1032 # and because otherwise the "gn check" fails.
dan sinclair889a4992022-06-17 13:01:59 +00001033
dan sinclair77bf2332022-06-22 12:40:43 +00001034 if (!build_with_chromium) {
1035 # When we aren't in Chromium we define out own targets based on the location
1036 # of the googletest repo.
1037 config("gtest_config") {
1038 include_dirs = [
1039 "${tint_googletest_dir}/googletest",
1040 "${tint_googletest_dir}/googletest/include",
1041 ]
1042 }
1043 static_library("gtest") {
1044 testonly = true
1045 sources = [ "${tint_googletest_dir}/googletest/src/gtest-all.cc" ]
1046 public_configs = [ ":gtest_config" ]
1047 }
1048
1049 config("gmock_config") {
1050 include_dirs = [
1051 "${tint_googletest_dir}/googlemock",
1052 "${tint_googletest_dir}/googlemock/include",
1053 "${tint_googletest_dir}/googletest/include",
1054 ]
1055 }
1056
1057 static_library("gmock") {
1058 testonly = true
1059 sources = [ "${tint_googletest_dir}/googlemock/src/gmock-all.cc" ]
1060 public_configs = [ ":gmock_config" ]
1061 }
1062
1063 group("gmock_and_gtest") {
1064 testonly = true
1065 public_deps = [
1066 ":gmock",
1067 ":gtest",
1068 ]
1069 }
1070 } else {
1071 # When we are in Chromium we reuse its targets, and also add some deps that
1072 # are needed to launch the test in swarming mode.
1073 group("gmock_and_gtest") {
1074 testonly = true
1075 public_deps = [
1076 "//base",
1077 "//base/test:test_support",
1078 "//testing/gmock",
1079 "//testing/gtest",
1080 "//third_party/googletest:gmock",
1081 ]
1082 }
dan sinclair889a4992022-06-17 13:01:59 +00001083 }
dan sinclair77bf2332022-06-22 12:40:43 +00001084
1085 ###############################################################################
1086 # Wrapping of Chromium targets
1087 ###############################################################################
1088 # These targets are separated because they are Chromium sources files that
1089 # can't use the tint_internal config, otherwise Tint's warning flags get
1090 # applied while compiling a bunch of Chromium's //base (via header inclusion)
1091 source_set("tint_unittests_main") {
dan sinclair889a4992022-06-17 13:01:59 +00001092 testonly = true
dan sinclair77bf2332022-06-22 12:40:43 +00001093 deps = [ ":gmock_and_gtest" ]
1094 if (build_with_chromium) {
1095 sources = [ "//gpu/tint_unittests_main.cc" ]
1096 } else {
1097 sources = [ "test_main.cc" ]
1098 configs += [ ":tint_unittests_config" ]
1099 deps += [
1100 ":libtint",
1101 ":tint_unittests_hlsl_writer_src",
1102 ":tint_unittests_msl_writer_src",
1103 ":tint_unittests_spv_reader_src",
1104 ]
1105 }
dan sinclair889a4992022-06-17 13:01:59 +00001106 }
1107
dan sinclair77bf2332022-06-22 12:40:43 +00001108 ###############################################################################
1109 # Tests - For libtint core and optional modules
1110 ###############################################################################
1111 config("tint_unittests_config") {
dan sinclair889a4992022-06-17 13:01:59 +00001112 include_dirs = [
dan sinclair889a4992022-06-17 13:01:59 +00001113 "${tint_googletest_dir}/googlemock/include",
1114 "${tint_googletest_dir}/googletest/include",
1115 ]
dan sinclair889a4992022-06-17 13:01:59 +00001116
dan sinclair77bf2332022-06-22 12:40:43 +00001117 configs = [
1118 ":tint_common_config",
1119 ":tint_public_config",
dan sinclair889a4992022-06-17 13:01:59 +00001120 ]
1121 }
dan sinclair889a4992022-06-17 13:01:59 +00001122
dan sinclair77bf2332022-06-22 12:40:43 +00001123 template("tint_unittests_source_set") {
1124 source_set(target_name) {
1125 forward_variables_from(invoker, "*", [ "configs" ])
dan sinclair889a4992022-06-17 13:01:59 +00001126
dan sinclair77bf2332022-06-22 12:40:43 +00001127 if (defined(invoker.configs)) {
1128 configs += invoker.configs
1129 }
1130 configs += [ ":tint_unittests_config" ]
1131 if (build_with_chromium) {
1132 configs -= [ "//build/config/compiler:chromium_code" ]
1133 configs += [ "//build/config/compiler:no_chromium_code" ]
1134 }
dan sinclair889a4992022-06-17 13:01:59 +00001135
dan sinclair77bf2332022-06-22 12:40:43 +00001136 testonly = true
dan sinclair889a4992022-06-17 13:01:59 +00001137
dan sinclair77bf2332022-06-22 12:40:43 +00001138 if (!defined(invoker.deps)) {
1139 deps = []
1140 }
1141 deps += [
1142 ":gmock_and_gtest",
1143 ":libtint",
1144 ":tint_utils_io",
1145 ]
dan sinclair889a4992022-06-17 13:01:59 +00001146 }
dan sinclair77bf2332022-06-22 12:40:43 +00001147 }
1148
1149 tint_unittests_source_set("tint_unittests_ast_src") {
1150 sources = [
Dan Sinclair749abea2022-11-02 17:07:25 +00001151 "ast/address_space_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001152 "ast/alias_test.cc",
1153 "ast/array_test.cc",
1154 "ast/assignment_statement_test.cc",
1155 "ast/atomic_test.cc",
1156 "ast/binary_expression_test.cc",
1157 "ast/binding_attribute_test.cc",
1158 "ast/bitcast_expression_test.cc",
1159 "ast/block_statement_test.cc",
1160 "ast/bool_literal_expression_test.cc",
1161 "ast/bool_test.cc",
dan sinclairb8b0c212022-10-20 22:45:50 +00001162 "ast/break_if_statement_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001163 "ast/break_statement_test.cc",
1164 "ast/builtin_attribute_test.cc",
1165 "ast/builtin_texture_helper_test.cc",
1166 "ast/builtin_texture_helper_test.h",
Dan Sinclair749abea2022-11-02 17:07:25 +00001167 "ast/builtin_value_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001168 "ast/call_expression_test.cc",
1169 "ast/call_statement_test.cc",
dan sinclairf148f082022-10-19 15:55:02 +00001170 "ast/case_selector_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001171 "ast/case_statement_test.cc",
1172 "ast/compound_assignment_statement_test.cc",
1173 "ast/continue_statement_test.cc",
1174 "ast/depth_multisampled_texture_test.cc",
1175 "ast/depth_texture_test.cc",
1176 "ast/discard_statement_test.cc",
1177 "ast/enable_test.cc",
Dan Sinclair749abea2022-11-02 17:07:25 +00001178 "ast/extension_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001179 "ast/external_texture_test.cc",
1180 "ast/f16_test.cc",
1181 "ast/f32_test.cc",
1182 "ast/fallthrough_statement_test.cc",
1183 "ast/float_literal_expression_test.cc",
1184 "ast/for_loop_statement_test.cc",
1185 "ast/function_test.cc",
1186 "ast/group_attribute_test.cc",
1187 "ast/i32_test.cc",
1188 "ast/id_attribute_test.cc",
1189 "ast/identifier_expression_test.cc",
1190 "ast/if_statement_test.cc",
1191 "ast/increment_decrement_statement_test.cc",
1192 "ast/index_accessor_expression_test.cc",
1193 "ast/int_literal_expression_test.cc",
1194 "ast/interpolate_attribute_test.cc",
1195 "ast/invariant_attribute_test.cc",
1196 "ast/location_attribute_test.cc",
1197 "ast/loop_statement_test.cc",
1198 "ast/matrix_test.cc",
1199 "ast/member_accessor_expression_test.cc",
1200 "ast/module_clone_test.cc",
1201 "ast/module_test.cc",
1202 "ast/multisampled_texture_test.cc",
1203 "ast/phony_expression_test.cc",
1204 "ast/pointer_test.cc",
1205 "ast/return_statement_test.cc",
1206 "ast/sampled_texture_test.cc",
1207 "ast/sampler_test.cc",
1208 "ast/stage_attribute_test.cc",
Ben Claytonbfd1a812022-08-02 23:16:25 +00001209 "ast/static_assert_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001210 "ast/storage_texture_test.cc",
1211 "ast/stride_attribute_test.cc",
1212 "ast/struct_member_align_attribute_test.cc",
1213 "ast/struct_member_offset_attribute_test.cc",
1214 "ast/struct_member_size_attribute_test.cc",
1215 "ast/struct_member_test.cc",
1216 "ast/struct_test.cc",
1217 "ast/switch_statement_test.cc",
1218 "ast/test_helper.h",
Dan Sinclair749abea2022-11-02 17:07:25 +00001219 "ast/texel_format_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001220 "ast/texture_test.cc",
1221 "ast/traverse_expressions_test.cc",
1222 "ast/u32_test.cc",
1223 "ast/unary_op_expression_test.cc",
1224 "ast/variable_decl_statement_test.cc",
1225 "ast/variable_test.cc",
1226 "ast/vector_test.cc",
1227 "ast/while_statement_test.cc",
1228 "ast/workgroup_attribute_test.cc",
1229 ]
1230 }
1231
1232 tint_unittests_source_set("tint_unittests_diagnostic_src") {
1233 sources = [
1234 "diagnostic/diagnostic_test.cc",
1235 "diagnostic/formatter_test.cc",
1236 "diagnostic/printer_test.cc",
1237 ]
1238 }
1239
1240 tint_unittests_source_set("tint_unittests_inspector_src") {
1241 sources = [
1242 "inspector/inspector_test.cc",
1243 "inspector/test_inspector_builder.cc",
1244 "inspector/test_inspector_builder.h",
1245 "inspector/test_inspector_runner.cc",
1246 "inspector/test_inspector_runner.h",
1247 ]
1248 }
1249
1250 tint_unittests_source_set("tint_unittests_resolver_src") {
1251 sources = [
dan sinclairff7cf212022-10-03 14:05:23 +00001252 "resolver/address_space_layout_validation_test.cc",
1253 "resolver/address_space_validation_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001254 "resolver/array_accessor_test.cc",
1255 "resolver/assignment_validation_test.cc",
1256 "resolver/atomics_test.cc",
1257 "resolver/atomics_validation_test.cc",
1258 "resolver/attribute_validation_test.cc",
1259 "resolver/bitcast_validation_test.cc",
1260 "resolver/builtin_test.cc",
1261 "resolver/builtin_validation_test.cc",
1262 "resolver/builtins_validation_test.cc",
1263 "resolver/call_test.cc",
1264 "resolver/call_validation_test.cc",
1265 "resolver/compound_assignment_validation_test.cc",
1266 "resolver/compound_statement_test.cc",
Antonio Maiorano723da2a2022-10-13 19:27:30 +00001267 "resolver/const_eval_binary_op_test.cc",
1268 "resolver/const_eval_builtin_test.cc",
1269 "resolver/const_eval_construction_test.cc",
1270 "resolver/const_eval_conversion_test.cc",
1271 "resolver/const_eval_indexing_test.cc",
1272 "resolver/const_eval_member_access_test.cc",
1273 "resolver/const_eval_test.h",
1274 "resolver/const_eval_unary_op_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001275 "resolver/control_block_validation_test.cc",
1276 "resolver/dependency_graph_test.cc",
1277 "resolver/entry_point_validation_test.cc",
Ben Clayton83bd7382022-07-15 23:46:31 +00001278 "resolver/evaluation_stage_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001279 "resolver/function_validation_test.cc",
1280 "resolver/host_shareable_validation_test.cc",
1281 "resolver/increment_decrement_validation_test.cc",
Ben Clayton783b1692022-08-02 17:03:35 +00001282 "resolver/inferred_type_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001283 "resolver/intrinsic_table_test.cc",
1284 "resolver/is_host_shareable_test.cc",
1285 "resolver/is_storeable_test.cc",
1286 "resolver/materialize_test.cc",
Ben Clayton9a6acc42022-07-27 20:50:40 +00001287 "resolver/override_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001288 "resolver/ptr_ref_test.cc",
1289 "resolver/ptr_ref_validation_test.cc",
1290 "resolver/resolver_behavior_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001291 "resolver/resolver_test.cc",
1292 "resolver/resolver_test_helper.cc",
1293 "resolver/resolver_test_helper.h",
1294 "resolver/side_effects_test.cc",
1295 "resolver/source_variable_test.cc",
dan sinclair1cd47062022-08-05 14:53:47 +00001296 "resolver/static_assert_test.cc",
dan sinclairff7cf212022-10-03 14:05:23 +00001297 "resolver/struct_address_space_use_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001298 "resolver/struct_layout_test.cc",
1299 "resolver/struct_pipeline_stage_use_test.cc",
dan sinclair6e77b472022-10-20 13:38:28 +00001300 "resolver/type_initializer_validation_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001301 "resolver/type_validation_test.cc",
1302 "resolver/uniformity_test.cc",
1303 "resolver/validation_test.cc",
1304 "resolver/validator_is_storeable_test.cc",
Ben Clayton68ae36e2022-06-24 21:26:39 +00001305 "resolver/variable_test.cc",
1306 "resolver/variable_validation_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001307 ]
1308 deps = [ ":tint_unittests_ast_src" ]
1309 }
1310
1311 tint_unittests_source_set("tint_unittests_sem_src") {
1312 sources = [
Ben Claytondf3a0462022-10-17 13:24:38 +00001313 "sem/array_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001314 "sem/atomic_test.cc",
1315 "sem/bool_test.cc",
1316 "sem/builtin_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001317 "sem/depth_multisampled_texture_test.cc",
1318 "sem/depth_texture_test.cc",
1319 "sem/expression_test.cc",
1320 "sem/external_texture_test.cc",
1321 "sem/f16_test.cc",
1322 "sem/f32_test.cc",
1323 "sem/i32_test.cc",
1324 "sem/matrix_test.cc",
1325 "sem/multisampled_texture_test.cc",
1326 "sem/pointer_test.cc",
1327 "sem/reference_test.cc",
1328 "sem/sampled_texture_test.cc",
1329 "sem/sampler_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001330 "sem/storage_texture_test.cc",
Ben Claytondf3a0462022-10-17 13:24:38 +00001331 "sem/struct_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001332 "sem/texture_test.cc",
1333 "sem/type_manager_test.cc",
1334 "sem/type_test.cc",
1335 "sem/u32_test.cc",
1336 "sem/vector_test.cc",
1337 ]
1338 }
1339
1340 tint_unittests_source_set("tint_unittests_text_src") {
1341 sources = [ "text/unicode_test.cc" ]
1342 }
1343
1344 tint_unittests_source_set("tint_unittests_transform_src") {
1345 sources = [
Stephen White863d9ed2022-09-02 19:19:10 +00001346 "transform/add_block_attribute_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001347 "transform/add_empty_entry_point_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001348 "transform/array_length_from_uniform_test.cc",
1349 "transform/binding_remapper_test.cc",
1350 "transform/builtin_polyfill_test.cc",
1351 "transform/calculate_array_length_test.cc",
1352 "transform/canonicalize_entry_point_io_test.cc",
Corentin Wallez98a7cd12022-10-11 09:52:25 +00001353 "transform/clamp_frag_depth_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001354 "transform/combine_samplers_test.cc",
1355 "transform/decompose_memory_access_test.cc",
1356 "transform/decompose_strided_array_test.cc",
1357 "transform/decompose_strided_matrix_test.cc",
1358 "transform/disable_uniformity_analysis_test.cc",
1359 "transform/expand_compound_assignment_test.cc",
1360 "transform/first_index_offset_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001361 "transform/for_loop_to_loop_test.cc",
1362 "transform/localize_struct_array_assignment_test.cc",
James Price5de8b432022-10-31 14:49:03 +00001363 "transform/merge_return_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001364 "transform/module_scope_var_to_entry_point_param_test.cc",
1365 "transform/multiplanar_external_texture_test.cc",
1366 "transform/num_workgroups_from_uniform_test.cc",
Ben Claytona92f4252022-10-27 14:36:49 +00001367 "transform/packed_vec3_test.cc",
Stephen White05d8b022022-09-13 19:48:51 +00001368 "transform/pad_structs_test.cc",
Ben Clayton7ebcfc72022-06-27 20:20:25 +00001369 "transform/promote_initializers_to_let_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001370 "transform/promote_side_effects_to_decl_test.cc",
1371 "transform/remove_continue_in_switch_test.cc",
1372 "transform/remove_phonies_test.cc",
1373 "transform/remove_unreachable_statements_test.cc",
1374 "transform/renamer_test.cc",
1375 "transform/robustness_test.cc",
1376 "transform/simplify_pointers_test.cc",
1377 "transform/single_entry_point_test.cc",
Antonio Maiorano268d7b82022-06-24 22:28:23 +00001378 "transform/spirv_atomic_test.cc",
Zhaoming Jiang5cbb32d2022-10-11 07:55:00 +00001379 "transform/std140_exhaustive_test.cc",
Ben Clayton657e61d2022-09-01 22:12:19 +00001380 "transform/std140_test.cc",
dan sinclair256f1112022-07-22 16:05:06 +00001381 "transform/substitute_override_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001382 "transform/test_helper.h",
1383 "transform/transform_test.cc",
1384 "transform/unshadow_test.cc",
1385 "transform/unwind_discard_functions_test.cc",
1386 "transform/utils/get_insertion_point_test.cc",
1387 "transform/utils/hoist_to_decl_before_test.cc",
1388 "transform/var_for_dynamic_index_test.cc",
Zhaoming Jiang426b47e2022-09-01 03:08:20 +00001389 "transform/vectorize_matrix_conversions_test.cc",
dan sinclair6e77b472022-10-20 13:38:28 +00001390 "transform/vectorize_scalar_matrix_initializers_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001391 "transform/vertex_pulling_test.cc",
1392 "transform/while_to_loop_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001393 "transform/zero_init_workgroup_memory_test.cc",
1394 ]
1395 }
1396
1397 tint_unittests_source_set("tint_unittests_utils_src") {
1398 sources = [
1399 "utils/bitcast_test.cc",
Ben Claytone43034b2022-07-21 23:32:24 +00001400 "utils/bitset_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001401 "utils/crc32_test.cc",
1402 "utils/defer_test.cc",
1403 "utils/enum_set_test.cc",
1404 "utils/hash_test.cc",
Ben Claytone13160e2022-08-17 16:28:23 +00001405 "utils/hashmap_test.cc",
1406 "utils/hashset_test.cc",
dan sinclairff2cb022022-08-18 14:37:17 +00001407 "utils/io/command_test.cc",
1408 "utils/io/tmpfile_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001409 "utils/map_test.cc",
1410 "utils/math_test.cc",
1411 "utils/result_test.cc",
1412 "utils/reverse_test.cc",
1413 "utils/scoped_assignment_test.cc",
1414 "utils/string_test.cc",
1415 "utils/transform_test.cc",
1416 "utils/unique_allocator_test.cc",
1417 "utils/unique_vector_test.cc",
Ben Clayton3bc20e32022-07-21 19:34:05 +00001418 "utils/vector_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001419 ]
1420 }
1421
1422 tint_unittests_source_set("tint_unittests_writer_src") {
1423 sources = [
1424 "writer/append_vector_test.cc",
Ben Clayton1a567782022-10-14 13:38:27 +00001425 "writer/check_supported_extensions_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001426 "writer/flatten_bindings_test.cc",
1427 "writer/float_to_string_test.cc",
1428 "writer/generate_external_texture_bindings_test.cc",
1429 "writer/text_generator_test.cc",
1430 ]
1431 }
1432
1433 tint_unittests_source_set("tint_unittests_spv_reader_src") {
1434 sources = [
1435 "reader/spirv/enum_converter_test.cc",
1436 "reader/spirv/fail_stream_test.cc",
1437 "reader/spirv/function_arithmetic_test.cc",
1438 "reader/spirv/function_bit_test.cc",
1439 "reader/spirv/function_call_test.cc",
1440 "reader/spirv/function_cfg_test.cc",
1441 "reader/spirv/function_composite_test.cc",
1442 "reader/spirv/function_conversion_test.cc",
1443 "reader/spirv/function_decl_test.cc",
1444 "reader/spirv/function_glsl_std_450_test.cc",
1445 "reader/spirv/function_logical_test.cc",
1446 "reader/spirv/function_memory_test.cc",
1447 "reader/spirv/function_misc_test.cc",
1448 "reader/spirv/function_var_test.cc",
1449 "reader/spirv/namer_test.cc",
1450 "reader/spirv/parser_impl_barrier_test.cc",
1451 "reader/spirv/parser_impl_convert_member_decoration_test.cc",
1452 "reader/spirv/parser_impl_convert_type_test.cc",
1453 "reader/spirv/parser_impl_function_decl_test.cc",
1454 "reader/spirv/parser_impl_get_decorations_test.cc",
1455 "reader/spirv/parser_impl_handle_test.cc",
1456 "reader/spirv/parser_impl_import_test.cc",
1457 "reader/spirv/parser_impl_module_var_test.cc",
1458 "reader/spirv/parser_impl_named_types_test.cc",
1459 "reader/spirv/parser_impl_test.cc",
1460 "reader/spirv/parser_impl_test_helper.cc",
1461 "reader/spirv/parser_impl_test_helper.h",
1462 "reader/spirv/parser_impl_user_name_test.cc",
1463 "reader/spirv/parser_test.cc",
1464 "reader/spirv/parser_type_test.cc",
1465 "reader/spirv/spirv_tools_helpers_test.cc",
1466 "reader/spirv/spirv_tools_helpers_test.h",
1467 "reader/spirv/usage_test.cc",
1468 ]
1469
1470 deps = [ ":libtint_spv_reader_src" ]
1471 }
1472
1473 tint_unittests_source_set("tint_unittests_spv_writer_src") {
1474 sources = [
1475 "writer/spirv/binary_writer_test.cc",
1476 "writer/spirv/builder_accessor_expression_test.cc",
1477 "writer/spirv/builder_assign_test.cc",
1478 "writer/spirv/builder_binary_expression_test.cc",
1479 "writer/spirv/builder_bitcast_expression_test.cc",
1480 "writer/spirv/builder_block_test.cc",
1481 "writer/spirv/builder_builtin_test.cc",
1482 "writer/spirv/builder_builtin_texture_test.cc",
1483 "writer/spirv/builder_call_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001484 "writer/spirv/builder_discard_test.cc",
1485 "writer/spirv/builder_entry_point_test.cc",
1486 "writer/spirv/builder_format_conversion_test.cc",
1487 "writer/spirv/builder_function_attribute_test.cc",
1488 "writer/spirv/builder_function_test.cc",
1489 "writer/spirv/builder_function_variable_test.cc",
1490 "writer/spirv/builder_global_variable_test.cc",
1491 "writer/spirv/builder_ident_expression_test.cc",
1492 "writer/spirv/builder_if_test.cc",
dan sinclair6e77b472022-10-20 13:38:28 +00001493 "writer/spirv/builder_initializer_expression_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001494 "writer/spirv/builder_literal_test.cc",
1495 "writer/spirv/builder_loop_test.cc",
1496 "writer/spirv/builder_return_test.cc",
Ben Claytonb4744ac2022-08-03 07:01:08 +00001497 "writer/spirv/builder_static_assert_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001498 "writer/spirv/builder_switch_test.cc",
1499 "writer/spirv/builder_test.cc",
1500 "writer/spirv/builder_type_test.cc",
1501 "writer/spirv/builder_unary_op_expression_test.cc",
1502 "writer/spirv/instruction_test.cc",
1503 "writer/spirv/operand_test.cc",
1504 "writer/spirv/scalar_constant_test.cc",
1505 "writer/spirv/spv_dump.cc",
1506 "writer/spirv/spv_dump.h",
1507 "writer/spirv/test_helper.h",
1508 ]
1509
1510 deps = [
1511 ":libtint_spv_writer_src",
1512 ":tint_unittests_ast_src",
1513 "${tint_spirv_tools_dir}/:spvtools",
1514 ]
1515 }
1516
1517 tint_unittests_source_set("tint_unittests_wgsl_reader_src") {
1518 sources = [
1519 "reader/wgsl/lexer_test.cc",
1520 "reader/wgsl/parser_impl_additive_expression_test.cc",
dan sinclairff7cf212022-10-03 14:05:23 +00001521 "reader/wgsl/parser_impl_address_space_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001522 "reader/wgsl/parser_impl_argument_expression_list_test.cc",
1523 "reader/wgsl/parser_impl_assignment_stmt_test.cc",
dan sinclairff2cb022022-08-18 14:37:17 +00001524 "reader/wgsl/parser_impl_bitwise_expression_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001525 "reader/wgsl/parser_impl_break_stmt_test.cc",
1526 "reader/wgsl/parser_impl_bug_cases_test.cc",
1527 "reader/wgsl/parser_impl_call_stmt_test.cc",
dan sinclair393de082022-08-22 16:15:04 +00001528 "reader/wgsl/parser_impl_callable_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001529 "reader/wgsl/parser_impl_case_body_test.cc",
dan sinclair1cd47062022-08-05 14:53:47 +00001530 "reader/wgsl/parser_impl_compound_stmt_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001531 "reader/wgsl/parser_impl_const_literal_test.cc",
1532 "reader/wgsl/parser_impl_continue_stmt_test.cc",
1533 "reader/wgsl/parser_impl_continuing_stmt_test.cc",
dan sinclair6c8dc152022-08-17 16:30:30 +00001534 "reader/wgsl/parser_impl_core_lhs_expression_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001535 "reader/wgsl/parser_impl_depth_texture_test.cc",
dan sinclair2788bec2022-08-19 21:26:01 +00001536 "reader/wgsl/parser_impl_element_count_expression_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001537 "reader/wgsl/parser_impl_enable_directive_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001538 "reader/wgsl/parser_impl_error_msg_test.cc",
1539 "reader/wgsl/parser_impl_error_resync_test.cc",
dan sinclairee255862022-08-22 14:06:44 +00001540 "reader/wgsl/parser_impl_expression_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001541 "reader/wgsl/parser_impl_external_texture_test.cc",
1542 "reader/wgsl/parser_impl_for_stmt_test.cc",
1543 "reader/wgsl/parser_impl_function_attribute_list_test.cc",
1544 "reader/wgsl/parser_impl_function_attribute_test.cc",
1545 "reader/wgsl/parser_impl_function_decl_test.cc",
1546 "reader/wgsl/parser_impl_function_header_test.cc",
1547 "reader/wgsl/parser_impl_global_constant_decl_test.cc",
1548 "reader/wgsl/parser_impl_global_decl_test.cc",
1549 "reader/wgsl/parser_impl_global_variable_decl_test.cc",
1550 "reader/wgsl/parser_impl_if_stmt_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001551 "reader/wgsl/parser_impl_increment_decrement_stmt_test.cc",
dan sinclair6c8dc152022-08-17 16:30:30 +00001552 "reader/wgsl/parser_impl_lhs_expression_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001553 "reader/wgsl/parser_impl_loop_stmt_test.cc",
dan sinclair2788bec2022-08-19 21:26:01 +00001554 "reader/wgsl/parser_impl_math_expression_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001555 "reader/wgsl/parser_impl_multiplicative_expression_test.cc",
1556 "reader/wgsl/parser_impl_param_list_test.cc",
dan sinclair05288f62022-07-22 16:07:36 +00001557 "reader/wgsl/parser_impl_paren_expression_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001558 "reader/wgsl/parser_impl_pipeline_stage_test.cc",
1559 "reader/wgsl/parser_impl_primary_expression_test.cc",
1560 "reader/wgsl/parser_impl_relational_expression_test.cc",
1561 "reader/wgsl/parser_impl_reserved_keyword_test.cc",
1562 "reader/wgsl/parser_impl_sampled_texture_test.cc",
1563 "reader/wgsl/parser_impl_sampler_test.cc",
1564 "reader/wgsl/parser_impl_shift_expression_test.cc",
1565 "reader/wgsl/parser_impl_singular_expression_test.cc",
1566 "reader/wgsl/parser_impl_statement_test.cc",
1567 "reader/wgsl/parser_impl_statements_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001568 "reader/wgsl/parser_impl_storage_texture_test.cc",
1569 "reader/wgsl/parser_impl_struct_attribute_decl_test.cc",
1570 "reader/wgsl/parser_impl_struct_body_decl_test.cc",
1571 "reader/wgsl/parser_impl_struct_decl_test.cc",
1572 "reader/wgsl/parser_impl_struct_member_attribute_decl_test.cc",
1573 "reader/wgsl/parser_impl_struct_member_attribute_test.cc",
1574 "reader/wgsl/parser_impl_struct_member_test.cc",
1575 "reader/wgsl/parser_impl_switch_body_test.cc",
1576 "reader/wgsl/parser_impl_switch_stmt_test.cc",
1577 "reader/wgsl/parser_impl_test.cc",
1578 "reader/wgsl/parser_impl_test_helper.cc",
1579 "reader/wgsl/parser_impl_test_helper.h",
1580 "reader/wgsl/parser_impl_texel_format_test.cc",
1581 "reader/wgsl/parser_impl_texture_sampler_test.cc",
1582 "reader/wgsl/parser_impl_type_alias_test.cc",
1583 "reader/wgsl/parser_impl_type_decl_test.cc",
dan sinclair393de082022-08-22 16:15:04 +00001584 "reader/wgsl/parser_impl_type_decl_without_ident_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001585 "reader/wgsl/parser_impl_unary_expression_test.cc",
1586 "reader/wgsl/parser_impl_variable_attribute_list_test.cc",
1587 "reader/wgsl/parser_impl_variable_attribute_test.cc",
1588 "reader/wgsl/parser_impl_variable_decl_test.cc",
1589 "reader/wgsl/parser_impl_variable_ident_decl_test.cc",
1590 "reader/wgsl/parser_impl_variable_qualifier_test.cc",
1591 "reader/wgsl/parser_impl_variable_stmt_test.cc",
dan sinclair393de082022-08-22 16:15:04 +00001592 "reader/wgsl/parser_impl_vec_mat_prefix_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001593 "reader/wgsl/parser_impl_while_stmt_test.cc",
1594 "reader/wgsl/parser_test.cc",
1595 "reader/wgsl/token_test.cc",
1596 ]
1597
1598 deps = [ ":libtint_wgsl_reader_src" ]
1599 }
1600
1601 tint_unittests_source_set("tint_unittests_wgsl_writer_src") {
1602 sources = [
1603 "writer/wgsl/generator_impl_alias_type_test.cc",
1604 "writer/wgsl/generator_impl_array_accessor_test.cc",
1605 "writer/wgsl/generator_impl_assign_test.cc",
1606 "writer/wgsl/generator_impl_binary_test.cc",
1607 "writer/wgsl/generator_impl_bitcast_test.cc",
1608 "writer/wgsl/generator_impl_block_test.cc",
1609 "writer/wgsl/generator_impl_break_test.cc",
1610 "writer/wgsl/generator_impl_call_test.cc",
1611 "writer/wgsl/generator_impl_case_test.cc",
1612 "writer/wgsl/generator_impl_cast_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001613 "writer/wgsl/generator_impl_continue_test.cc",
1614 "writer/wgsl/generator_impl_discard_test.cc",
1615 "writer/wgsl/generator_impl_enable_test.cc",
1616 "writer/wgsl/generator_impl_fallthrough_test.cc",
1617 "writer/wgsl/generator_impl_function_test.cc",
1618 "writer/wgsl/generator_impl_global_decl_test.cc",
1619 "writer/wgsl/generator_impl_identifier_test.cc",
1620 "writer/wgsl/generator_impl_if_test.cc",
dan sinclair6e77b472022-10-20 13:38:28 +00001621 "writer/wgsl/generator_impl_initializer_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001622 "writer/wgsl/generator_impl_literal_test.cc",
1623 "writer/wgsl/generator_impl_loop_test.cc",
1624 "writer/wgsl/generator_impl_member_accessor_test.cc",
1625 "writer/wgsl/generator_impl_return_test.cc",
Ben Claytonb4744ac2022-08-03 07:01:08 +00001626 "writer/wgsl/generator_impl_static_assert_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001627 "writer/wgsl/generator_impl_switch_test.cc",
1628 "writer/wgsl/generator_impl_test.cc",
1629 "writer/wgsl/generator_impl_type_test.cc",
1630 "writer/wgsl/generator_impl_unary_op_test.cc",
1631 "writer/wgsl/generator_impl_variable_decl_statement_test.cc",
1632 "writer/wgsl/generator_impl_variable_test.cc",
1633 "writer/wgsl/test_helper.h",
1634 ]
1635
1636 deps = [
1637 ":libtint_wgsl_writer_src",
1638 ":tint_unittests_ast_src",
1639 ]
1640 }
1641
1642 tint_unittests_source_set("tint_unittests_msl_writer_src") {
1643 sources = [
1644 "writer/msl/generator_impl_array_accessor_test.cc",
1645 "writer/msl/generator_impl_assign_test.cc",
1646 "writer/msl/generator_impl_binary_test.cc",
1647 "writer/msl/generator_impl_bitcast_test.cc",
1648 "writer/msl/generator_impl_block_test.cc",
1649 "writer/msl/generator_impl_break_test.cc",
1650 "writer/msl/generator_impl_builtin_test.cc",
1651 "writer/msl/generator_impl_builtin_texture_test.cc",
1652 "writer/msl/generator_impl_call_test.cc",
1653 "writer/msl/generator_impl_case_test.cc",
1654 "writer/msl/generator_impl_cast_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001655 "writer/msl/generator_impl_continue_test.cc",
1656 "writer/msl/generator_impl_discard_test.cc",
1657 "writer/msl/generator_impl_function_test.cc",
1658 "writer/msl/generator_impl_identifier_test.cc",
1659 "writer/msl/generator_impl_if_test.cc",
1660 "writer/msl/generator_impl_import_test.cc",
dan sinclair6e77b472022-10-20 13:38:28 +00001661 "writer/msl/generator_impl_initializer_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001662 "writer/msl/generator_impl_loop_test.cc",
1663 "writer/msl/generator_impl_member_accessor_test.cc",
1664 "writer/msl/generator_impl_module_constant_test.cc",
1665 "writer/msl/generator_impl_return_test.cc",
1666 "writer/msl/generator_impl_sanitizer_test.cc",
Ben Claytonb4744ac2022-08-03 07:01:08 +00001667 "writer/msl/generator_impl_static_assert_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001668 "writer/msl/generator_impl_switch_test.cc",
1669 "writer/msl/generator_impl_test.cc",
1670 "writer/msl/generator_impl_type_test.cc",
1671 "writer/msl/generator_impl_unary_op_test.cc",
1672 "writer/msl/generator_impl_variable_decl_statement_test.cc",
1673 "writer/msl/test_helper.h",
1674 ]
1675
1676 deps = [
1677 ":libtint_msl_writer_src",
1678 ":tint_unittests_ast_src",
1679 ]
1680 }
1681
1682 tint_unittests_source_set("tint_unittests_hlsl_writer_src") {
1683 sources = [
1684 "writer/hlsl/generator_impl_array_accessor_test.cc",
1685 "writer/hlsl/generator_impl_assign_test.cc",
1686 "writer/hlsl/generator_impl_binary_test.cc",
1687 "writer/hlsl/generator_impl_bitcast_test.cc",
1688 "writer/hlsl/generator_impl_block_test.cc",
1689 "writer/hlsl/generator_impl_break_test.cc",
1690 "writer/hlsl/generator_impl_builtin_test.cc",
1691 "writer/hlsl/generator_impl_builtin_texture_test.cc",
1692 "writer/hlsl/generator_impl_call_test.cc",
1693 "writer/hlsl/generator_impl_case_test.cc",
1694 "writer/hlsl/generator_impl_cast_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001695 "writer/hlsl/generator_impl_continue_test.cc",
1696 "writer/hlsl/generator_impl_discard_test.cc",
1697 "writer/hlsl/generator_impl_function_test.cc",
1698 "writer/hlsl/generator_impl_identifier_test.cc",
1699 "writer/hlsl/generator_impl_if_test.cc",
1700 "writer/hlsl/generator_impl_import_test.cc",
dan sinclair6e77b472022-10-20 13:38:28 +00001701 "writer/hlsl/generator_impl_initializer_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001702 "writer/hlsl/generator_impl_loop_test.cc",
1703 "writer/hlsl/generator_impl_member_accessor_test.cc",
1704 "writer/hlsl/generator_impl_module_constant_test.cc",
1705 "writer/hlsl/generator_impl_return_test.cc",
1706 "writer/hlsl/generator_impl_sanitizer_test.cc",
Ben Claytonb4744ac2022-08-03 07:01:08 +00001707 "writer/hlsl/generator_impl_static_assert_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001708 "writer/hlsl/generator_impl_switch_test.cc",
1709 "writer/hlsl/generator_impl_test.cc",
1710 "writer/hlsl/generator_impl_type_test.cc",
1711 "writer/hlsl/generator_impl_unary_op_test.cc",
1712 "writer/hlsl/generator_impl_variable_decl_statement_test.cc",
1713 "writer/hlsl/generator_impl_workgroup_var_test.cc",
1714 "writer/hlsl/test_helper.h",
1715 ]
1716
1717 deps = [
1718 ":libtint_hlsl_writer_src",
1719 ":tint_unittests_ast_src",
1720 ]
1721 }
1722
1723 tint_unittests_source_set("tint_unittests_glsl_writer_src") {
1724 sources = [
1725 "writer/glsl/generator_impl_array_accessor_test.cc",
1726 "writer/glsl/generator_impl_assign_test.cc",
1727 "writer/glsl/generator_impl_binary_test.cc",
1728 "writer/glsl/generator_impl_bitcast_test.cc",
1729 "writer/glsl/generator_impl_block_test.cc",
1730 "writer/glsl/generator_impl_break_test.cc",
1731 "writer/glsl/generator_impl_builtin_test.cc",
1732 "writer/glsl/generator_impl_builtin_texture_test.cc",
1733 "writer/glsl/generator_impl_call_test.cc",
1734 "writer/glsl/generator_impl_case_test.cc",
1735 "writer/glsl/generator_impl_cast_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001736 "writer/glsl/generator_impl_continue_test.cc",
1737 "writer/glsl/generator_impl_discard_test.cc",
1738 "writer/glsl/generator_impl_function_test.cc",
1739 "writer/glsl/generator_impl_identifier_test.cc",
1740 "writer/glsl/generator_impl_if_test.cc",
1741 "writer/glsl/generator_impl_import_test.cc",
dan sinclair6e77b472022-10-20 13:38:28 +00001742 "writer/glsl/generator_impl_initializer_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001743 "writer/glsl/generator_impl_loop_test.cc",
1744 "writer/glsl/generator_impl_member_accessor_test.cc",
1745 "writer/glsl/generator_impl_module_constant_test.cc",
1746 "writer/glsl/generator_impl_return_test.cc",
1747 "writer/glsl/generator_impl_sanitizer_test.cc",
1748 "writer/glsl/generator_impl_storage_buffer_test.cc",
1749 "writer/glsl/generator_impl_switch_test.cc",
1750 "writer/glsl/generator_impl_test.cc",
1751 "writer/glsl/generator_impl_type_test.cc",
1752 "writer/glsl/generator_impl_unary_op_test.cc",
1753 "writer/glsl/generator_impl_uniform_buffer_test.cc",
1754 "writer/glsl/generator_impl_variable_decl_statement_test.cc",
1755 "writer/glsl/generator_impl_workgroup_var_test.cc",
1756 "writer/glsl/test_helper.h",
1757 ]
1758
1759 deps = [
1760 ":libtint_glsl_writer_src",
1761 ":tint_unittests_ast_src",
1762 ":tint_unittests_transform_src",
1763 ]
1764 }
1765
1766 tint_unittests_source_set("tint_unittests_core_src") {
1767 sources = [
1768 "castable_test.cc",
1769 "clone_context_test.cc",
1770 "debug_test.cc",
1771 "demangler_test.cc",
1772 "number_test.cc",
1773 "program_builder_test.cc",
1774 "program_test.cc",
Ben Clayton648bd7b2022-09-02 11:40:19 +00001775 "reflection_test.cc",
dan sinclair77bf2332022-06-22 12:40:43 +00001776 "scope_stack_test.cc",
1777 "source_test.cc",
1778 "symbol_table_test.cc",
1779 "symbol_test.cc",
1780 "traits_test.cc",
1781 "utils/block_allocator_test.cc",
1782 ]
1783
1784 deps = [ ":tint_unittests_ast_src" ]
1785 }
1786
1787 if (build_with_chromium) {
1788 tint_unittests_source_set("tint_unittests_fuzzer_src") {
1789 sources = [ "fuzzers/random_generator_test.cc" ]
1790
1791 deps = [
1792 ":tint_unittests_core_src",
1793 "fuzzers:tint_fuzzer_common_src",
1794 ]
1795 }
1796 }
1797
1798 source_set("tint_unittests_src") {
1799 testonly = true
1800
1801 deps = [
1802 ":libtint_wgsl_reader_src",
1803 ":libtint_wgsl_writer_src",
1804 ":tint_unittests_ast_src",
1805 ":tint_unittests_core_src",
1806 ":tint_unittests_diagnostic_src",
1807 ":tint_unittests_inspector_src",
1808 ":tint_unittests_resolver_src",
1809 ":tint_unittests_sem_src",
1810 ":tint_unittests_text_src",
1811 ":tint_unittests_transform_src",
1812 ":tint_unittests_utils_src",
1813 ":tint_unittests_writer_src",
1814 ]
1815
1816 if (tint_build_spv_reader) {
1817 deps += [ ":tint_unittests_spv_reader_src" ]
1818 }
1819
1820 if (tint_build_spv_writer) {
1821 deps += [ ":tint_unittests_spv_writer_src" ]
1822 }
1823
1824 if (tint_build_wgsl_reader) {
1825 deps += [ ":tint_unittests_wgsl_reader_src" ]
1826 }
1827
1828 if (tint_build_wgsl_writer) {
1829 deps += [ ":tint_unittests_wgsl_writer_src" ]
1830 }
1831
1832 if (tint_build_msl_writer) {
1833 deps += [ ":tint_unittests_msl_writer_src" ]
1834 }
1835
1836 if (tint_build_hlsl_writer) {
1837 deps += [ ":tint_unittests_hlsl_writer_src" ]
1838 }
1839
1840 if (tint_build_glsl_writer) {
1841 deps += [ ":tint_unittests_glsl_writer_src" ]
1842 }
1843
1844 if (build_with_chromium) {
1845 deps += [ ":tint_unittests_fuzzer_src" ]
1846 }
1847
dan sinclair889a4992022-06-17 13:01:59 +00001848 configs += [ ":tint_unittests_config" ]
dan sinclair77bf2332022-06-22 12:40:43 +00001849
1850 if (build_with_chromium) {
1851 configs -= [ "//build/config/compiler:chromium_code" ]
1852 configs += [ "//build/config/compiler:no_chromium_code" ]
1853 }
1854 }
1855
1856 test("tint_unittests") {
1857 deps = [
1858 ":gmock_and_gtest",
1859 ":tint_unittests_src",
1860 "${tint_spirv_tools_dir}/:spvtools",
1861 "${tint_spirv_tools_dir}/:spvtools_opt",
1862 "${tint_spirv_tools_dir}/:spvtools_val",
1863 ]
1864
1865 deps += [ ":tint_unittests_main" ]
1866
1867 configs += [ ":tint_unittests_config" ]
1868
dan sinclair889a4992022-06-17 13:01:59 +00001869 if (build_with_chromium) {
1870 configs -= [ "//build/config/compiler:chromium_code" ]
1871 configs += [ "//build/config/compiler:no_chromium_code" ]
1872 }
1873
1874 testonly = true
dan sinclair889a4992022-06-17 13:01:59 +00001875 }
1876}