From 467fa3a5dcdd36e310b084747d6f4fcd6ca81249 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 20 Apr 2023 11:55:26 -0400 Subject: Improvements outputting containers (#2815) * #include an absolute path didn't work - because paths were taken to always be relative. * Moved JSON source map writing logic to JSONSourceMapUtil. * Use ArtifactHandler to read/write SourceMaps. Use ObjectCastableAdapter to hold SourceMap Only serialize SourceMap <-> JSON on demand. * Make some types swappable. * BoxValue impl. * Added asBoxValue. * Remove const get funcs. * Fix typo in asBoxValue. * Fix another typo in asBoxValue. * Slightly simplify conversion to blob of SourceMap. * WIP Api improvements around sourcemap/artifact/line-directive. * Small fix for asBoxValue * WIP outputting container with multiple artifacts. * Added ArtifactContailerUtil::filter to produce an artifact hierarchy that only contains "signficant" and "blobable" artifacts. * Make emitting IR disjoint to using a container. Added -emit-ir option. Simplfiy output. * Fix typo in options parsing. * Add a test that ouputs with an emit source map. * Enable emitting our SlangIR module if no targets are specified. * Fix issues constructing container. * Extra checks getting obfuscated source map from a translation unit. * Fix typo. --- source/slang/slang.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 6b2814ca7..637b22090 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -4887,8 +4887,16 @@ SlangResult _addLibraryReference(EndToEndCompileRequest* req, IArtifact* artifac auto sourceMap = asBoxValue(castable); SLANG_ASSERT(sourceMap); - // I guess we add to all ir modules? - + // TODO(JS): + // There is perhaps (?) a risk here that we might copy the obfuscated map + // into some output container. Currently that only happens for source maps + // that are from translation units. + // + // On the other hand using "import" is a way that such source maps *would* be + // copied into the output, and that is something that could be a vector + // for leaking. + // + // That isn't a risk from -r though because, it doesn't create a translation unit(s). for (auto irModule : library->m_modules) { irModule->setObfuscatedSourceMap(sourceMap); @@ -5316,9 +5324,15 @@ ISlangMutableFileSystem* EndToEndCompileRequest::getCompileRequestResultAsFileSy if (m_containerArtifact) { ComPtr fileSystem(new MemoryFileSystem); - if (SLANG_SUCCEEDED(ArtifactContainerUtil::writeContainer(m_containerArtifact, "", fileSystem))) + + // Filter the containerArtifact into things that can be written + ComPtr writeArtifact; + if (SLANG_SUCCEEDED(ArtifactContainerUtil::filter(m_containerArtifact, writeArtifact))) { - m_containerFileSystem.swap(fileSystem); + if (SLANG_SUCCEEDED(ArtifactContainerUtil::writeContainer(writeArtifact, "", fileSystem))) + { + m_containerFileSystem.swap(fileSystem); + } } } } -- cgit v1.2.3