From 172538fdb418f7a2faab1f5a410f3b2cb8e18ba5 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 21 May 2021 18:41:54 -0400 Subject: Downstream option handling (#1850) * #include an absolute path didn't work - because paths were taken to always be relative. * Added SourceLoc handling for command line parsing. * Fix typo in debug. * Fix issue around the DiagnosticSink used in options parsing not having a writer available - by having DiagnosticSink parenting. * Small rename for clarity. * WIP extracting command line args for downstream tools. * Unit tests/bug fixes around extracting args. * Use DownstreamArgs in the EndToEndCompileRequest * Passing downstream compiler options downstream. * Fix issue with endToEndReq being nullptr. * Fix issue with diagnostics number change. * Small improvements to how the source line is displayed if it's too long. Default to 120, as suggested in previous review. Co-authored-by: T. Foley --- source/slang/slang-compiler.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/slang/slang-compiler.cpp') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 3850615b4..31ead4cc3 100755 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -964,6 +964,23 @@ namespace Slang typedef DownstreamCompiler::CompileOptions CompileOptions; CompileOptions options; + /* Let's set the compiler specific options + + We can only do this if the endToEndReq is set. */ + if (endToEndReq) + { + auto name = TypeTextUtil::getPassThroughName((SlangPassThrough)downstreamCompiler); + const Index nameIndex = endToEndReq->m_downstreamArgs.findName(name); + if (nameIndex >= 0) + { + auto& args = endToEndReq->m_downstreamArgs.getArgsAt(nameIndex); + for (const auto& arg : args.m_args) + { + options.compilerSpecificArguments.add(arg.value); + } + } + } + /* This is more convoluted than the other scenarios, because when we invoke C/C++ compiler we would ideally like to use the original file. We want to do this because we want includes relative to the source file to work, and for that to work most easily we want to use the original file, if there is one */ -- cgit v1.2.3