Skip to content

Commit d2c4a2e

Browse files
sibereamkdudka
authored andcommitted
csgcca: introduce ${CSGCCA_ANALYZER_BIN} to specify analyzer binary
... at run-time Closes: #5
1 parent f02ccc2 commit d2c4a2e

7 files changed

Lines changed: 28 additions & 3 deletions

File tree

doc/csgcca.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ ENVIRONMENT VARIABLES
8888
are appended even if they already appear in the command line and they are
8989
always appended at the end of the command line.
9090
91+
*CSGCCA_ANALYZER_BIN*::
92+
If set to a non-empty string, csgcca will use the value as a path (relative
93+
or absolute) to analyzer binary.
94+
9195
9296
BUGS
9397
----

src/csclng.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const char *wrapper_debug_envvar_name = "DEBUG_CSCLNG";
3737

3838
const char *analyzer_name = "clang";
3939

40+
const char *analyzer_bin_envvar_name = NULL;
41+
4042
const bool analyzer_is_cxx_ready = true;
4143

4244
const bool analyzer_is_gcc_compatible = true;

src/cscppc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const char *wrapper_debug_envvar_name = "DEBUG_CSCPPC";
3838

3939
const char *analyzer_name = "cppcheck";
4040

41+
const char *analyzer_bin_envvar_name = NULL;
42+
4143
const bool analyzer_is_cxx_ready = true;
4244

4345
const bool analyzer_is_gcc_compatible = false;

src/csgcca.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const char *wrapper_debug_envvar_name = "DEBUG_CSGCCA";
3737

3838
const char *analyzer_name = "gcc";
3939

40+
const char *analyzer_bin_envvar_name = "CSGCCA_ANALYZER_BIN";
41+
4042
const bool analyzer_is_cxx_ready = false;
4143

4244
const bool analyzer_is_gcc_compatible = true;

src/csmatch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const char *wrapper_debug_envvar_name = "DEBUG_CSMATCH";
3737

3838
const char *analyzer_name = "smatch";
3939

40+
const char *analyzer_bin_envvar_name = NULL;
41+
4042
const bool analyzer_is_cxx_ready = false;
4143

4244
const bool analyzer_is_gcc_compatible = true;

src/cswrap-core.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,14 @@ static void consider_running_analyzer(
393393
return;
394394
}
395395

396-
/* make sure that the analyzer process is named analyzer_name */
397-
argv[0] = (char *) analyzer_name;
396+
const char *analyzer_name_actual = NULL;
397+
if (analyzer_bin_envvar_name)
398+
analyzer_name_actual = getenv(analyzer_bin_envvar_name);
399+
if (!analyzer_name_actual || !analyzer_name_actual[0])
400+
analyzer_name_actual = analyzer_name;
401+
402+
/* make sure that the analyzer process is named analyzer_name_actual */
403+
argv[0] = (char *) analyzer_name_actual;
398404

399405
/* make sure there is NULL at the end of argv[] */
400406
argv[argc_total - 1] = NULL;
@@ -410,7 +416,7 @@ static void consider_running_analyzer(
410416
}
411417

412418
/* try to start analyzer */
413-
pid_analyzer = launch_tool(analyzer_name, argv, /* del_args */ NULL);
419+
pid_analyzer = launch_tool(analyzer_name_actual, argv, /* del_args */ NULL);
414420

415421
/* FIXME: release also the memory allocated by asprintf() and
416422
read_custom_opts() */

src/cswrap-core.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ extern const char *wrapper_debug_envvar_name;
3434

3535
extern const char *analyzer_name;
3636

37+
/**
38+
* The name of the environment variable which value is the path (relative or
39+
* absolute) to the analyzer binary. If value of the environment variable is
40+
* non-empty string, it's used to override the value of analyzer_name.
41+
*/
42+
extern const char *analyzer_bin_envvar_name;
43+
3744
extern const bool analyzer_is_cxx_ready;
3845

3946
extern const bool analyzer_is_gcc_compatible;

0 commit comments

Comments
 (0)