summaryrefslogtreecommitdiff
path: root/source/slang/slang-options.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-04-15 15:46:45 -0400
committerGitHub <noreply@github.com>2022-04-15 15:46:45 -0400
commitd939773a9127bccbbd22903eb5b5620ad7127d37 (patch)
treec9610f4891ba99f70bb5493ebca2daf16da88722 /source/slang/slang-options.cpp
parentac81614974700806e8257b8483a0ba97b925971a (diff)
DXIL library support and Artifact type (#2186)
* #include an absolute path didn't work - because paths were taken to always be relative. * Compile to a dxil library. * Added CompileProduct. * Support handling of ModuleLibrary. * CacheBehavior -> Cache * Use CompileProduct for -r references. * CompileProduct -> Artifact. * Determining an artifact type on binding. * Determine binary linkability. * Added Artifact::exists. * Added ArtifactKeep. * Small fixes. * Small improvements to Artifact. * Add zip extension. * Fix some comments.
Diffstat (limited to 'source/slang/slang-options.cpp')
-rw-r--r--source/slang/slang-options.cpp42
1 files changed, 36 insertions, 6 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 982066a33..d4199154f 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -9,6 +9,7 @@
#include "slang-compiler.h"
#include "slang-profile.h"
+#include "slang-artifact.h"
#include "slang-repro.h"
#include "slang-serialize-ir.h"
@@ -23,7 +24,7 @@
namespace Slang {
-SlangResult _addLibraryReference(EndToEndCompileRequest* req, Stream* stream);
+SlangResult _addLibraryReference(EndToEndCompileRequest* req, Artifact* artifact);
struct OptionsParser
{
@@ -1398,13 +1399,39 @@ struct OptionsParser
CommandLineArg referenceModuleName;
SLANG_RETURN_ON_FAIL(reader.expectArg(referenceModuleName));
- // We need to deserialize and add the modules
- FileStream fileStream;
- SLANG_RETURN_ON_FAIL(fileStream.init(referenceModuleName.value, FileMode::Open, FileAccess::Read, FileShare::ReadWrite));
+ auto path = referenceModuleName.value;
- // TODO: probably near an error when we can't open the file?
+ auto desc = ArtifactDesc::fromPath(path.getUnownedSlice());
- _addLibraryReference(requestImpl, &fileStream);
+ if (desc.kind == ArtifactKind::Unknown)
+ {
+ sink->diagnose(referenceModuleName.loc, Diagnostics::unknownLibraryKind, Path::getPathExt(path));
+ return SLANG_FAIL;
+ }
+
+ // If it's a GPU binary, then we'll assume it's a library
+ if (desc.isGpuBinary())
+ {
+ desc.kind = ArtifactKind::Library;
+ }
+
+ if (!desc.isBinaryLinkable())
+ {
+ sink->diagnose(referenceModuleName.loc, Diagnostics::kindNotLinkable, Path::getPathExt(path));
+ return SLANG_FAIL;
+ }
+
+ // Create the artifact
+ RefPtr<Artifact> artifact = new Artifact(desc);
+ // Set the path
+ artifact->setPath(Artifact::PathType::Existing, referenceModuleName.value);
+
+ // TODO(JS): We might want to check if the artifact exists.
+ // If the artifact is a CPU (or downstream compiler) library
+ // it may be findable by some other mechanism, so we probably don't want to check existance and just let the
+ // downstream compiler handle.
+
+ SLANG_RETURN_ON_FAIL(_addLibraryReference(requestImpl, artifact));
}
else if (argValue == "-v" || argValue == "-version")
{
@@ -1991,6 +2018,9 @@ struct OptionsParser
case CodeGenTarget::ShaderHostCallable:
case CodeGenTarget::HostExecutable:
case CodeGenTarget::ShaderSharedLibrary:
+
+ case CodeGenTarget::DXIL:
+
rawOutput.isWholeProgram = true;
break;
default: