summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/scripts/shaderc.lua
blob: 4da12fafa451bf38c9c29671e13c3a76f99316ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
--
-- Copyright 2010-2023 Branimir Karadzic. All rights reserved.
-- License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
--

group "tools/shaderc"

local GLSL_OPTIMIZER = path.join(BGFX_DIR, "3rdparty/glsl-optimizer")
local FCPP_DIR       = path.join(BGFX_DIR, "3rdparty/fcpp")
local GLSLANG        = path.join(BGFX_DIR, "3rdparty/glslang")
local SPIRV_CROSS    = path.join(BGFX_DIR, "3rdparty/spirv-cross")
local SPIRV_HEADERS  = path.join(BGFX_DIR, "3rdparty/spirv-headers")
local SPIRV_TOOLS    = path.join(BGFX_DIR, "3rdparty/spirv-tools")

project "spirv-opt"
	kind "StaticLib"

	includedirs {
		SPIRV_TOOLS,

		path.join(SPIRV_TOOLS, "include"),
		path.join(SPIRV_TOOLS, "include/generated"),
		path.join(SPIRV_TOOLS, "source"),
		path.join(SPIRV_HEADERS, "include"),
	}

	files {
		path.join(SPIRV_TOOLS, "source/opt/**.cpp"),
		path.join(SPIRV_TOOLS, "source/opt/**.h"),
		path.join(SPIRV_TOOLS, "source/reduce/**.cpp"),
		path.join(SPIRV_TOOLS, "source/reduce/**.h"),
		path.join(SPIRV_TOOLS, "source/val/**.cpp"),
		path.join(SPIRV_TOOLS, "source/val/**.h"),

		-- libspirv
		path.join(SPIRV_TOOLS, "source/assembly_grammar.cpp"),
		path.join(SPIRV_TOOLS, "source/assembly_grammar.h"),
		path.join(SPIRV_TOOLS, "source/binary.cpp"),
		path.join(SPIRV_TOOLS, "source/binary.h"),
		path.join(SPIRV_TOOLS, "source/cfa.h"),
		path.join(SPIRV_TOOLS, "source/diagnostic.cpp"),
		path.join(SPIRV_TOOLS, "source/diagnostic.h"),
		path.join(SPIRV_TOOLS, "source/disassemble.cpp"),
		path.join(SPIRV_TOOLS, "source/disassemble.h"),
		path.join(SPIRV_TOOLS, "source/enum_set.h"),
		path.join(SPIRV_TOOLS, "source/enum_string_mapping.cpp"),
		path.join(SPIRV_TOOLS, "source/enum_string_mapping.h"),
		path.join(SPIRV_TOOLS, "source/ext_inst.cpp"),
		path.join(SPIRV_TOOLS, "source/ext_inst.h"),
		path.join(SPIRV_TOOLS, "source/extensions.cpp"),
		path.join(SPIRV_TOOLS, "source/extensions.h"),
		path.join(SPIRV_TOOLS, "source/instruction.h"),
		path.join(SPIRV_TOOLS, "source/latest_version_glsl_std_450_header.h"),
		path.join(SPIRV_TOOLS, "source/latest_version_opencl_std_header.h"),
		path.join(SPIRV_TOOLS, "source/latest_version_spirv_header.h"),
		path.join(SPIRV_TOOLS, "source/libspirv.cpp"),
		path.join(SPIRV_TOOLS, "source/macro.h"),
		path.join(SPIRV_TOOLS, "source/name_mapper.cpp"),
		path.join(SPIRV_TOOLS, "source/name_mapper.h"),
		path.join(SPIRV_TOOLS, "source/opcode.cpp"),
		path.join(SPIRV_TOOLS, "source/opcode.h"),
		path.join(SPIRV_TOOLS, "source/operand.cpp"),
		path.join(SPIRV_TOOLS, "source/operand.h"),
		path.join(SPIRV_TOOLS, "source/parsed_operand.cpp"),
		path.join(SPIRV_TOOLS, "source/parsed_operand.h"),
		path.join(SPIRV_TOOLS, "source/print.cpp"),
		path.join(SPIRV_TOOLS, "source/print.h"),
		path.join(SPIRV_TOOLS, "source/software_version.cpp"),
		path.join(SPIRV_TOOLS, "source/spirv_constant.h"),
		path.join(SPIRV_TOOLS, "source/spirv_definition.h"),
		path.join(SPIRV_TOOLS, "source/spirv_endian.cpp"),
		path.join(SPIRV_TOOLS, "source/spirv_endian.h"),
		path.join(SPIRV_TOOLS, "source/spirv_optimizer_options.cpp"),
		path.join(SPIRV_TOOLS, "source/spirv_reducer_options.cpp"),
		path.join(SPIRV_TOOLS, "source/spirv_target_env.cpp"),
		path.join(SPIRV_TOOLS, "source/spirv_target_env.h"),
		path.join(SPIRV_TOOLS, "source/spirv_validator_options.cpp"),
		path.join(SPIRV_TOOLS, "source/spirv_validator_options.h"),
		path.join(SPIRV_TOOLS, "source/table.cpp"),
		path.join(SPIRV_TOOLS, "source/table.h"),
		path.join(SPIRV_TOOLS, "source/text.cpp"),
		path.join(SPIRV_TOOLS, "source/text.h"),
		path.join(SPIRV_TOOLS, "source/text_handler.cpp"),
		path.join(SPIRV_TOOLS, "source/text_handler.h"),
		path.join(SPIRV_TOOLS, "source/util/bit_vector.cpp"),
		path.join(SPIRV_TOOLS, "source/util/bit_vector.h"),
		path.join(SPIRV_TOOLS, "source/util/bitutils.h"),
		path.join(SPIRV_TOOLS, "source/util/hex_float.h"),
		path.join(SPIRV_TOOLS, "source/util/parse_number.cpp"),
		path.join(SPIRV_TOOLS, "source/util/parse_number.h"),
		path.join(SPIRV_TOOLS, "source/util/string_utils.cpp"),
		path.join(SPIRV_TOOLS, "source/util/string_utils.h"),
		path.join(SPIRV_TOOLS, "source/util/timer.h"),
	}

	configuration { "vs*" }
		buildoptions {
			"/wd4127", -- warning C4127: conditional expression is constant
			"/wd4267", -- warning C4267: 'argument': conversion from '' to '', possible loss of data
			"/wd4389", -- warning C4389: '==': signed/unsigned mismatch
			"/wd4702", -- warning C4702: unreachable code
			"/wd4706", -- warning C4706: assignment within conditional expression
		}

	configuration { "mingw* or linux* or osx*" }
		buildoptions {
			"-Wno-switch",
		}

	configuration { "mingw* or linux-gcc-*" }
		buildoptions {
			"-Wno-misleading-indentation",
		}

	configuration {}

