From 7e51180ed80ce1c5718b65c6625dc12fe64c8bfa Mon Sep 17 00:00:00 2001 From: tareksander <57038324+tareksander@users.noreply.github.com> Date: Mon, 11 Nov 2024 20:32:00 +0100 Subject: Reflection compiler option (#5507) * Moved the pretty writer code from slang-reflection-test into core * Moved reflection test code into the slang codebase and added the compiler option -reflection-json to store the reflection data in a separate file. * Documented -reflection-json command line option * moved PrettyWriter from core to compiler-core * Fixed variable shadowing warning * Use File::writeAllText instead of OSFilesystem and write to stdout if - is used as the path * format code * Fixed linker error * Fix COM Ptr life time issues. * Move enum to the end. * Fix formatting. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He --- source/slang/slang-options.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/slang/slang-options.cpp') diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 9353acd35..681999168 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -524,8 +524,13 @@ void initCommandOptions(CommandOptions& options) nullptr, "Preserve all resource parameters in the output code, even if they are not used by the " "shader."}, + {OptionKind::EmitReflectionJSON, + "-reflection-json", + "reflection-json ", + "Emit reflection data in JSON format to a file."}, }; + _addOptions(makeConstArrayView(generalOpts), options); /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Target !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ @@ -2663,6 +2668,14 @@ SlangResult OptionsParser::_parse(int argc, char const* const* argv) addOutputPath(outputPath.value.getBuffer()); break; } + case OptionKind::EmitReflectionJSON: + { + CommandLineArg outputPath; + SLANG_RETURN_ON_FAIL(m_reader.expectArg(outputPath)); + + linkage->m_optionSet.set(CompilerOptionName::EmitReflectionJSON, outputPath.value); + break; + } case OptionKind::DepFile: { CommandLineArg dependencyPath; -- cgit v1.2.3