static void
add_prefix(struct args *orig_args)
{
- if (!str_eq(conf->prefix_command, "")) {
- char *e;
- char *tok, *saveptr = NULL;
- struct args *prefix = args_init(0, NULL);
- int i;
-
- e = x_strdup(conf->prefix_command);
- for (tok = strtok_r(e, " ", &saveptr);
- tok;
- tok = strtok_r(NULL, " ", &saveptr)) {
- char *p;
+ char *e;
+ char *tok, *saveptr = NULL;
+ struct args *prefix;
+ int i;
- p = find_executable(tok, MYNAME);
- if (!p) {
- fatal("%s: %s", tok, strerror(errno));
- }
+ if (str_eq(conf->prefix_command, "")) {
+ return;
+ }
- args_add(prefix, p);
- free(p);
- }
- free(e);
+ prefix = args_init(0, NULL);
+ e = x_strdup(conf->prefix_command);
+ for (tok = strtok_r(e, " ", &saveptr);
+ tok;
+ tok = strtok_r(NULL, " ", &saveptr)) {
+ char *p;
- cc_log("Using command-line prefix %s", conf->prefix_command);
- for (i = prefix->argc; i != 0; i--) {
- args_add_prefix(orig_args, prefix->argv[i-1]);
+ p = find_executable(tok, MYNAME);
+ if (!p) {
+ fatal("%s: %s", tok, strerror(errno));
}
- args_free(prefix);
+
+ args_add(prefix, p);
+ free(p);
}
+ free(e);
+
+ cc_log("Using command-line prefix %s", conf->prefix_command);
+ for (i = prefix->argc; i != 0; i--) {
+ args_add_prefix(orig_args, prefix->argv[i-1]);
+ }
+ args_free(prefix);
}
/* Something went badly wrong - just execute the real compiler. */
{
assert(orig_args);
- /* strip any local args */
args_strip(orig_args, "--ccache-");
-
- /* add prefix from CCACHE_PREFIX */
add_prefix(orig_args);
cc_log("Failed; falling back to running the real compiler");
failed();
}
- /* add prefix from CCACHE_PREFIX */
add_prefix(compiler_args);
/* run real compiler, sending output to cache */
/*
- * Copyright (C) 2011 Joel Rosdahl
+ * Copyright (C) 2011-2012 Joel Rosdahl
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
printer(s, conf->item_origins[find_conf("cache_dir")->number], context);
reformat(&s, "cache_dir_levels = %u", conf->cache_dir_levels);
- printer(s, conf->item_origins[find_conf("cache_dir_levels")->number], context);
+ printer(s, conf->item_origins[find_conf("cache_dir_levels")->number],
+ context);
reformat(&s, "compiler = %s", conf->compiler);
printer(s, conf->item_origins[find_conf("compiler")->number], context);
printer(s, conf->item_origins[find_conf("disable")->number], context);
reformat(&s, "extra_files_to_hash = %s", conf->extra_files_to_hash);
- printer(s, conf->item_origins[find_conf("extra_files_to_hash")->number], context);
+ printer(s, conf->item_origins[find_conf("extra_files_to_hash")->number],
+ context);
reformat(&s, "hard_link = %s", conf->hard_link ? "true" : "false");
printer(s, conf->item_origins[find_conf("hard_link")->number], context);