free(path);
}
-static enum guessed_compiler
+static GuessedCompiler
guess_compiler(const char* path)
{
string_view name = Util::base_name(path);
- enum guessed_compiler result = GUESSED_UNKNOWN;
+ GuessedCompiler result = GuessedCompiler::unknown;
if (name == "clang") {
- result = GUESSED_CLANG;
+ result = GuessedCompiler::clang;
} else if (name == "gcc" || name == "g++") {
- result = GUESSED_GCC;
+ result = GuessedCompiler::gcc;
} else if (name == "nvcc") {
- result = GUESSED_NVCC;
+ result = GuessedCompiler::nvcc;
} else if (name == "pump" || name == "distcc-pump") {
- result = GUESSED_PUMP;
+ result = GuessedCompiler::pump;
}
return result;
}
// distcc-pump outputs lines like this:
// __________Using # distcc servers in pump mode
- if (st.size() != 0 && guessed_compiler != GUESSED_PUMP) {
+ if (st.size() != 0 && guessed_compiler != GuessedCompiler::pump) {
cc_log("Compiler produced stdout");
stats_update(STATS_STDOUT);
tmp_unlink(tmp_stdout);
hash_delimiter(hash, "cpp");
if (!process_preprocessed_file(
- ctx, hash, path_stdout, guessed_compiler == GUESSED_PUMP)) {
+ ctx, hash, path_stdout, guessed_compiler == GuessedCompiler::pump)) {
stats_update(STATS_ERROR);
failed();
}
}
// Possibly hash GCC_COLORS (for color diagnostics).
- if (guessed_compiler == GUESSED_GCC) {
+ if (guessed_compiler == GuessedCompiler::gcc) {
const char* gcc_colors = getenv("GCC_COLORS");
if (gcc_colors) {
hash_delimiter(hash, "gcccolors");
// clang will emit warnings for unused linker flags, so we shouldn't skip
// those arguments.
- int is_clang =
- guessed_compiler == GUESSED_CLANG || guessed_compiler == GUESSED_UNKNOWN;
+ int is_clang = guessed_compiler == GuessedCompiler::clang
+ || guessed_compiler == GuessedCompiler::unknown;
// First the arguments.
for (int i = 1; i < args->argc; i++) {
//
// file 'foo.h' has been modified since the precompiled header 'foo.pch'
// was built
- if ((guessed_compiler == GUESSED_CLANG || guessed_compiler == GUESSED_UNKNOWN)
+ if ((guessed_compiler == GuessedCompiler::clang
+ || guessed_compiler == GuessedCompiler::unknown)
&& ctx.args_info.output_is_precompiled_header
&& mode == FROMCACHE_CPP_MODE) {
cc_log("Not considering cached precompiled header in preprocessor mode");
}
// Handle cuda "-optf" and "--options-file" argument.
- if (guessed_compiler == GUESSED_NVCC
+ if (guessed_compiler == GuessedCompiler::nvcc
&& (str_eq(argv[i], "-optf") || str_eq(argv[i], "--options-file"))) {
if (i == argc - 1) {
cc_log("Expected argument after %s", argv[i]);
// when using nvcc with separable compilation, -dc implies -c
if ((str_eq(argv[i], "-dc") || str_eq(argv[i], "--device-c"))
- && guessed_compiler == GUESSED_NVCC) {
+ && guessed_compiler == GuessedCompiler::nvcc) {
found_dc_opt = true;
continue;
}
}
// Alternate form of -o with no space. Nvcc does not support this.
- if (str_startswith(argv[i], "-o") && guessed_compiler != GUESSED_NVCC) {
+ if (str_startswith(argv[i], "-o")
+ && guessed_compiler != GuessedCompiler::nvcc) {
args_info.output_obj = make_relative_path(ctx, &argv[i][2]);
continue;
}
// Since output is redirected, compilers will not color their output by
// default, so force it explicitly if it would be otherwise done.
if (!found_color_diagnostics && color_output_possible()) {
- if (guessed_compiler == GUESSED_CLANG) {
+ if (guessed_compiler == GuessedCompiler::clang) {
if (args_info.actual_language != "assembler") {
args_add(common_args, "-fcolor-diagnostics");
add_extra_arg("-fcolor-diagnostics");
cc_log("Automatically enabling colors");
}
- } else if (guessed_compiler == GUESSED_GCC) {
+ } else if (guessed_compiler == GuessedCompiler::gcc) {
// GCC has it since 4.9, but that'd require detecting what GCC version is
// used for the actual compile. However it requires also GCC_COLORS to be
// set (and not empty), so use that for detecting if GCC would use