summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-visual-studio-compiler-util.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-04-26 12:43:28 -0400
committerGitHub <noreply@github.com>2022-04-26 12:43:28 -0400
commitf9432467cac85eae6f7120cd94208f3a3dd9aa19 (patch)
tree1370c70a0159a1f8dd89cc8c86db930f556bdc5d /source/compiler-core/slang-visual-studio-compiler-util.cpp
parent79dd12c21e8f5c5ce01051a280679cf6ac8ffe97 (diff)
Improvements around Artifacts (#2192)
* #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. * Fix multiple adding of PublicDecoration. Make public output export for DXIL/lib. Add checking for simpleDecorations such that only added once. * Use 'whole program' to identify library build. * Move slang-artifact into compiler-core. * Split out Keep free functions. * Artifact::Keep -> ArtifactKeep. * Handle libraries as artifacts. * Add -target dxil so test infrastructure knows it needs DXC. * Linking working in DXC. * Improve handling around emit for 'export'. * Add comment around Artifact name. * Render test working with linking. * Improvements around Artifact handling.
Diffstat (limited to 'source/compiler-core/slang-visual-studio-compiler-util.cpp')
-rw-r--r--source/compiler-core/slang-visual-studio-compiler-util.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/source/compiler-core/slang-visual-studio-compiler-util.cpp b/source/compiler-core/slang-visual-studio-compiler-util.cpp
index df64ed821..0552657f8 100644
--- a/source/compiler-core/slang-visual-studio-compiler-util.cpp
+++ b/source/compiler-core/slang-visual-studio-compiler-util.cpp
@@ -4,6 +4,7 @@
#include "../core/slang-common.h"
#include "../../slang-com-helper.h"
#include "../core/slang-string-util.h"
+#include "../core/slang-string-slice-pool.h"
// if Visual Studio import the visual studio platform specific header
#if SLANG_VC
@@ -250,28 +251,36 @@ namespace Slang
// Link options (parameters past /link go to linker)
cmdLine.addArg("/link");
+ StringSlicePool libPathPool(StringSlicePool::Style::Default);
+
for (const auto& libPath : options.libraryPaths)
{
- // Note that any escaping of the path is handled in the ProcessUtil::
- cmdLine.addPrefixPathArg("/LIBPATH:", libPath);
+ libPathPool.add(libPath);
}
// Link libraries.
for (Artifact* artifact : options.libraries)
{
- if (artifact->getDesc().isCpuBinary())
+ auto desc = artifact->getDesc();
+
+ if (desc.isCpuBinary() && desc.kind == ArtifactKind::Library)
{
- String path;
- SLANG_RETURN_ON_FAIL(artifact->requireFilePath(ArtifactKeep::No, path));
+ // Get the libray name and path
+ SLANG_RETURN_ON_FAIL(artifact->requireFileLike(ArtifactKeep::No));
- if (Path::getPathExt(path).getLength() == 0)
- {
- path.append(".lib");
- }
- cmdLine.addArg(path);
+ libPathPool.add(artifact->getParentPath());
+ // We need the extension for windows
+ cmdLine.addArg(artifact->getBaseName() + ".lib");
}
}
+ // Add all the library paths
+ for (const auto& libPath : libPathPool.getAdded())
+ {
+ // Note that any escaping of the path is handled in the ProcessUtil::
+ cmdLine.addPrefixPathArg("/LIBPATH:", libPath);
+ }
+
return SLANG_OK;
}