/* the main ccache driver function */ static void ccache(int argc, char *argv[]) { /* find the real compiler */ find_compiler(argc, argv); /* use the real compiler if HOME is not set */ if (!cache_dir) { cc_log("Unable to determine home directory\n"); cc_log("ccache is disabled\n"); failed(); } /* we might be disabled */ if (getenv("CCACHE_DISABLE")) { cc_log("ccache is disabled\n"); failed(); } if (getenv("CCACHE_STRIPC")) { strip_c_option = 1; } if (getenv("CCACHE_UNIFY")) { enable_unify = 1; } detect_swig(); /* process argument list, returning a new set of arguments for pre-processing */ process_args(orig_args->argc, orig_args->argv); /* run with -E to find the hash */ find_hash(stripped_args); /* if we can return from cache at this point then do */ from_cache(1); if (getenv("CCACHE_READONLY")) { cc_log("read-only set - doing real compile\n"); failed(); } /* run real compiler, sending output to cache */ to_cache(stripped_args); /* return from cache */ from_cache(0); /* oh oh! */ cc_log("secondary from_cache failed!\n"); stats_update(STATS_ERROR); failed(); }
int main(int argc, char **argv) { int optc; int optC = 0; while ((optc = getopt(argc, argv, "DdfCs:c:")) != EOF) { switch (optc) { case 'd': test_set_debug(); break; case 'f': test_set_force(); break; case 'D': test_set_debug(); extra_debug++; break; case 'c': compilation = optarg; break; case 'C': optC++; break; case 's': sym = optarg; break; default: (void) fprintf(stderr, "Usage: %s [-df]\n", argv[0]); exit(1); } } if (test_load_config(NULL, compilation, "env", do_env, "env_group", do_env_group, NULL) < 0) { exit(1); } while (optind < argc) { if (test_load_config(NULL, argv[optind++], "type", do_type, "value", do_value, "define", do_define, "func", do_func, NULL) < 0) { exit(1); } } if (atexit(cleanup) != 0) { perror("atexit"); exit(1); } if (custr_alloc(&st_custr) == -1) { perror("custr"); exit(1); } if (mkworkdir() < 0) { perror("mkdir"); exit(1); } find_compiler(); if (!optC) test_compile(); exit(0); }