project "spirv-cross"
	kind "StaticLib"

	defines {
		"SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS",
	}

	includedirs {
		path.join(SPIRV_CROSS, "include"),
	}

	files {
		path.join(SPIRV_CROSS, "spirv.hpp"),
		path.join(SPIRV_CROSS, "spirv_cfg.cpp"),
		path.join(SPIRV_CROSS, "spirv_cfg.hpp"),
		path.join(SPIRV_CROSS, "spirv_common.hpp"),
		path.join(SPIRV_CROSS, "spirv_cpp.cpp"),
		path.join(SPIRV_CROSS, "spirv_cpp.hpp"),
		path.join(SPIRV_CROSS, "spirv_cross.cpp"),
		path.join(SPIRV_CROSS, "spirv_cross.hpp"),
		path.join(SPIRV_CROSS, "spirv_cross_parsed_ir.cpp"),
		path.join(SPIRV_CROSS, "spirv_cross_parsed_ir.hpp"),
		path.join(SPIRV_CROSS, "spirv_cross_util.cpp"),
		path.join(SPIRV_CROSS, "spirv_cross_util.hpp"),
		path.join(SPIRV_CROSS, "spirv_glsl.cpp"),
		path.join(SPIRV_CROSS, "spirv_glsl.hpp"),
		path.join(SPIRV_CROSS, "spirv_hlsl.cpp"),
		path.join(SPIRV_CROSS, "spirv_hlsl.hpp"),
		path.join(SPIRV_CROSS, "spirv_msl.cpp"),
		path.join(SPIRV_CROSS, "spirv_msl.hpp"),
		path.join(SPIRV_CROSS, "spirv_parser.cpp"),
		path.join(SPIRV_CROSS, "spirv_parser.hpp"),
		path.join(SPIRV_CROSS, "spirv_reflect.cpp"),
		path.join(SPIRV_CROSS, "spirv_reflect.hpp"),
	}

	configuration { "vs*" }
		buildoptions {
			"/wd4018", -- warning C4018: '<': signed/unsigned mismatch
			"/wd4245", -- warning C4245: 'return': conversion from 'int' to 'unsigned int', signed/unsigned mismatch
			"/wd4706", -- warning C4706: assignment within conditional expression
			"/wd4715", -- warning C4715: '': not all control paths return a value
		}

	configuration { "mingw* or linux* or osx*" }
		buildoptions {
			"-Wno-type-limits",
		}

	configuration {}

