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

Method findBestCompiler

Libraries/Plugin/Plugin.cpp:431–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429};
430#endif
431SC::Result SC::PluginCompiler::findBestCompiler(PluginCompiler& compiler)
432{
433#if SC_PLATFORM_WINDOWS
434 // TODO: can we use findLatest in order to avoid finding best compiler version...?
435 FixedVector<StringPath, 8> rootPaths;
436 SC_TRY(VisualStudioPathFinder().findAll(rootPaths))
437 for (auto& base : rootPaths)
438 SC_TRY(PluginString::append(base, {SC_NATIVE_STR("/VC/Tools/MSVC")}));
439
440 compiler.type = Type::MicrosoftCompiler;
441 CompilerFinder compilerFinder;
442 for (const auto& basePath : rootPaths)
443 {
444 StringSpan base = basePath.view();
445 PluginFileSystemIterator iterator;
446 if (not iterator.init(base))
447 continue;
448 PluginFileSystemIterator::Entry entry;
449 while (iterator.next(entry))
450 {
451 if (entry.isDirectory and entry.name != SC_NATIVE_STR(".") and entry.name != SC_NATIVE_STR(".."))
452 {
453 SC_TRY(compilerFinder.tryFindCompiler(base, entry.name, compiler));
454 if (compilerFinder.found)
455 break;
456 }
457 }
458
459 if (compilerFinder.found)
460 {
461 break;
462 }
463 }
464 if (not compilerFinder.found)
465 {
466 return Result::Error("Visual Studio PluginCompiler not found");
467 }
468#elif SC_PLATFORM_APPLE
469 compiler.type = Type::ClangCompiler;
470 SC_TRY(compiler.compilerPath.assign("clang"));
471 SC_TRY(compiler.linkerPath.assign("clang"));
472#elif SC_PLATFORM_LINUX
473 compiler.type = Type::GnuCompiler;
474 SC_TRY(compiler.compilerPath.assign("g++"));
475 SC_TRY(compiler.linkerPath.assign("g++"));
476#endif
477 return Result(true);
478}
479
480SC::Result SC::PluginCompiler::compileFile(const PluginDefinition& definition, const PluginSysroot& sysroot,
481 const PluginCompilerEnvironment& compilerEnvironment, StringSpan sourceFile,

Callers

nothing calls this directly

Calls 10

findAllMethod · 0.80
tryFindCompilerMethod · 0.80
appendFunction · 0.50
ErrorEnum · 0.50
ResultClass · 0.50
viewMethod · 0.45
initMethod · 0.45
nextMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected