-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmodel.cppm
More file actions
61 lines (46 loc) · 2.06 KB
/
Copy pathmodel.cppm
File metadata and controls
61 lines (46 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// mcpp.toolchain.model - stable toolchain data model.
export module mcpp.toolchain.model;
import std;
export namespace mcpp::toolchain {
enum class CompilerId { Unknown, GCC, Clang, MSVC };
struct Toolchain {
CompilerId compiler = CompilerId::Unknown;
std::string version; // "15.1.0"
std::filesystem::path binaryPath;
std::string driverIdent; // normalized --version output
std::string targetTriple; // "x86_64-linux-gnu"
std::string stdlibId; // "libstdc++"
std::string stdlibVersion;
std::filesystem::path stdModuleSource; // bits/std.cc / std.cppm
std::filesystem::path sysroot; // -print-sysroot output (or empty)
std::vector<std::filesystem::path> compilerRuntimeDirs; // LD_LIBRARY_PATH for private tools
std::vector<std::filesystem::path> linkRuntimeDirs; // -L/-rpath dirs for produced binaries
bool hasImportStd = false;
std::string label() const {
return std::format("{} {} ({})", compiler_name(), version, targetTriple);
}
std::string_view compiler_name() const {
switch (compiler) {
case CompilerId::GCC: return "gcc";
case CompilerId::Clang: return "clang";
case CompilerId::MSVC: return "msvc";
default: return "unknown";
}
}
};
struct DetectError { std::string message; };
bool is_gcc(const Toolchain& tc);
bool is_clang(const Toolchain& tc);
bool is_musl_target(const Toolchain& tc);
} // namespace mcpp::toolchain
namespace mcpp::toolchain {
bool is_gcc(const Toolchain& tc) {
return tc.compiler == CompilerId::GCC;
}
bool is_clang(const Toolchain& tc) {
return tc.compiler == CompilerId::Clang;
}
bool is_musl_target(const Toolchain& tc) {
return tc.targetTriple.find("-musl") != std::string::npos;
}
} // namespace mcpp::toolchain