project "glslang"
	kind "StaticLib"

	defines {
		"ENABLE_OPT=1", -- spirv-tools
		"ENABLE_HLSL=1",
	}

	includedirs {
		GLSLANG,
		path.join(GLSLANG, ".."),
		path.join(SPIRV_TOOLS, "include"),
		path.join(SPIRV_TOOLS, "source"),
	}

	files {
		path.join(GLSLANG, "glslang/**.cpp"),
		path.join(GLSLANG, "glslang/**.h"),

		path.join(GLSLANG, "hlsl/**.cpp"),
		path.join(GLSLANG, "hlsl/**.h"),

		path.join(GLSLANG, "SPIRV/**.cpp"),
		path.join(GLSLANG, "SPIRV/**.h"),

		path.join(GLSLANG, "OGLCompilersDLL/**.cpp"),
		path.join(GLSLANG, "OGLCompilersDLL/**.h"),
	}

	configuration { "windows" }
		removefiles {
			path.join(GLSLANG, "glslang/OSDependent/Unix/**.cpp"),
			path.join(GLSLANG, "glslang/OSDependent/Unix/**.h"),
		}

	configuration { "not windows" }
		removefiles {
			path.join(GLSLANG, "glslang/OSDependent/Windows/**.cpp"),
			path.join(GLSLANG, "glslang/OSDependent/Windows/**.h"),
		}

	configuration { "vs*" }
		buildoptions {
			"/wd4005", -- warning C4005: '_CRT_SECURE_NO_WARNINGS': macro redefinition
			"/wd4065", -- warning C4065: switch statement contains 'default' but no 'case' labels
			"/wd4100", -- warning C4100: 'inclusionDepth' : unreferenced formal parameter
			"/wd4127", -- warning C4127: conditional expression is constant
			"/wd4189", -- warning C4189: 'isFloat': local variable is initialized but not referenced
			"/wd4244", -- warning C4244: '=': conversion from 'int' to 'char', possible loss of data
			"/wd4310", -- warning C4310: cast truncates constant value
			"/wd4389", -- warning C4389: '==': signed/unsigned mismatch
			"/wd4456", -- warning C4456: declaration of 'feature' hides previous local declaration
			"/wd4457", -- warning C4457: declaration of 'token' hides function parameter
			"/wd4458", -- warning C4458: declaration of 'language' hides class member
			"/wd4702", -- warning C4702: unreachable code
			"/wd4715", -- warning C4715: 'spv::Builder::makeFpConstant': not all control paths return a value
			"/wd4838", -- warning C4838: conversion from 'spv::GroupOperation' to 'unsigned int' requires a narrowing conversion
		}

	configuration { "mingw-gcc or linux-gcc" }
		buildoptions {
			"-Wno-logical-op",
			"-Wno-maybe-uninitialized",
		}

	configuration { "mingw* or linux* or osx*" }
		buildoptions {
			"-fno-strict-aliasing", -- glslang has bugs if strict aliasing is used.
			"-Wno-ignored-qualifiers",
			"-Wno-implicit-fallthrough",
			"-Wno-missing-field-initializers",
			"-Wno-reorder",
			"-Wno-return-type",
			"-Wno-shadow",
			"-Wno-sign-compare",
			"-Wno-switch",
			"-Wno-undef",
			"-Wno-unknown-pragmas",
			"-Wno-unused-function",
			"-Wno-unused-parameter",
			"-Wno-unused-variable",
		}

	configuration { "osx*" }
		buildoptions {
			"-Wno-c++11-extensions",
			"-Wno-unused-const-variable",
			"-Wno-deprecated-register",
		}

	configuration { "linux-gcc-*" }
		buildoptions {
			"-Wno-unused-but-set-variable",
		}

	configuration {}

