Skip to content
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

fix: Add option to skip target without srcs #447

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

johan-vcc
Copy link

Description

Add option 'skip_if_no_srcs' to lint_clang_tidy aspect.
Set to True to skip target if it provides CcInfo but has no source files. By default this will generate an error.

See issue #406

Adding an option to skip these targets enables us to run ./lint.sh //package//... even if some target has no source files, e.g. code generation targets.

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes
    Add option 'skip_if_no_srcs' to lint_clang_tidy aspect.

Test plan

  • Manual testing; please provide instructions so we can reproduce:
    bazel build with lint_clang_tidy_aspect for a target that provides 'CcInfo' but does not have 'srcs' attribute.
    With skip_if_no_srcs set to True:
    Build completes with empty target.AspectRulesLintClangTidy.out file.
    Without new option / new option set to False:
File ".../aspect_rules_lint~/lint/clang_tidy.bzl", line 186, column 38, in _filter_srcs
                return [s for s in rule.files.srcs if _is_source(s)]
Error: No attribute 'srcs' in files. Make sure there is a label or label_list type attribute with this name

Add option 'skip_if_no_srcs' to lint_clang_tidy aspect
Set to True to skip target if it provides CcInfo but has no source files. By default this will generate an error.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants