Skip to content

Commit 29b78f9

Browse files
authored
Add debug mode (#95)
Why: We want to provide useful debug messages to users without cluttering the default output. What: Added a new tag `"debug"`, which, if set allows calls of the `warning` function to print debug messages. Addresses: fixes: #94
1 parent 87e30ab commit 29b78f9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/codechecker.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ load(
1414
"per_file.bzl",
1515
"per_file_test",
1616
)
17+
load(
18+
"tools.bzl",
19+
"warning"
20+
)
1721

1822
def get_platform_alias(platform):
1923
"""

src/per_file.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
55
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
6+
load("@bazel_codechecker//src:tools.bzl", "warning")
67

78
def _run_code_checker(
89
ctx,
@@ -182,8 +183,7 @@ def _compile_info_aspect_impl(target, ctx):
182183
elif src.extension.lower() in ["cc", "cpp", "cxx", "c++"]:
183184
flags = cxx_flags
184185
else:
185-
# FIXME: Create verbose mode, show warning only if thats enabled
186-
print(
186+
warning(
187187
"Unknown file extension for {} defaulting to c++ compile flags".
188188
format(src.short_path)
189189
)

src/tools.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,10 @@ default_codechecker_tools = repository_rule(
9898

9999
def register_default_codechecker():
100100
default_codechecker_tools(name = "default_codechecker_tools")
101+
102+
def warning(ctx, msg):
103+
"""
104+
Prints message if the debug tag is enabled.
105+
"""
106+
if "debug" in ctx.attr.tags:
107+
print(msg)

0 commit comments

Comments
 (0)