diff --git a/meson.build b/meson.build index badb606..df28c81 100644 --- a/meson.build +++ b/meson.build @@ -113,7 +113,7 @@ else shader_generator_deps = [glslc_tgt] endif -spv_compile_script = [meson.project_source_root() + '/scripts/compile_shader.py', '--glslc_path', glslc_path, '@EXTRA_ARGS@'] +spv_compile_script = [meson.project_source_root() + '/scripts/compile_shader.py', '--glslc_path', glslc_path] glslc_args = ['--target-env', 'vulkan1.3'] glslc_args += ['-I' + meson.project_source_root()] glslc_args += ['-I' + join_paths(project_root, 'src')] @@ -125,7 +125,7 @@ shader_generator = generator( py, output: ['@PLAINNAME@.spv.h', '@PLAINNAME@.spv.c'], depfile: '@PLAINNAME@.d', - arguments: spv_compile_script + ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@'] + glslc_args, + arguments: spv_compile_script + ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@'] + glslc_args + ['@EXTRA_ARGS@'], depends: shader_generator_deps ) diff --git a/scripts/compile_shader.py b/scripts/compile_shader.py index a4a3363..c08e0c6 100644 --- a/scripts/compile_shader.py +++ b/scripts/compile_shader.py @@ -61,10 +61,10 @@ def main(): parser.add_argument("shader_path", type=Path) parser.add_argument("header_path", type=Path) parser.add_argument("implementation_path", type=Path) - parser.add_argument("glslc_args", nargs=argparse.REMAINDER) - args = parser.parse_args() + args, glslc_args = parser.parse_known_args() if args.debug: print(args) + print(f"glslc args: {glslc_args}") print(f"cwd {os.getcwd()}") shader_name = re.sub( @@ -96,7 +96,7 @@ def main(): print(f"wrote header to {args.header_path}") spv = compile_shader( - args.glslc_path, args.shader_path, args.glslc_args, args.optimize + args.glslc_path, args.shader_path, glslc_args, args.optimize ) implementation = """\ #include "stdint.h" @@ -124,8 +124,8 @@ def main(): if args.debug: print(f"wrote implementation to {args.implementation_path}") - if "--depfile" in args.glslc_args: - depfile_path = args.glslc_args[args.glslc_args.index("--depfile") + 1] + if "--depfile" in glslc_args: + depfile_path = glslc_args[glslc_args.index("--depfile") + 1] if args.debug: print(f"fixup depfile {depfile_path}") with open(depfile_path, "r") as f: