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
support excude directories or files #252
Conversation
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.
Hey @liugang , thanks for this. I agree that this functionality might be desired. Although I would not solve it as you did. Can I ask you for a change?
bear/main.py.in
Outdated
@@ -296,9 +296,9 @@ def intercept_build(): | |||
if args.append and os.path.isfile(args.cdb): |
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.
Could you filter out the excluded files before calling the CompilationDatabase.save
method? I would like to keep the save functionality as is. It can be a simple function like this:
def exclude(candidates, directories):
# type: (Iterable[Compilation], List[str]) -> Iterable[Compilation]
def is_no_excluded(candidate):
return not any(candidate.is_in(directory) for directory in directories)
return (candidate for candidate in candidates if is_no_excluded(candidate))
This would require to create an is_in
method on the Compilation
class. Please use the os.path
module to check if the directory contains the file or not. (String comparision might be misleading.)
Hi @rizsotto I add |
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.
Thanks for the update.
- Please extract the logic which decide about which files to exclude.
- I would still prefer the exclude to work on iterators. And not part of any existing logic.
- I would like to have a few test cases to prove that it's actually working as expected.
bear/main.py.in
Outdated
@@ -576,7 +580,32 @@ class Compilation: | |||
flags=candidate.flags, | |||
output=output) |
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.
Could you make it a bit simpler? Like...
if os.path.isfile(result.source) and is_not_excluded(result.source, excludes):
yield result
bear/main.py.in
Outdated
@@ -555,15 +560,14 @@ class Compilation: | |||
return cls.iter_from_execution(execution, category) | |||
|
|||
@classmethod | |||
def iter_from_execution(cls, execution, category): | |||
def iter_from_execution(cls, execution, category, args=None): |
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.
Please don't use default value.
Hi @rizsotto It has been modified.
|
In the actual big project, the effect is very obvious bear -e opensources -e driver -e kernel -e sdk -e tools make
|
I was looking into this PR. Was decided to go in a different way. Created the ticket #261 to draft the design for this problem. |
Fix or Enhancement?
For some large projects, we don't care too many subprojects, such as the Linux kernel, third-party libraries, and so on.
So let the bear support the excude directory or file, then reduce the cache size and speed up the index.
e.g. ccls, cquery
Environment