PMunch/futhark

Question

Shinyzenith opened this issue · 10 comments

Hi! I'm using futhark to wrap around wlroots and to compile the wlr/types/xdg_shell.h header we need to generate a xdg-shell-protocol.h file with wayland-scanner at compile time

I don't know how to get futhark to integrate with this process, as an alternative I am copying the header manually to /usr/include after compiling them with sudo which is not safe and not distribution ready.

If I understand your issue correctly it seems like you're struggling with how to pass paths to your library to Futhark. If you clone this repository: https://github.com/swaywm/wlroots and then add a path "include" where the include part is a path to the include folder in that library, then you should be able to simply add "wlr/types/xdg_shell.h" as a file in the Futhark importc statement. To generate the "xdg-shell-protocol.h" file in that folder it should be a simple matter of running the build commands as a normal user, it should appear in the include folder, if not you simply need to pass the folder it appears in with path as well.

Hi! First of all, I'm loving futhark, it's dead simple.

Cloning the repo works but it might not be compatible with the currently installed wlroots version. And following your method would still require me to use sudo to move the header in the include folder. I believe it would be easier if I could pass a -I flag to opir to read my protocol headers directory, is that possible?

Yes, that is exactly what the path and sysPath things you can pass to Futhark does. The difference is that sysPath only tells Opir where to find stuff, while path will also generate code from any header which might be imported within that folder. Do you have an example of what you're doing? Then it would be much easier to show you.

I appreciate you being thorough with the issue, you have my gratitude. https://github.com/waycrate/nim-wl

Right, so assuming you have cloned wlroots into a folder /home/shinyzenith/wlroots you could do something like this:

import futhark
importc:
  sysPath "/usr/lib/clang/13.0.1/include"
  path "/home/shinyzenith/wlroots/include"
  compilerArg "-DWLR_USE_UNSTABLE"
  "wlr/types/wlr_xdg_shell.h"

This tells Opir to also consider the /home/shinyzenith/wlroots/include folder when doing imports. Since it is using path instead of sysPath any header file that is imported by wlr_xdg_shell.h which resides somewhere within /home/shinyzenith/wlroots/include will also be imported automatically (which is why I've removed the rest of the imports, I'm not sure if all those are actually grabbed by that import, if some are missing just add them back in).

Understood, can I specify multiple paths?

Yes, you can pass as many paths as you'd like.

Thank you so much, it works perfectly.

Oh and one last thing, I had some errors while wrapping libwayland, should I just ask that in this issue or open a new one?

Just open a new one :)