MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / resolveCompiledLibraryRoot

Function resolveCompiledLibraryRoot

Libraries/Testing/Testing.cpp:291–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291static bool resolveCompiledLibraryRoot(StringSpan executablePath, StringPath& libraryRoot, StartupAttempt* attempts,
292 size_t maxAttempts, size_t& numAttempts)
293{
294#if defined(SC_LIBRARY_ROOT)
295 const StringSpan compiledLibraryRoot =
296 StringSpan::fromNullTerminated(SC_COMPILER_LIBRARY_PATH, StringEncoding::Utf8);
297 if (compiledLibraryRoot.isEmpty())
298 return false;
299
300 StringPath compiledLibraryRootPath;
301 if (!compiledLibraryRootPath.assign(compiledLibraryRoot))
302 return false;
303
304 StringPath candidate;
305 if (isAbsoluteNative(compiledLibraryRootPath.view()))
306 {
307 if (!candidate.assign(compiledLibraryRootPath.view()))
308 return false;
309 }
310 else
311 {
312 StringPath executableDirectory;
313 if (!getDirectoryName(executablePath, executableDirectory))
314 return false;
315 if (!pathJoin(candidate, executableDirectory.view(), compiledLibraryRootPath.view()))
316 return false;
317 }
318
319 StringPath normalizedCandidate;
320 if (normalizeNativePath(candidate.view(), normalizedCandidate))
321 {
322 candidate = move(normalizedCandidate);
323 }
324
325 recordAttempt(attempts, maxAttempts, numAttempts, "compiled relative root", candidate.view());
326 if (validateLibraryRoot(candidate.view()))
327 {
328 return libraryRoot.assign(candidate.view()) ? true : false;
329 }
330 return false;
331#else
332 (void)(executablePath);
333 (void)(libraryRoot);
334 (void)(attempts);
335 (void)(maxAttempts);
336 (void)(numAttempts);
337 return false;
338#endif
339}
340
341static void reportLibraryRootFailure(TestReport::IOutput& console, StringSpan applicationRoot, StartupAttempt* attempts,
342 size_t numAttempts, StringSpan explicitOverride, bool explicitOverrideProvided,

Callers 1

resolveLibraryRootFunction · 0.85

Calls 10

fromNullTerminatedFunction · 0.85
isAbsoluteNativeFunction · 0.85
getDirectoryNameFunction · 0.85
pathJoinFunction · 0.85
normalizeNativePathFunction · 0.85
recordAttemptFunction · 0.85
validateLibraryRootFunction · 0.85
isEmptyMethod · 0.45
assignMethod · 0.45
viewMethod · 0.45

Tested by

no test coverage detected