From cae56127251b4766f686c2ec6d4672da3ded160f Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 8 Oct 2019 09:37:46 -0400 Subject: Make CPU/C++ generate a single temporary file name basis that used for both source (if source isn't available as a file) and binaries. (#1070) --- source/slang/slang-compiler.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index a24289d22..c8cc947f4 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -1336,14 +1336,20 @@ SlangResult dissassembleDXILUsingDXC( rawSourceLanguage = SourceLanguage::CPP; } - List tempFiles; + // Generate a path a temporary filename for output module + String modulePath; + SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice::fromLiteral("slang-generated"), modulePath)); if (!useOriginalFile) { - SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice::fromLiteral("slang-generated"), compileSourcePath)); + // We need to create a new file which has the source. We'll use the module generated name as the basis + compileSourcePath = modulePath; + + // NOTE: Strictly speaking producing filenames by modifying the generateTemporary path that may introduce a temp filename clash, but in practice is extraordinary unlikely + + compileSourcePath.append("-src"); // Make the temporary filename have the appropriate extension. - // NOTE: Strictly speaking that may introduce a temp filename clash, but in practice is extraordinary unlikely if (rawSourceLanguage == SourceLanguage::C) { compileSourcePath.append(".c"); @@ -1376,10 +1382,6 @@ SlangResult dissassembleDXILUsingDXC( // Disable exceptions and security checks options.flags &= ~(CompileOptions::Flag::EnableExceptionHandling | CompileOptions::Flag::EnableSecurityChecks); - // Generate a path a temporary filename for output module - String modulePath; - SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice::fromLiteral("slang-generated"), modulePath)); - // Remove the temporary path/file when done temporaryFileSet.add(modulePath); -- cgit v1.2.3