From 1afb9cb43d3ab3d55ac5125ef8b5e6cd482f3f85 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Thu, 11 Apr 2024 21:54:05 -0700 Subject: Fix the issues when compiling slang to library (#3936) --- source/slang/slang-serialize-container.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'source/slang/slang-serialize-container.cpp') diff --git a/source/slang/slang-serialize-container.cpp b/source/slang/slang-serialize-container.cpp index 2454256c2..50b9061e3 100644 --- a/source/slang/slang-serialize-container.cpp +++ b/source/slang/slang-serialize-container.cpp @@ -149,17 +149,25 @@ namespace Slang { // If the dependnet file is the same as the module's file path, store it as a relative path // with respect to the search directory discovered above. - if (canonicalFilePath == canonicalModulePath) + if (file->getPathInfo().hasFileFoundPath()) { - auto relativeModulePath = Path::getRelativePath(linkageRoot, canonicalModulePath); - dstModule.dependentFiles.add(relativeModulePath); + if (canonicalFilePath == canonicalModulePath) + { + auto relativeModulePath = Path::getRelativePath(linkageRoot, canonicalModulePath); + dstModule.dependentFiles.add(relativeModulePath); + } + else + { + // For all other dependnet files, store them as relative paths with respect + // to the module's path. + canonicalFilePath = Path::getRelativePath(moduleDir, canonicalFilePath); + dstModule.dependentFiles.add(canonicalFilePath); + } } else { - // For all other dependnet files, store them as relative paths with respect - // to the module's path. - canonicalFilePath = Path::getRelativePath(moduleDir, canonicalFilePath); - dstModule.dependentFiles.add(canonicalFilePath); + // If the module is coming from string instead of an actual file, store it as is. + dstModule.dependentFiles.add(canonicalModulePath); } } else @@ -193,6 +201,11 @@ namespace Slang { // Output the parsed modules. addFrontEndRequestToData(request->getFrontEndReq(), options, out); + // If we are skipping code generation, then we are done. + if(request->getOptionSet().getBoolOption(CompilerOptionName::SkipCodeGen)) + { + return SLANG_OK; + } // auto program = request->getSpecializedGlobalAndEntryPointsComponentType(); -- cgit v1.2.3