-
Notifications
You must be signed in to change notification settings - Fork 212
Add maxdepth parameter to get_labels function
#3460
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
Add maxdepth parameter to get_labels function
#3460
Conversation
This is used in conjunction with the `transitive` parameter; when `transitive` is true, `maxdepth` can be used to control the maximum depth of the recursion. The default is -1, meaning "no limit". The main use case is to help limit the collection of `cc:inc:` labels to direct dependencies in the cc-rules plugin, since headers used by (library) dependencies shouldn't be required at compilation time. `transitive=True, maxdepth=0` is equivalent to `transitive=False`, so actually there's no need for `transitive` to exist as a parameter at all any more, although it remains for backwards compatibility. It could be removed in a future major release.
src/parse/asp/builtins.go
Outdated
| if all && !transitive { | ||
| log.Fatalf("get_labels can't be called with all set to true when transitive is set to False") | ||
| if all && maxDepth != -1 { | ||
| log.Fatalf("get_labels can't be called with all set to True when transitive is set to False") |
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.
The message here needs to account for maxDepth being greater than 0 (or should this just be maxDepth == 0?)
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.
This is a kludge to work around the fact that transitive still exists as a parameter in the built-in function. In getLabelsInternal's function signature, transitive has been replaced with maxDepth; all && maxDepth != -1 is therefore equivalent to the former all && !transitive (because maxDepth < -1 is forbidden by getLabels, and maxDepth > -1 means "not really transitive: stop recursing this many levels deep").
|
Having said all that, I think there's merit in severing the dependency between |
Add a
maxdepthparameter to theget_labelsbuilt-in function that controls the maximum depth ofget_labels' recursive dependency search. The default is -1, meaning "no limit". The main use case is to help limit the collection ofcc:inc:labels to direct dependencies in the cc-rules plugin, since headers used by transitive (library) dependencies shouldn't be required at compilation time.This is an alternative to (and is in fact a superset of the functionality offered by) the
transitiveparameter:transitive=Trueis equivalent tomaxdepth=-1, andtransitive=Falseis equivalent tomaxdepth=0. Thetransitiveparameter remains for backwards compatibility, although it could now be removed in a future major release.