summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-04-02 13:49:44 -0400
committerGitHub <noreply@github.com>2021-04-02 13:49:44 -0400
commite14d9ffac640c3eefdba301c16fbeee7c63e57c6 (patch)
tree3f874c3393b00aa870270b98e67fd56bf983109b
parente1ad4a2d9b7ee615397721fa1117499914c9efc3 (diff)
Repro fixes (#1780)
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix handling names in repro with : Handle if file info is not set - which means it's contents was not loaded.
-rw-r--r--source/slang/slang-repro.cpp98
1 files changed, 64 insertions, 34 deletions
diff --git a/source/slang/slang-repro.cpp b/source/slang/slang-repro.cpp
index 3618568c1..d8688f4a3 100644
--- a/source/slang/slang-repro.cpp
+++ b/source/slang/slang-repro.cpp
@@ -332,6 +332,22 @@ static bool _isStorable(const PathInfo::Type type)
}
}
+static String _scrubName(const String& in)
+{
+ StringBuilder builder;
+ for (auto c : in)
+ {
+ switch (c)
+ {
+ case ':': c = '_'; break;
+ default:break;
+ }
+ builder.appendChar(c);
+ }
+
+ return builder.ProduceString();
+}
+
/* static */SlangResult ReproUtil::store(EndToEndCompileRequest* request, OffsetContainer& inOutContainer, Offset32Ptr<RequestState>& outRequest)
{
StoreContext context(&inOutContainer);
@@ -570,8 +586,8 @@ static bool _isStorable(const PathInfo::Type type)
path = builder;
}
- String filename = Path::getFileNameWithoutExt(path);
- String ext = Path::getPathExt(path);
+ String filename = _scrubName(Path::getFileNameWithoutExt(path));
+ String ext = _scrubName(Path::getPathExt(path));
StringBuilder uniqueName;
for (Index j = 0; j < 0x10000; j++)
@@ -736,6 +752,11 @@ struct LoadContext
CacheFileSystem::PathInfo* addPathInfo(const PathInfoState* srcInfo)
{
+ if (!srcInfo)
+ {
+ return nullptr;
+ }
+
CacheFileSystem::PathInfo* pathInfo;
if (m_pathInfoMap.TryGetValue(srcInfo, pathInfo))
{
@@ -1019,7 +1040,9 @@ struct LoadContext
for (const auto& pairOffset : requestState->pathInfoMap)
{
const auto& pair = base.asRaw(pairOffset);
- CacheFileSystem::PathInfo* pathInfo = context.addPathInfo(base.asRaw(pair.pathInfo));
+ auto srcPathInfo = base.asRaw(pair.pathInfo);
+
+ CacheFileSystem::PathInfo* pathInfo = context.addPathInfo(srcPathInfo);
dstPathMap.Add(base.asRaw(pair.path)->getSlice(), pathInfo);
}
}
@@ -1444,49 +1467,56 @@ static SlangResult _calcCommandLine(OffsetBase& base, ReproUtil::RequestState* r
const auto pathInfo = base.asRaw(path.pathInfo);
- if (pathInfo->file)
- {
- builder << base.asRaw(base.asRaw(pathInfo->file)->uniqueName)->getSlice();
- }
- else
+ if (pathInfo)
{
- typedef CacheFileSystem::CompressedResult CompressedResult;
- if (pathInfo->getPathTypeResult == CompressedResult::Ok)
+ if (pathInfo->file)
{
- switch (pathInfo->pathType)
+ builder << base.asRaw(base.asRaw(pathInfo->file)->uniqueName)->getSlice();
+ }
+ else
+ {
+ typedef CacheFileSystem::CompressedResult CompressedResult;
+ if (pathInfo->getPathTypeResult == CompressedResult::Ok)
{
- case SLANG_PATH_TYPE_FILE: builder << "file "; break;
- case SLANG_PATH_TYPE_DIRECTORY: builder << "directory "; break;
- default: builder << "?"; break;
+ switch (pathInfo->pathType)
+ {
+ case SLANG_PATH_TYPE_FILE: builder << "file "; break;
+ case SLANG_PATH_TYPE_DIRECTORY: builder << "directory "; break;
+ default: builder << "?"; break;
+ }
}
- }
- CompressedResult curRes = pathInfo->getCanonicalPathResult;
- CompressedResult results[] =
- {
- pathInfo->getPathTypeResult,
- pathInfo->loadFileResult,
- };
+ CompressedResult curRes = pathInfo->getCanonicalPathResult;
+ CompressedResult results[] =
+ {
+ pathInfo->getPathTypeResult,
+ pathInfo->loadFileResult,
+ };
- for (auto compRes : results)
- {
- if (int(compRes) > int(curRes))
+ for (auto compRes : results)
{
- curRes = compRes;
+ if (int(compRes) > int(curRes))
+ {
+ curRes = compRes;
+ }
}
- }
- switch (curRes)
- {
- default:
- case CompressedResult::Uninitialized: break;
- case CompressedResult::Ok: break;
+ switch (curRes)
+ {
+ default:
+ case CompressedResult::Uninitialized: break;
+ case CompressedResult::Ok: break;
- case CompressedResult::NotFound: builder << " [not found]"; break;
- case CompressedResult::CannotOpen: builder << "[cannot open]"; break;
- case CompressedResult::Fail: builder << "[fail]"; break;
+ case CompressedResult::NotFound: builder << "[not found]"; break;
+ case CompressedResult::CannotOpen: builder << "[cannot open]"; break;
+ case CompressedResult::Fail: builder << "[fail]"; break;
+ }
}
}
+ else
+ {
+ builder << "[not loaded]";
+ }
builder << "\n";
}