Skip to content

Commit

Permalink
Add verbosity option to aspect
Browse files Browse the repository at this point in the history
  • Loading branch information
martis42 committed Jan 15, 2024
1 parent 7bcf20b commit 3455428
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [Recursion](#recursion)
- [Implementation_deps](#Implementation_deps)
- [Target mapping](#target-mapping)
- [Verbosity](#verbosity)
- [Applying automatic fixes](#applying-automatic-fixes)
- [Assumptions of use](#assumptions-of-use)
- [Supported Platforms](#supported-platforms)
Expand Down Expand Up @@ -206,6 +207,16 @@ your_aspect = dwyu_aspect_factory(target_mapping = "<mapping_target_created_by_t

This is demonstrated in the [target_mapping example](/examples/target_mapping).

## Verbosity

One can configure the DWYU aspect to print debugging information.

Activate this behavior via:

```starlark
your_aspect = dwyu_aspect_factory(verbose = True)
```

# Applying automatic fixes

> \[!WARNING\]
Expand Down
6 changes: 3 additions & 3 deletions src/aspect/dwyu.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ def dwyu_aspect_impl(target, ctx):
defines = _gather_defines(ctx, target_compilation_context = target[CcInfo].compilation_context),
output_path = "{}_processed_target_under_inspection.json".format(target.label.name),
is_target_under_inspection = True,
verbose = False,
verbose = ctx.attr._verbose,
)

target_deps, target_impl_deps = _preprocess_deps(ctx)

# TODO Investigate if we can prevent running this multiple times for the same dep if multiple
# target_under_inspection have the same dependency
processed_deps = _process_dependencies(ctx, target = target, deps = target_deps, verbose = False)
processed_impl_deps = _process_dependencies(ctx, target = target, deps = target_impl_deps, verbose = False)
processed_deps = _process_dependencies(ctx, target = target, deps = target_deps, verbose = ctx.attr._verbose)
processed_impl_deps = _process_dependencies(ctx, target = target, deps = target_impl_deps, verbose = ctx.attr._verbose)

report_file = ctx.actions.declare_file("{}_dwyu_report.json".format(target.label.name))
args = ctx.actions.args()
Expand Down
7 changes: 6 additions & 1 deletion src/aspect/factory.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def dwyu_aspect_factory(
recursive = False,
skipped_tags = None,
target_mapping = None,
use_implementation_deps = False):
use_implementation_deps = False,
verbose = False):
"""
Create a "Depend on What You Use" (DWYU) aspect.
Expand All @@ -22,6 +23,7 @@ def dwyu_aspect_factory(
use_implementation_deps: If true, ensure cc_library dependencies which are used only in private files are
listed in implementation_deps. Only available if flag
'--experimental_cc_implementation_deps' is provided.
verbose: If true, print debugging information about what DWYU does internally.
Returns:
Configured DWYU aspect
"""
Expand Down Expand Up @@ -75,5 +77,8 @@ def dwyu_aspect_factory(
"_use_implementation_deps": attr.bool(
default = use_implementation_deps,
),
"_verbose": attr.bool(
default = verbose,
),
},
)

0 comments on commit 3455428

Please sign in to comment.