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

A symbol is missing in inherited dependencies #69

Closed
xairy opened this issue May 10, 2019 · 4 comments
Closed

A symbol is missing in inherited dependencies #69

xairy opened this issue May 10, 2019 · 4 comments

Comments

@xairy
Copy link

xairy commented May 10, 2019

Hi,

The documentation for the referenced field of the Symbol class says that it includes dependencies inherited from surrounding menus and if's.. However when I look at the value of the referenced field for COMEDI_NI_USB6501 (source), I don't see the USB symbol there:

> print(kconf.syms['COMEDI_NI_USB6501'].referenced)
set([<symbol COMEDI_USB_DRIVERS, tristate, "Comedi USB drivers", value m, user value m, visibility m, direct deps m, drivers/staging/comedi/Kconfig:1183>, <symbol COMEDI, tristate, "Data acquisition support (comedi)", value m, user value m, visibility y, direct deps y, drivers/staging/comedi/Kconfig:1>, <symbol STAGING, bool, "Staging drivers", value y, user value y, visibility y, direct deps y, drivers/staging/Kconfig:1>])

COMEDI_NI_USB6501 depends on COMEDI_USB_DRIVERS through an if, and COMEDI_USB_DRIVERS in turns depends on USB through a depends on. So AFAIU USB should be in referenced.

Is this a bug or there's something I misunderstand?

Thanks!

@ulfalizer
Copy link
Owner

ulfalizer commented May 10, 2019

Hello,

referenced isn't transitive. It only includes "direct" references.

The reason dependencies from surrounding ifs and menus count as direct references has to do with dependency propagation. Basically, if FOO is just a shorthand for adding depends on FOO to each item within the if, and a depends on on a menu also gets propagated to all the items in it.

These two ways of defining two symbols A and B are equivalent:

With if:

if B

config A
	bool

endif

if C

config B
	bool

endif

With depends on:

config A
	bool
	depends on B

config B
	bool
	depends on C

In both cases, A ends with just B in referenced, and B ends up with just C.

To get transitive references, you'll have to calculate the transitive closure (I think that's the term...), recursively expanding the .referenced until no new symbols appear.

If you're only interested in the direct dependencies of a symbol (its depends on, possibly inherited), have a look at Symbol.direct_dep btw. You can extract all the symbols in it with the global expr_items() function.

@xairy
Copy link
Author

xairy commented May 10, 2019

Ah, OK, I see. Maybe it makes sense to mention this in the documentation? The word inherited seems confusing to me here. Thanks!

ulfalizer added a commit that referenced this issue May 10, 2019
 - Point out why dependencies from surrounding if's and menus are
   included

 - Clarify that .referenced isn't transitive. Only "direct" references
   are included.

 - Give a hint about direct dependencies and expr_items()

Prompted by #69.
@ulfalizer
Copy link
Owner

Clarified the docstring and added some more details in 814e2de. Does it look okay?

@xairy
Copy link
Author

xairy commented May 10, 2019

Looks good, thanks you!

@xairy xairy closed this as completed May 10, 2019
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

No branches or pull requests

2 participants