diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-06-24 16:08:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-24 16:08:08 -0400 |
| commit | f1b41a71be938b8711ee0fff0130185f512d2336 (patch) | |
| tree | 29ad602a61968e1aacdf8424afc0c89defdb4330 /source/compiler-core/slang-downstream-compiler.cpp | |
| parent | c12c0ad7fbb0272283f224493dbc28d9d60e7b91 (diff) | |
Handling of temporary files (#2299)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Work around windows issue with temporary file clash.
* Handle the temporary file path actually creates a file.
* Fix typo.
* Fix typo in linux for temporary file.
* Add unit test for io. Tests generateTemporary operation.
Diffstat (limited to 'source/compiler-core/slang-downstream-compiler.cpp')
| -rw-r--r-- | source/compiler-core/slang-downstream-compiler.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source/compiler-core/slang-downstream-compiler.cpp b/source/compiler-core/slang-downstream-compiler.cpp index 5011b42a0..85726557e 100644 --- a/source/compiler-core/slang-downstream-compiler.cpp +++ b/source/compiler-core/slang-downstream-compiler.cpp @@ -428,6 +428,7 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio // Find all the files that will be produced RefPtr<TemporaryFileSet> productFileSet(new TemporaryFileSet); + if (options.modulePath.getLength() == 0 || options.sourceContents.getLength() != 0) { String modulePath = options.modulePath; @@ -435,7 +436,15 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio // If there is no module path, generate one. if (modulePath.getLength() == 0) { - SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice::fromLiteral("slang-generated"), modulePath)); + // Holds the temporary lock path, if a temporary path is used + String temporaryLockPath; + + // Generate a unique module path name + SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice::fromLiteral("slang-generated"), temporaryLockPath)); + productFileSet->add(temporaryLockPath); + + modulePath = temporaryLockPath; + options.modulePath = modulePath; } @@ -511,7 +520,6 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio DownstreamDiagnostics diagnostics; SLANG_RETURN_ON_FAIL(parseOutput(exeRes, diagnostics)); - out = new CommandLineDownstreamCompileResult(diagnostics, moduleFilePath, productFileSet); return SLANG_OK; |
