Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,21 @@ codechecker_extension = use_extension(
"module_register_default_codechecker",
)
use_repo(codechecker_extension, "default_codechecker_tools")


bazel_dep(name = "toolchains_llvm", version = "1.7.0")

# Configure and register the toolchain.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
name = "llvm_toolchain",
llvm_version = "20.1.4",
extra_llvm_distributions = {
"LLVM-20.1.4-Linux-ARM64.tar.xz": "4de80a332eecb06bf55097fd3280e1c69ed80f222e5bdd556221a6ceee02721a",
"LLVM-20.1.4-Linux-X64.tar.xz": "113b54c397adb2039fa45e38dc8107b9ec5a0baead3a3bac8ccfbb65b2340caa",
"LLVM-20.1.4-macOS-ARM64.tar.xz": "debb43b7b364c5cf864260d84ba1b201d49b6460fe84b76eaa65688dfadf19d2",
"clang+llvm-20.1.4-x86_64-pc-windows-msvc.tar.xz": "2b12ac1a0689e29a38a7c98c409cbfa83f390aea30c60b7a06e4ed73f82d2457",
},
)

use_repo(llvm, "llvm_toolchain_llvm")
14 changes: 12 additions & 2 deletions src/codechecker.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,23 @@ def _codechecker_impl(ctx):
},
)

llvm_bin_dir = ctx.files._llvm_toolchain[0].dirname

ctx.actions.run(
inputs = depset(
[
ctx.outputs.codechecker_script,
ctx.outputs.codechecker_commands,
ctx.outputs.codechecker_skipfile,
config_file,
] + source_files,
] + source_files + ctx.files._llvm_toolchain,
),
outputs = [
codechecker_files,
ctx.outputs.codechecker_log,
],
executable = ctx.outputs.codechecker_script,
arguments = [],
arguments = [llvm_bin_dir],
# executable = python_path(ctx),
# arguments = [ctx.outputs.codechecker_script.path],
mnemonic = "CodeChecker",
Expand Down Expand Up @@ -176,6 +178,10 @@ codechecker = rule(
default = None,
doc = "CodeChecker configuration",
),
"_llvm_toolchain": attr.label(
default = "@llvm_toolchain_llvm//:bin",
doc = "If the llvm_toolchain is obtained through bazel, provide the PATH to its bin directory here (e.g. @llvm_toolchain_llvm//:bin)",
),
"skip": attr.string_list(
default = [],
doc = "List of skip/ignore file rules. " +
Expand Down Expand Up @@ -261,6 +267,10 @@ _codechecker_test = rule(
cfg = platforms_transition,
doc = "CodeChecker configuration",
),
"_llvm_toolchain": attr.label(
default = "@llvm_toolchain_llvm//:bin",
doc = "If the llvm_toolchain is obtained through bazel, provide the PATH to its bin directory here (e.g. @llvm_toolchain_llvm//:bin)",
),
"platform": attr.string(
default = "", #"@platforms//os:linux",
doc = "Platform to build for",
Expand Down
4 changes: 4 additions & 0 deletions src/codechecker_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ def analyze():
env.update(codechecker_env)
if "PATH" not in env:
env["PATH"] = "/bin" # NOTE: this is workaround for CodeChecker 6.24.4
if sys.argv[1] != "":
env["PATH"] = os.path.abspath(sys.argv[1]) + os.pathsep + env["PATH"]
logging.debug("env: %s", str(env))

output = execute(f"{CODECHECKER_PATH} analyzers --details", env=env)
Expand All @@ -198,6 +200,8 @@ def analyze():
# This can be removed once codechecker 6.16.0 is used.
# command += " --keep-gcc-intrin"
logging.info("Running CodeChecker analyze...")
output = execute(f"{CODECHECKER_PATH} analyzers", env=env)
logging.info("Output:\n\n%s\n", output)
output = execute(command, env=env)
logging.info("Output:\n\n%s\n", output)
if output.find("- Failed to analyze") != -1:
Expand Down
Loading