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

Function detectCompilerName

Tests/SCBuildTest/SCBuildFixtureTest.cpp:88–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88static Result detectCompilerName(const Build::Toolchain& toolchain, StringView& compilerName)
89{
90 switch (toolchain.family)
91 {
92 case Build::Toolchain::Clang: compilerName = "clang"; return Result(true);
93 case Build::Toolchain::FilC: compilerName = "filc"; return Result(true);
94 case Build::Toolchain::GCC: compilerName = "gcc"; return Result(true);
95 case Build::Toolchain::LLVMMingw: compilerName = "llvm-mingw"; return Result(true);
96 case Build::Toolchain::MSVC: compilerName = "msvc"; return Result(true);
97 case Build::Toolchain::ClangCL: compilerName = "clang-cl"; return Result(true);
98 case Build::Toolchain::CustomDriver:
99 compilerName = Path::basename(toolchain.compilerCpp.view(), Path::AsNative);
100 return Result(true);
101 case Build::Toolchain::HostDefault:
102#if SC_PLATFORM_WINDOWS
103 compilerName = "msvc";
104 return Result(true);
105#elif SC_PLATFORM_APPLE
106 compilerName = "clang";
107 return Result(true);
108#else
109 {
110 Process probeProcess;
111 String output = StringEncoding::Utf8;
112 if (probeProcess.exec({"clang++", "--version"}, output) and probeProcess.getExitStatus() == 0)
113 {
114 compilerName = "clang";
115 }
116 else
117 {
118 compilerName = "gcc";
119 }
120 return Result(true);
121 }
122#endif
123 }
124 Assert::unreachable();
125}
126
127static size_t getSmallFixtureMaxBytes()
128{

Callers 1

Calls 3

basenameFunction · 0.85
ResultClass · 0.50
viewMethod · 0.45

Tested by

no test coverage detected