Skip to content

Commit

Permalink
Adding environment dependent handling of the anlayzer version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrupp committed Sep 5, 2024
1 parent 99fcaf4 commit b1b40c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
11 changes: 7 additions & 4 deletions analyzer/codechecker_analyzer/analyzers/analyzer_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def check_supported_analyzers(analyzers):
"""

context = analyzer_context.get_context()
check_env = context.cc_env

analyzer_binaries = context.analyzer_binaries

Expand All @@ -182,7 +181,8 @@ def check_supported_analyzers(analyzers):
elif not os.path.isabs(analyzer_bin):
# If the analyzer is not in an absolute path, try to find it...
found_bin = supported_analyzers[analyzer_name].\
resolve_missing_binary(analyzer_bin, check_env)
resolve_missing_binary(analyzer_bin,
context.get_analyzer_env(analyzer_name))

# found_bin is an absolute path, an executable in one of the
# PATH folders.
Expand All @@ -201,7 +201,8 @@ def check_supported_analyzers(analyzers):
# Check version compatibility of the analyzer binary.
if analyzer_bin:
analyzer = supported_analyzers[analyzer_name]
error = analyzer.is_binary_version_incompatible(check_env)
error = analyzer.is_binary_version_incompatible(
context.get_analyzer_env(analyzer_name))
if error:
failed_analyzers.add((analyzer_name,
f"Incompatible version: {error} "
Expand All @@ -211,7 +212,9 @@ def check_supported_analyzers(analyzers):
available_analyzer = False

if not analyzer_bin or \
not host_check.check_analyzer(analyzer_bin, check_env):
not host_check.check_analyzer(analyzer_bin,
context.
get_analyzer_env(analyzer_name)):
# Analyzers unavailable under absolute paths are deliberately a
# configuration problem.
failed_analyzers.add((analyzer_name,
Expand Down
11 changes: 8 additions & 3 deletions analyzer/codechecker_analyzer/host_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,22 @@ def check_analyzer(compiler_bin, env):
clang_version_cmd = [compiler_bin, '--version']
LOG.debug_analyzer(' '.join(clang_version_cmd))
try:
res = subprocess.call(
proc = subprocess.Popen(
clang_version_cmd,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
errors="ignore")
if not res:
out, err = proc.communicate()
LOG.debug_analyzer("return code %d", proc.returncode)
if not proc.returncode:
return True

LOG.debug_analyzer("ENV:")
LOG.debug_analyzer(env)
LOG.debug_analyzer('Failed to run: "%s"', ' '.join(clang_version_cmd))
LOG.debug_analyzer('stdout: %s', out)
LOG.debug_analyzer('stderr: %s', err)
return False

except OSError as oerr:
Expand Down

0 comments on commit b1b40c5

Please sign in to comment.