diff options
Diffstat (limited to 'source/compiler-core/slang-gcc-compiler-util.cpp')
| -rw-r--r-- | source/compiler-core/slang-gcc-compiler-util.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp index 8d1b87b68..7d1b7b86a 100644 --- a/source/compiler-core/slang-gcc-compiler-util.cpp +++ b/source/compiler-core/slang-gcc-compiler-util.cpp @@ -619,6 +619,56 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse cmdLine.addArg(sourceFile); } + // Add the library paths + List<String> libraryPaths; + libraryPaths.addRange(options.libraryPaths.getBuffer(), options.libraryPaths.getCount()); + + // 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); + } + } + + cmdLine.addPrefixPathArg("-l", path); + } + } + } + for (const auto& libPath : options.libraryPaths) { // Note that any escaping of the path is handled in the ProcessUtil:: @@ -628,6 +678,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse cmdLine.addArg(libPath); } + if (options.sourceLanguage == SLANG_SOURCE_LANGUAGE_CPP && !PlatformUtil::isFamily(PlatformFamily::Windows, platformKind)) { // Make STD libs available |
