Skip to content

Commit

Permalink
csgcca: introduce ${CSGCCA_ANALYZER_BIN} to specify analyzer binary
Browse files Browse the repository at this point in the history
... at run-time

Closes: #5
  • Loading branch information
sibeream authored and kdudka committed Sep 22, 2021
1 parent f02ccc2 commit d2c4a2e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/csgcca.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
Expand Down
2 changes: 2 additions & 0 deletions src/csclng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/cscppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/csgcca.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/csmatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 9 additions & 3 deletions src/cswrap-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() */
Expand Down
7 changes: 7 additions & 0 deletions src/cswrap-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 of analyzer_name.
*/
extern const char *analyzer_bin_envvar_name;

extern const bool analyzer_is_cxx_ready;

extern const bool analyzer_is_gcc_compatible;
Expand Down

0 comments on commit d2c4a2e

Please sign in to comment.