if (value == "clang") {
return CompilerType::clang;
} else if (value == "clang-cl") {
- return CompilerType::clangcl;
+ return CompilerType::clang_cl;
} else if (value == "gcc") {
return CompilerType::gcc;
} else if (value == "msvc") {
return "auto";
CASE(clang);
- CASE(clangcl);
+ CASE(clang_cl);
CASE(gcc);
CASE(msvc);
CASE(nvcc);
#include <string>
#include <unordered_map>
-enum class CompilerType { auto_guess, clang, clangcl, gcc, msvc, nvcc, other };
+enum class CompilerType { auto_guess, clang, clang_cl, gcc, msvc, nvcc, other };
std::string compiler_type_to_string(CompilerType compiler_type);
const std::string& compiler() const;
const std::string& compiler_check() const;
CompilerType compiler_type() const;
- // Returns true for clang or clangcl.
- bool is_compiler_group_clang() const;
- // Returns true for cl or clangcl.
- bool is_compiler_group_cl() const;
bool compression() const;
int8_t compression_level() const;
const std::string& cpp_extension() const;
const std::string& temporary_dir() const;
nonstd::optional<mode_t> umask() const;
+ // Return true for Clang and clang-cl.
+ bool is_compiler_group_clang() const;
+
+ // Return true for MSVC (cl.exe) and clang-cl.
+ bool is_compiler_group_msvc() const;
+
void set_base_dir(const std::string& value);
void set_cache_dir(const std::string& value);
void set_compiler(const std::string& value);
Config::is_compiler_group_clang() const
{
return m_compiler_type == CompilerType::clang
- || m_compiler_type == CompilerType::clangcl;
+ || m_compiler_type == CompilerType::clang_cl;
}
inline bool
-Config::is_compiler_group_cl() const
+Config::is_compiler_group_msvc() const
{
return m_compiler_type == CompilerType::msvc
- || m_compiler_type == CompilerType::clangcl;
+ || m_compiler_type == CompilerType::clang_cl;
}
inline bool
}
bool changed_from_slash = false;
- if (ctx.config.is_compiler_group_cl() && util::starts_with(args[i], "/")) {
+ if (ctx.config.is_compiler_group_msvc() && util::starts_with(args[i], "/")) {
// MSVC understands both /option and -option, so convert all /option to
// -option to simplify our handling.
args[i][0] = '-';
return Statistic::called_for_preprocessing;
}
// MSVC -P is -E with output to a file.
- if (args[i] == "-P" && ctx.config.is_compiler_group_cl()) {
+ if (args[i] == "-P" && ctx.config.is_compiler_group_msvc()) {
return Statistic::called_for_preprocessing;
}
++argpath;
}
auto file_args =
- Args::from_atfile(argpath, ctx.config.is_compiler_group_cl());
+ Args::from_atfile(argpath, ctx.config.is_compiler_group_msvc());
if (!file_args) {
LOG("Couldn't read arg file {}", argpath);
return Statistic::bad_compiler_arguments;
}
// MSVC -Fo with no space.
- if (util::starts_with(args[i], "-Fo") && config.is_compiler_group_cl()) {
+ if (util::starts_with(args[i], "-Fo") && config.is_compiler_group_msvc()) {
args_info.output_obj =
Util::make_relative_path(ctx, string_view(args[i]).substr(3));
return nullopt;
// These options require special handling, because they behave differently
// with gcc -E, when the output file is not specified.
if ((args[i] == "-MD" || args[i] == "-MMD")
- && !config.is_compiler_group_cl()) {
+ && !config.is_compiler_group_msvc()) {
args_info.generating_dependencies = true;
args_info.seen_MD_MMD = true;
state.dep_args.push_back(args[i]);
}
if ((util::starts_with(args[i], "-MQ") || util::starts_with(args[i], "-MT"))
- && !config.is_compiler_group_cl()) {
+ && !config.is_compiler_group_msvc()) {
args_info.dependency_target_specified = true;
if (args[i].size() == 3) {
// MSVC -MD[d], -MT[d] and -LT[d] options are something different than GCC's
// -MD etc.
- if (config.is_compiler_group_cl()
+ if (config.is_compiler_group_msvc()
&& (util::starts_with(args[i], "-MD") || util::starts_with(args[i], "-MT")
|| util::starts_with(args[i], "-LD"))) {
// These affect compiler but also #define some things.
}
// MSVC -u is something else than GCC -u, handle it specially.
- if (args[i] == "-u" && ctx.config.is_compiler_group_cl()) {
+ if (args[i] == "-u" && ctx.config.is_compiler_group_msvc()) {
state.cpp_args.push_back(args[i]);
return nullopt;
}
string_view extension;
if (state.found_S_opt) {
extension = ".s";
- } else if (!ctx.config.is_compiler_group_cl()) {
+ } else if (!ctx.config.is_compiler_group_msvc()) {
extension = ".o";
} else {
extension = ".obj";
const auto name =
Util::to_lowercase(Util::remove_extension(Util::base_name(compiler_path)));
if (name.find("clang-cl") != nonstd::string_view::npos) {
- return CompilerType::clangcl;
+ return CompilerType::clang_cl;
} else if (name.find("clang") != nonstd::string_view::npos) {
return CompilerType::clang;
} else if (name.find("gcc") != nonstd::string_view::npos
const Args& depend_extra_args,
Hash* depend_mode_hash)
{
- if (ctx.config.is_compiler_group_cl()) {
+ if (ctx.config.is_compiler_group_msvc()) {
args.push_back(fmt::format("-Fo{}", ctx.args_info.output_obj));
} else {
args.push_back("-o");
TRY(set_up_uncached_err());
- if (!ctx.config.run_second_cpp() && ctx.config.is_compiler_group_cl()) {
+ if (!ctx.config.run_second_cpp() && ctx.config.is_compiler_group_msvc()) {
LOG_RAW("Second preprocessor cannot be disabled");
ctx.config.set_run_second_cpp(true);
}