-
Notifications
You must be signed in to change notification settings - Fork 4
Idea for CodeChecker toolchain #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| """ | ||
| This file provides the toolchain rule for CodeChecker | ||
| """ | ||
|
|
||
| CodeCheckerInfo = provider( | ||
| doc = "This provider provides the executable path for CodeChecker", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| fields = [ | ||
| "executable", | ||
| ], | ||
|
Comment on lines
+7
to
+9
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip: I think this should be a dict |
||
| ) | ||
|
|
||
| def _codechecker_toolchain_impl(ctx): | ||
| toolchain_info = platform_common.ToolchainInfo( | ||
| codecheckerinfo = CodeCheckerInfo( | ||
| executable = ctx.attr.analyzer_binary, | ||
| ), | ||
| ) | ||
| return [toolchain_info] | ||
|
|
||
| codechecker_toolchain = rule( | ||
| implementation = _codechecker_toolchain_impl, | ||
| attrs = { | ||
| "analyzer_binary": attr.string(), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess "analyzer" is not a good name here |
||
| }, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,8 @@ def _run_code_checker( | |
| content = "\n".join(ctx.attr.skip), | ||
| ) | ||
|
|
||
| info = ctx.toolchains["//src:toolchain_type"].codecheckerinfo | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) ) |
||
|
|
||
| if "--ctu" in options: | ||
| inputs = [ | ||
| compile_commands_json, | ||
|
|
@@ -86,6 +88,7 @@ def _run_code_checker( | |
| outputs = outputs, | ||
| executable = ctx.outputs.per_file_script, | ||
| arguments = [ | ||
| info.executable, | ||
| data_dir, | ||
| src.path, | ||
| codechecker_log.path, | ||
|
|
@@ -155,6 +158,8 @@ def _create_wrapper_script(ctx, options, compile_commands_json, config_file): | |
| ) | ||
|
|
||
| def _per_file_impl(ctx): | ||
| info = ctx.toolchains["//src:toolchain_type"].codecheckerinfo | ||
| print("CodeChecker path resolved:", info.executable) | ||
| compile_commands = None | ||
| for output in compile_commands_impl(ctx): | ||
| if type(output) == "DefaultInfo": | ||
|
|
@@ -258,4 +263,5 @@ per_file_test = rule( | |
| "test_script": "%{name}/test_script.sh", | ||
| }, | ||
| test = True, | ||
| toolchains = ["//src:toolchain_type"], | ||
| ) | ||
There was a problem hiding this comment.
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...