diff --git a/doc/csgcca.adoc b/doc/csgcca.adoc index 95e6b70..052940f 100644 --- a/doc/csgcca.adoc +++ b/doc/csgcca.adoc @@ -88,6 +88,10 @@ ENVIRONMENT VARIABLES are appended even if they already appear in the command line and they are always appended at the end of the command line. +*CSGCCA_ANALYZER_BIN*:: + If set to a non-empty string, csgcca will use the value as a path (relative + or absolute) to analyzer binary. + BUGS ---- diff --git a/src/csclng.c b/src/csclng.c index 57799a7..f2d1d2c 100644 --- a/src/csclng.c +++ b/src/csclng.c @@ -37,6 +37,8 @@ const char *wrapper_debug_envvar_name = "DEBUG_CSCLNG"; const char *analyzer_name = "clang"; +const char *analyzer_bin_envvar_name = NULL; + const bool analyzer_is_cxx_ready = true; const bool analyzer_is_gcc_compatible = true; diff --git a/src/cscppc.c b/src/cscppc.c index 48da183..717adb0 100644 --- a/src/cscppc.c +++ b/src/cscppc.c @@ -38,6 +38,8 @@ const char *wrapper_debug_envvar_name = "DEBUG_CSCPPC"; const char *analyzer_name = "cppcheck"; +const char *analyzer_bin_envvar_name = NULL; + const bool analyzer_is_cxx_ready = true; const bool analyzer_is_gcc_compatible = false; diff --git a/src/csgcca.c b/src/csgcca.c index 8fbb194..19ba42c 100644 --- a/src/csgcca.c +++ b/src/csgcca.c @@ -37,6 +37,8 @@ const char *wrapper_debug_envvar_name = "DEBUG_CSGCCA"; const char *analyzer_name = "gcc"; +const char *analyzer_bin_envvar_name = "CSGCCA_ANALYZER_BIN"; + const bool analyzer_is_cxx_ready = false; const bool analyzer_is_gcc_compatible = true; diff --git a/src/csmatch.c b/src/csmatch.c index 27f6f86..fdac9d4 100644 --- a/src/csmatch.c +++ b/src/csmatch.c @@ -37,6 +37,8 @@ const char *wrapper_debug_envvar_name = "DEBUG_CSMATCH"; const char *analyzer_name = "smatch"; +const char *analyzer_bin_envvar_name = NULL; + const bool analyzer_is_cxx_ready = false; const bool analyzer_is_gcc_compatible = true; diff --git a/src/cswrap-core.c b/src/cswrap-core.c index 1fa4a77..a8ecb2a 100644 --- a/src/cswrap-core.c +++ b/src/cswrap-core.c @@ -393,8 +393,14 @@ static void consider_running_analyzer( return; } - /* make sure that the analyzer process is named analyzer_name */ - argv[0] = (char *) analyzer_name; + const char *analyzer_name_actual = NULL; + if (analyzer_bin_envvar_name) + analyzer_name_actual = getenv(analyzer_bin_envvar_name); + if (!analyzer_name_actual || !analyzer_name_actual[0]) + analyzer_name_actual = analyzer_name; + + /* make sure that the analyzer process is named analyzer_name_actual */ + argv[0] = (char *) analyzer_name_actual; /* make sure there is NULL at the end of argv[] */ argv[argc_total - 1] = NULL; @@ -410,7 +416,7 @@ static void consider_running_analyzer( } /* try to start analyzer */ - pid_analyzer = launch_tool(analyzer_name, argv, /* del_args */ NULL); + pid_analyzer = launch_tool(analyzer_name_actual, argv, /* del_args */ NULL); /* FIXME: release also the memory allocated by asprintf() and read_custom_opts() */ diff --git a/src/cswrap-core.h b/src/cswrap-core.h index 1a68184..e7a01af 100644 --- a/src/cswrap-core.h +++ b/src/cswrap-core.h @@ -34,6 +34,13 @@ extern const char *wrapper_debug_envvar_name; extern const char *analyzer_name; +/** + * The name of the environment variable which value is the path (relative or + * absolute) to the analyzer binary. If value of the environment variable is + * non-empty string it's used to override the value if analyzer_name. + */ +extern const char *analyzer_bin_envvar_name; + extern const bool analyzer_is_cxx_ready; extern const bool analyzer_is_gcc_compatible;