project "glsl-optimizer"
	kind "StaticLib"

	includedirs {
		path.join(GLSL_OPTIMIZER, "src"),
		path.join(GLSL_OPTIMIZER, "include"),
		path.join(GLSL_OPTIMIZER, "src/mesa"),
		path.join(GLSL_OPTIMIZER, "src/mapi"),
		path.join(GLSL_OPTIMIZER, "src/glsl"),
	}

	files {
		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp-lex.c"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp-parse.c"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp-parse.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/pp.c"),

		path.join(GLSL_OPTIMIZER, "src/glsl/ast.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ast_array_index.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ast_expr.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ast_function.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ast_to_hir.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ast_type.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/builtin_functions.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/builtin_type_macros.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/builtin_types.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/builtin_variables.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_lexer.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_optimizer.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_optimizer.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_parser.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_parser.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_parser_extras.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_parser_extras.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_symbol_table.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_symbol_table.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_types.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glsl_types.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/hir_field_selection.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_basic_block.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_basic_block.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_builder.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_builder.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_clone.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_constant_expression.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_equals.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_expression_flattening.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_expression_flattening.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_function.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_function_can_inline.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_function_detect_recursion.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_function_inlining.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_hierarchical_visitor.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_hierarchical_visitor.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_hv_accept.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_import_prototypes.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_optimization.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_glsl_visitor.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_glsl_visitor.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_metal_visitor.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_metal_visitor.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_visitor.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_print_visitor.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_rvalue_visitor.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_rvalue_visitor.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_stats.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_stats.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_uniform.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_unused_structs.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_unused_structs.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_validate.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_variable_refcount.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_variable_refcount.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_visitor.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_atomics.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_functions.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_interface_blocks.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_uniform_block_active_visitor.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_uniform_block_active_visitor.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_uniform_blocks.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_uniform_initializers.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_uniforms.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_varyings.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/link_varyings.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/linker.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/linker.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/list.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/loop_analysis.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/loop_analysis.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/loop_controls.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/loop_unroll.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_clip_distance.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_discard.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_discard_flow.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_if_to_cond_assign.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_instructions.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_jumps.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_mat_op_to_vec.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_named_interface_blocks.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_noise.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_offset_array.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_output_reads.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_packed_varyings.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_packing_builtins.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_ubo_reference.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_variable_index_to_cond_assign.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_vec_index_to_cond_assign.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_vec_index_to_swizzle.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_vector.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_vector_insert.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/lower_vertex_id.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_algebraic.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_array_splitting.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_constant_folding.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_constant_propagation.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_constant_variable.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_copy_propagation.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_copy_propagation_elements.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_cse.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_builtin_variables.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_builtin_varyings.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_code.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_code_local.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_dead_functions.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_flatten_nested_if_blocks.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_flip_matrices.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_function_inlining.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_if_simplification.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_minmax.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_noop_swizzle.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_rebalance_tree.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_redundant_jumps.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_structure_splitting.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_swizzle_swizzle.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_tree_grafting.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/opt_vectorize.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/program.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/s_expression.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/s_expression.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/standalone_scaffolding.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/standalone_scaffolding.h"),
		path.join(GLSL_OPTIMIZER, "src/glsl/strtod.c"),
		path.join(GLSL_OPTIMIZER, "src/glsl/strtod.h"),

		path.join(GLSL_OPTIMIZER, "src/mesa/main/compiler.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/config.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/context.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/core.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/dd.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/errors.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/glheader.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/glminimal.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/imports.c"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/imports.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/macros.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/mtypes.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/main/simple_list.h"),

		path.join(GLSL_OPTIMIZER, "src/mesa/program/hash_table.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/program/prog_hash_table.c"),
		path.join(GLSL_OPTIMIZER, "src/mesa/program/prog_instruction.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/program/prog_parameter.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/program/prog_statevars.h"),
		path.join(GLSL_OPTIMIZER, "src/mesa/program/symbol_table.c"),
		path.join(GLSL_OPTIMIZER, "src/mesa/program/symbol_table.h"),

		path.join(GLSL_OPTIMIZER, "src/util/hash_table.c"),
		path.join(GLSL_OPTIMIZER, "src/util/hash_table.h"),
		path.join(GLSL_OPTIMIZER, "src/util/macros.h"),
		path.join(GLSL_OPTIMIZER, "src/util/ralloc.c"),
		path.join(GLSL_OPTIMIZER, "src/util/ralloc.h"),
	}

	removefiles {
		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.c"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/tests/**"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.l"),
		path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.y"),
		path.join(GLSL_OPTIMIZER, "src/glsl/ir_set_program_inouts.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/main.cpp"),
		path.join(GLSL_OPTIMIZER, "src/glsl/builtin_stubs.cpp"),
	}

	configuration { "Release" }
		flags {
			"Optimize",
		}

		removeflags {
			-- GCC 4.9 -O2 + -fno-strict-aliasing don't work together...
			"OptimizeSpeed",
		}

	configuration { "vs*" }
		includedirs {
			path.join(GLSL_OPTIMIZER, "src/glsl/msvc"),
		}

		defines { -- glsl-optimizer
			"__STDC__",
			"__STDC_VERSION__=199901L",
			"strdup=_strdup",
			"alloca=_alloca",
			"isascii=__isascii",
		}

		buildoptions {
			"/wd4100", -- error C4100: '' : unreferenced formal parameter
			"/wd4127", -- warning C4127: conditional expression is constant
			"/wd4132", -- warning C4132: 'deleted_key_value': const object should be initialized
			"/wd4189", -- warning C4189: 'interface_type': local variable is initialized but not referenced
			"/wd4204", -- warning C4204: nonstandard extension used: non-constant aggregate initializer
			"/wd4244", -- warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data
			"/wd4389", -- warning C4389: '!=': signed/unsigned mismatch
			"/wd4245", -- warning C4245: 'return': conversion from 'int' to 'unsigned int', signed/unsigned mismatch
			"/wd4701", -- warning C4701: potentially uninitialized local variable 'lower' used
			"/wd4702", -- warning C4702: unreachable code
			"/wd4706", -- warning C4706: assignment within conditional expression
			"/wd4996", -- warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup.
		}

	configuration { "mingw* or linux* or osx*" }
		buildoptions {
			"-fno-strict-aliasing", -- glsl-optimizer has bugs if strict aliasing is used.

			"-Wno-implicit-fallthrough",
			"-Wno-parentheses",
			"-Wno-sign-compare",
			"-Wno-unused-function",
			"-Wno-unused-parameter",
		}

		removebuildoptions {
			"-Wshadow", -- glsl-optimizer is full of -Wshadow warnings ignore it.
		}

	configuration { "osx*" }
		buildoptions {
			"-Wno-deprecated-register",
		}

	configuration { "mingw* or linux-gcc-*" }
		buildoptions {
			"-Wno-misleading-indentation",
		}

	configuration {}

project "fcpp"
	kind "StaticLib"

	defines { -- fcpp
		"NINCLUDE=64",
		"NWORK=65536",
		"NBUFF=65536",
		"OLD_PREPROCESSOR=0",
--		"MSG_PREFIX=\"Preprocessor: \"",
	}

	files {
		path.join(FCPP_DIR, "**.h"),
		path.join(FCPP_DIR, "cpp1.c"),
		path.join(FCPP_DIR, "cpp2.c"),
		path.join(FCPP_DIR, "cpp3.c"),
		path.join(FCPP_DIR, "cpp4.c"),
		path.join(FCPP_DIR, "cpp5.c"),
		path.join(FCPP_DIR, "cpp6.c"),
		path.join(FCPP_DIR, "cpp6.c"),
	}

	configuration { "vs*" }

		buildoptions {
			"/wd4055", -- warning C4055: 'type cast': from data pointer 'void *' to function pointer 'void (__cdecl *)(char *,void *)'
			"/wd4244", -- warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data
			"/wd4701", -- warning C4701: potentially uninitialized local variable 'lower' used
			"/wd4706", -- warning C4706: assignment within conditional expression
		}

	configuration { "not vs*" }
		buildoptions {
			"-Wno-implicit-fallthrough",
			"-Wno-incompatible-pointer-types",
			"-Wno-parentheses-equality",
		}

	configuration {}

project "shaderc"
	kind "ConsoleApp"

	includedirs {
		path.join(BIMG_DIR, "include"),
		path.join(BGFX_DIR, "include"),

		path.join(BGFX_DIR, "3rdparty/webgpu/include"),
		path.join(BGFX_DIR, "3rdparty/dxsdk/include"),

		FCPP_DIR,

		path.join(BGFX_DIR, "3rdparty/glslang/glslang/Public"),
		path.join(BGFX_DIR, "3rdparty/glslang/glslang/Include"),
		path.join(BGFX_DIR, "3rdparty/glslang"),

		path.join(GLSL_OPTIMIZER, "include"),
		path.join(GLSL_OPTIMIZER, "src/glsl"),

		SPIRV_CROSS,

		path.join(SPIRV_TOOLS, "include"),
	}

	links {
		"fcpp",
		"glslang",
		"glsl-optimizer",
		"spirv-opt",
		"spirv-cross",
	}

	using_bx()

	files {
		path.join(BGFX_DIR, "tools/shaderc/**.cpp"),
		path.join(BGFX_DIR, "tools/shaderc/**.h"),
		path.join(BGFX_DIR, "src/vertexlayout.**"),
		path.join(BGFX_DIR, "src/shader**"),
	}

	configuration { "mingw-*" }
		targetextension ".exe"

	configuration { "osx*" }
		links {
			"Cocoa.framework",
		}

	configuration { "vs*" }
		includedirs {
			path.join(GLSL_OPTIMIZER, "include/c99"),
		}

	configuration { "vs20* or mingw*" }
		links {
			"psapi",
		}

	configuration { "osx* or linux*" }
		links {
			"pthread",
		}

	configuration {}

	if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-gnm"), {
		path.join(BGFX_DIR, "scripts/shaderc.lua"), }) then

		if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-gnm"), {
			path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"), }) then

			removefiles {
				path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"),
			}
		end

		dofile(path.join(BGFX_DIR, "../bgfx-gnm/scripts/shaderc.lua") )
	end

	strip()

group "tools"