From a5d91ce4f196bff0c6be54c5339d3b255b10cf56 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 17 Nov 2008 22:43:15 +0000 Subject: [PATCH] add input and output files to hash for correct operation when swig is the compiler. Automatically detect when swig is the compiler. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10931 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/ccache.c | 28 ++++++++++++++++++++-------- CCache/ccache.yo | 7 ++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CCache/ccache.c b/CCache/ccache.c index 4b7c2944f..0c3c15a0f 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -195,7 +195,6 @@ static void to_cache(ARGS *args) x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string()); x_asprintf(&tmp_outfiles, "%s/tmp.outfiles.%s", temp_dir, tmp_string()); - /* TODO swig */ if (output_file) { args_add(args, "-o"); args_add(args, output_file); @@ -384,13 +383,19 @@ static void find_hash(ARGS *args) /* when we are doing the unifying tricks we need to include the input file name in the hash to get the warnings right */ - if (enable_unify) { + if (enable_unify || swig) { hash_string(input_file); } - /* we have to hash the extension, as a .i file isn't treated the same - by the compiler as a .ii file (Note: not strictly necessary for SWIG) */ - hash_string(i_extension); + if (swig) { + if (output_file) { + hash_string(output_file); + } + } else { + /* we have to hash the extension, as a .i file isn't treated the same + by the compiler as a .ii file */ + hash_string(i_extension); + } /* first the arguments */ for (i=1;iargc;i++) { @@ -1055,6 +1060,15 @@ static void process_args(int argc, char **argv) } } +static void detect_swig() +{ + char *basename = str_basename(orig_args->argv[0]); + if (strstr(basename, "swig") || getenv("CCACHE_SWIG")) { + swig = 1; + } + free(basename); +} + /* the main ccache driver function */ static void ccache(int argc, char *argv[]) { @@ -1078,9 +1092,7 @@ static void ccache(int argc, char *argv[]) enable_unify = 1; } - if (getenv("CCACHE_SWIG")) { - swig = 1; - } + detect_swig(); /* process argument list, returning a new set of arguments for pre-processing */ process_args(orig_args->argc, orig_args->argv); diff --git a/CCache/ccache.yo b/CCache/ccache.yo index 3996c5184..8960c8498 100644 --- a/CCache/ccache.yo +++ b/CCache/ccache.yo @@ -233,9 +233,10 @@ systems like this you can use the CCACHE_EXTENSION option to override the default. On HP-UX set this environment variable to "i" if you use the aCC compiler. -dit(bf(CCACHE_SWIG)) The CCACHE_SWIG environment variable needs to be -set in order for ccache to work with SWIG. Currently the CCACHE_CPP2 -environment variable also needs to be set in order to work with SWIG. +dit(bf(CCACHE_SWIG)) When using SWIG as the compiler and it does not +have 'swig' in the executable name, then the CCACHE_SWIG environment +variable needs to be set in order for ccache to work correctly with +SWIG. enddit()