enh(ci): allow to ignore certain preprocessor define directive when attempting to compile shaders
requested to merge 74-enh-ci-allow-to-ignore-certain-preprocessor-define-directive-when-attempting-to-compile-shaders into dev
Description
It is now possible to add inline comments in shaders to avoid attempting to compile with exclusive #define combinations
or with #define
s internal to the shader.
The syntax is as such:
// sheldon:glslang discard-define(do_foo, do_bar)
// sheldon:glslang require-exclusive(SIGHT_OPTION_A, SIGHT_OPTION_B, SIGHT_OPTION_C)
// Spaces don't matter, the following also work (though I would question the readability of the second one)
// sheldon: glslang discard-define(do_hug, do_zog)
// sheldon : glslang require-exclusive(SIGHT_OPTION_D, SIGHT_OPTION_E)
Source files with .vert.glsl
/ .frag.glsl
& co. are now also supported and are now longer compiled as fragment shaders.
Closes #74 (closed)
How to test it?
- Trust the CI (I added a test)
If you want to test it in your shaders, you may follow the following plan:
- Create a shader with something like this:
#if defined(SIGHT_PATH_A)
#if defined(SIGHT_PATH_B)
#error Invalid configuration. Expected at most one of SIGHT_PATH_A, SIGHT_PATH_B.
#endif
#elif defined(SIGHT_PATH_B)
#if defined(SIGHT_PATH_A)
#error Invalid configuration. Expected at most one of SIGHT_PATH_A, SIGHT_PATH_B.
#endif
#else
#error Missing preprocessor define. Expected SIGHT_PATH_A or SIGHT_PATH_B.
#endif
#if defined(SIGHT_DO_FOO)
#error Should not be defined.
#endif
#if defined(SIGHT_DO_BAR)
#error Should not be defined.
#endif
#define SIGHT_DO_FOO
#define SIGHT_DO_BAR
- Confirm
sheldon
glslang hook refuses it. - Add
// sheldon: glslang require-exclusive(SIGHT_PATH_A, SIGHT_PATH_B)
- Add
// sheldon: glslang discard-define(SIGHT_DO_FOO, SIGHT_DO_BAR)
- Confirm the shader is accepted (provided you wrote something correct without this of course)
Edited by Erwan DUHAMEL