Motivation
I'm trying to integrate glslValidator into my build system for verifying shaders at compile time. The catch is that I'm using it as a validator (rather than compiler into SPIR-V), so its purpose is to simply exit successfully rather than produce any output files. This makes it apparently impossible to integrate well into meson right now:
shader_validation = custom_target(
'shader_validation',
output: 'shader_validation.txt',
input: shader_files,
command: [glslangValidator, '-t', '@INPUT@'],
#capture: true,
build_by_default: true, # I want to run it as part of a standard build to check for errors
)
This makes it re-run validator on every build since output file doesn't get created. Uncommenting capture: true fixes this particular problem (so glslangValidator is only invoked when I edit shaders), but instead leads to an even worse one: in case of an error stdout with errors gets lost, leaving me without vital information to diagnose the problem.
While my personal issue is specifically with glslangValidator, I imagine it would be pretty much the same with any other validator program out there.
Suggestion
Add a boolean keyword argument touch_output_files to custom_target that makes Meson create/update timestamp on output files after command successfully exits (much like touch).
Current workarounds
While a little messy, this does the job:
if (glslangValidator.found())
touch = find_program('touch', required: true, native: true)
endif
shader_validation = custom_target(
'shader_validation',
output: 'shader_validation.txt',
input: shader_files,
command: [glslangValidator, '-t', '@INPUT@'],
console: true,
)
custom_target(
'shader_validation_toucher',
output: 'shader_validation2.txt',
depends: [shader_validation],
command: [touch, 'shader_validation.txt', 'shader_validation2.txt'],
build_by_default: true,
)
Nothing is done if shader files weren't modified and validator runs with proper stdout as well (console: true is not required, but is apparently nice to have).
Another, simpler but subopimal option, is to pass -E to glslangValidator and set capture: true, which causes it to print errors to stderr (which is dumped into console) and output preprocessed GLSL to stdout (which meson redirects to output file):
shader_validation = custom_target(
'shader_validation',
output: 'shader_validation.txt',
input: shader_files,
command: [glslangValidator, '-t', '-E', '@INPUT@'],
build_by_default: true,
capture: true,
)
Obviously, this forces glslValidator to do somewhat more work than actually needed, so it's still less than ideal. Additionally, option like this might as well be missing on other validators out there.
Motivation
I'm trying to integrate
glslValidatorinto my build system for verifying shaders at compile time. The catch is that I'm using it as a validator (rather than compiler into SPIR-V), so its purpose is to simply exit successfully rather than produce any output files. This makes it apparently impossible to integrate well into meson right now:This makes it re-run validator on every build since output file doesn't get created. Uncommenting
capture: truefixes this particular problem (so glslangValidator is only invoked when I edit shaders), but instead leads to an even worse one: in case of an error stdout with errors gets lost, leaving me without vital information to diagnose the problem.While my personal issue is specifically with
glslangValidator, I imagine it would be pretty much the same with any other validator program out there.Suggestion
Add a boolean keyword argument
touch_output_filestocustom_targetthat makes Meson create/update timestamp on output files after command successfully exits (much liketouch).Current workarounds
While a little messy, this does the job:
Nothing is done if shader files weren't modified and validator runs with proper stdout as well (
console: trueis not required, but is apparently nice to have).Another, simpler but subopimal option, is to pass
-EtoglslangValidatorand setcapture: true, which causes it to print errors to stderr (which is dumped into console) and output preprocessed GLSL to stdout (which meson redirects to output file):Obviously, this forces
glslValidatorto do somewhat more work than actually needed, so it's still less than ideal. Additionally, option like this might as well be missing on other validators out there.