Skip to content

Introduce CodeChecker toolchain#226

Open
furtib wants to merge 8 commits into
Ericsson:mainfrom
furtib:codechecker-toolchain
Open

Introduce CodeChecker toolchain#226
furtib wants to merge 8 commits into
Ericsson:mainfrom
furtib:codechecker-toolchain

Conversation

@furtib

@furtib furtib commented May 19, 2026

Copy link
Copy Markdown
Contributor

Why:
We want to use toolchains to determine which CodeChecker binary to use.

What:

Addresses:
none

Notes:

  • Looking around in other toolchains: rules_go and rules_python it seems toolchains are usually under a folder named the program - in out case CodeChecker (python for rules_python, go for rules_go) - this seems to be to have the toolchain path be //codechecker:toolchain_type instead of //src:toolchain_type.

@furtib furtib requested review from Szelethus and nettle May 19, 2026 09:13
@furtib furtib self-assigned this May 19, 2026
@furtib furtib added the help wanted Extra attention is needed label May 19, 2026
@furtib furtib force-pushed the codechecker-toolchain branch from 17263c7 to d51ce3b Compare May 19, 2026 09:16
@furtib furtib changed the title Add CodeChecker toolchain Idea for CodeChecker toolchain May 19, 2026
@furtib furtib force-pushed the codechecker-toolchain branch 2 times, most recently from 1007067 to 2f2f858 Compare May 19, 2026 20:32

@nettle nettle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start! I think this is right way forward!

Comment thread src/codechecker_toolchain.bzl Outdated
Comment thread src/codechecker_toolchain.bzl Outdated
"""

CodeCheckerInfo = provider(
doc = "This provider provides the executable path for CodeChecker",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should list all parameters including clang, clang-tidy and maybe more

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a way to define clang and clang-tidy.
For everything else, we can extend it later.

Comment thread src/codechecker_toolchain.bzl Outdated
Comment thread src/per_file.bzl
content = "\n".join(ctx.attr.skip),
)

info = ctx.toolchains["//src:toolchain_type"].codecheckerinfo

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we discussed that to get rid of "src" you may try alias. (I havent tried myself though :) )

Comment thread src/BUILD Outdated

codechecker_toolchain(
name = "codechecker_local",
analyzer_binary = "CodeChecker", # Find it in PATH ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should find a way how to make it flexible. At least we should be able to pass CodeChecker binary by absolute path, try to find in the PATH (current implementation), as a Label, maybe via env var, maybe somehow else...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on this.
I want to create targets with the repository rule and have those be the label() targets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

All binary targets are now labels.

@furtib furtib force-pushed the codechecker-toolchain branch from 8c9fc81 to 93dd1e4 Compare June 17, 2026 14:39
@furtib furtib marked this pull request as ready for review June 17, 2026 15:52
@furtib furtib requested a review from nettle June 17, 2026 15:52
@furtib furtib changed the title Idea for CodeChecker toolchain Introduce CodeChecker toolchain Jun 18, 2026

@nettle nettle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the right direction!

Comment thread README.md
Comment on lines +490 to +492
clang_tidy_binary = "@my_tools//:clang-tidy",
clangsa_binary = "@my_tools//:clang",
codechecker_binary = "@my_tools//:CodeChecker",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description and examples are missing for @my_tools//:CodeChecker etc

CodeCheckerInfo = provider(
doc = "This provider provides the executable path for CodeChecker and its related tools",
fields = {
"clang_tidy_bin": "clang-tidy executable",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need suffix "_bin"? Does it have any meaning?

Comment thread src/codechecker_script.py
EXECUTION_MODE = "{Mode}"
VERBOSITY = "{Verbosity}"
CODECHECKER_PATH = "{codechecker_bin}"
CODECHECKER_PATH = os.path.realpath("{codechecker_bin}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... we call realpath() only for CodeChecker?

codechecker_toolchain = rule(
implementation = _codechecker_toolchain_impl,
attrs = {
"clang_tidy_binary": attr.label(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same question: "_binary" - do we need?

Comment thread MODULE.bazel
use_repo(codechecker_extension, "default_codechecker_tools")

register_toolchains(
"//src:codechecker_local_toolchain",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what is the meaning of "locat"?
Is there a "global" alternative?

@@ -0,0 +1,46 @@
"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, probably we do not need prefix "codechecker" in the file name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants