diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-04-26 12:43:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-26 12:43:28 -0400 |
| commit | f9432467cac85eae6f7120cd94208f3a3dd9aa19 (patch) | |
| tree | 1370c70a0159a1f8dd89cc8c86db930f556bdc5d /source/compiler-core/slang-gcc-compiler-util.cpp | |
| parent | 79dd12c21e8f5c5ce01051a280679cf6ac8ffe97 (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-gcc-compiler-util.cpp')
| -rw-r--r-- | source/compiler-core/slang-gcc-compiler-util.cpp | 71 |
1 files changed, 22 insertions, 49 deletions
diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp index 7d1b7b86a..2d1ad2555 100644 --- a/source/compiler-core/slang-gcc-compiler-util.cpp +++ b/source/compiler-core/slang-gcc-compiler-util.cpp @@ -8,6 +8,7 @@ #include "../core/slang-io.h" #include "../core/slang-shared-library.h" #include "../core/slang-char-util.h" +#include "../core/slang-string-slice-pool.h" namespace Slang { @@ -620,65 +621,28 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse } // Add the library paths - List<String> libraryPaths; - libraryPaths.addRange(options.libraryPaths.getBuffer(), options.libraryPaths.getCount()); + StringSlicePool libPathPool(StringSlicePool::Style::Default); + + for (const auto& libPath : options.libraryPaths) + { + libPathPool.add(libPath); + } // Artifacts might add library paths for (Artifact* artifact : options.libraries) { const auto desc = artifact->getDesc(); // If it's a library for CPU types, try and use it - if (desc.isCpuBinary()) - { - if (desc.kind == ArtifactKind::Library) - { - String path; - SLANG_RETURN_ON_FAIL(artifact->requireFilePath(ArtifactKeep::No, path)); - - String parentDir = Path::getParentDirectory(parentDir); - if (parentDir.getLength()) - { - // Check if we already have the library path, only add it if it's not found - if (libraryPaths.indexOf(parentDir) < 0) - { - libraryPaths.add(parentDir); - } - path = Path::getFileName(path); - } - - // If it starts with lib strip it - if (path.startsWith("lib")) - { - const String stripLib = path.getUnownedSlice().tail(3); - path = stripLib; - } - - // Strip the extension if it's a match - auto extension = Path::getPathExt(path); - if (extension.getLength()) - { - auto libExt = ArtifactDesc::make(ArtifactKind::Library, ArtifactPayload::HostCPU).getDefaultExtension(); - if (extension == libExt) - { - path = Path::getFileNameWithoutExt(path); - } - } + if (desc.isCpuBinary() && desc.kind == ArtifactKind::Library) + { + // Get the name and path (can be empty) to the library + SLANG_RETURN_ON_FAIL(artifact->requireFileLike(ArtifactKeep::No)); - cmdLine.addPrefixPathArg("-l", path); - } + libPathPool.add(artifact->getParentPath()); + cmdLine.addPrefixPathArg("-l", artifact->getBaseName()); } } - for (const auto& libPath : options.libraryPaths) - { - // Note that any escaping of the path is handled in the ProcessUtil:: - cmdLine.addArg("-L"); - cmdLine.addArg(libPath); - cmdLine.addArg("-F"); - cmdLine.addArg(libPath); - } - - if (options.sourceLanguage == SLANG_SOURCE_LANGUAGE_CPP && !PlatformUtil::isFamily(PlatformFamily::Windows, platformKind)) { // Make STD libs available @@ -687,6 +651,15 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse cmdLine.addArg("-lm"); } + for (const auto& libPath : libPathPool.getAdded()) + { + // Note that any escaping of the path is handled in the ProcessUtil:: + cmdLine.addArg("-L"); + cmdLine.addArg(libPath); + cmdLine.addArg("-F"); + cmdLine.addArg(libPath); + } + return SLANG_OK; } |
