xcbgen: Module.direct_imports does not contain all direct imports
It took me way to long to figure out this trivial problem, so I want to at least document my findings here.
xinput.xml <import>
s both xfixes and xproto: https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/blob/2b3559c10c18eb63e61efdc8a030765d624a0fba/src/xinput.xml#L37-38
However, the resulting xcbgen.Module
instance only contains xfixes
in its .direct_imports
. The xproto
import is lost.
What happens is that first the xfixes
import is handled here: https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/blob/2b3559c10c18eb63e61efdc8a030765d624a0fba/xcbgen/matcher.py#L27-28
During the import of xfixes
, xproto
is imported (because xfixes
imports xproto
): https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/blob/2b3559c10c18eb63e61efdc8a030765d624a0fba/src/xfixes.xml#L30
Now, xproto
is an indirect import, so it is not added to direct_imports
here (which is correct): https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/blob/2b3559c10c18eb63e61efdc8a030765d624a0fba/xcbgen/state.py#L130-136
Later, the import of xproto
in xinput
is parsed. Since xproto
was already imported, this <import>
is just ignored here: https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/blob/2b3559c10c18eb63e61efdc8a030765d624a0fba/xcbgen/matcher.py#L27-28
Thus, in the end, xproto
does not end up in the direct_imports
of xinput
.
This issue does not affect libxcb (since it only uses imports for generating #include
statements and thanks to include guards, the difference that this bug causes is unimportant). Thus, I guess this issue can just be ignored, but I still wanted to at least report my findings.