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

gir files are Linux-only #35

Closed
matthewbauer opened this issue Apr 21, 2019 · 12 comments
Closed

gir files are Linux-only #35

matthewbauer opened this issue Apr 21, 2019 · 12 comments

Comments

@matthewbauer
Copy link

These .gir files only work on Linux systems! For instance g_desktop_app_info_get_type is not available in macOS systems (g_osx_app_info_get_type is instead). Perhaps these files could be generated on the fly for each platform?

@GuillaumeGomez
Copy link
Member

I have to admit that I don't know how to support nicely such cases...

Any idea @EPashkin @sdroege ?

@EPashkin
Copy link
Member

GOsxAppInfo is separate class that replaces GDesctopAppInfo when "HAVE_COCOA" defined.
It seems don't have even public constructor, only 2 function defined besides g_osx_app_info_get_type

GLIB_AVAILABLE_IN_2_52
char  * g_osx_app_info_get_filename       (GOsxAppInfo *info);

GLIB_AVAILABLE_IN_2_52
GList * g_osx_app_info_get_all_for_scheme (const gchar *scheme);

Last return list of GAppInfo interfaces and seems count as constructor.

So we can add cfg_condition "not(osx)" to GDesctopAppInfo and then implement GOsxAppInfo and its functions manually.

@sdroege
Copy link
Member

sdroege commented Apr 21, 2019

We have a similar problem in GStreamer with GstGL-1.0.gir, just worse. The API available there depends not only on the OS but also on the available GL platform(s). The way how we solved that there is by merging the XML parts of other platforms into one for the bindings, and via the .toml configuration of gir give each its own Cargo feature.

Works but is ugly, but I don't see a better solution for this with the current way how gobject-introspection works.

@samm-git
Copy link

Also on macos it is causing issue with gio:

  "_g_desktop_app_info_get_implementations", referenced from:
      gio::auto::desktop_app_info::DesktopAppInfo::get_implementations::h39f8b9ded749059c in librsvg_c_api.a(gio-a9fe66c4b1029806.gio.6bhpekaq-cgu.7.rcgu.o)
  "_g_desktop_app_info_get_type", referenced from:
      _$LT$gio..auto..desktop_app_info..DesktopAppInfo$u20$as$u20$glib..types..StaticType$GT$::static_type::h1de2af8b073eef74 in librsvg_c_api.a(gio-a9fe66c4b1029806.gio.6bhpekaq-cgu.7.rcgu.o)
  "_g_desktop_app_info_new", referenced from:
      gio::auto::desktop_app_info::DesktopAppInfo::new::h7e539e264f012c4b in librsvg_c_api.a(gio-a9fe66c4b1029806.gio.6bhpekaq-cgu.7.rcgu.o)
  "_g_desktop_app_info_new_from_keyfile", referenced from:
      gio::auto::desktop_app_info::DesktopAppInfo::new_from_keyfile::hdd23e166fd1f7916 in librsvg_c_api.a(gio-a9fe66c4b1029806.gio.6bhpekaq-cgu.7.rcgu.o)
  "_g_desktop_app_info_search", referenced from:
      gio::desktop_app_info::_$LT$impl$u20$gio..auto..desktop_app_info..DesktopAppInfo$GT$::search::h194a199f99b5d7f6 in librsvg_c_api.a(gio-a9fe66c4b1029806.gio.6bhpekaq-cgu.7.rcgu.o)

These are Linux only and not defined in macos gio.

@sdroege
Copy link
Member

sdroege commented Jan 15, 2020

Can you create an issue against gio for that? Unfortunately there is no such information in the gir files so we need to manually configure that on our side.

@samm-git
Copy link

Thank you for reply. I dont understand why it should be issue to gir. On my local file in the ~/gtk/inst/share/gir-1.0 there is no such functions, so i think the whole idea that gir-s must be same on all platforms is just nonsense.

@sdroege
Copy link
Member

sdroege commented Jan 15, 2020

The problem is that we need to generate the bindings once from a single .gir file as otherwise it would have to be generated every time and we would have no control over how broken your personal .gir files are and in what state they're in, and more importantly everybody would have their own version of the bindings and there would be no reproducability.

The problem with gobject-introspection is that it's not well-designed but it's the best and only thing we have right now, so we have to work around such things. Meaning in your specific case that in gio that specific API has to be marked as not available on macOS.

@samm-git
Copy link

Got it. yes, gir is not very well designed. i see that you have already #[cfg(any(not(windows), feature = "dox"))] in the rs, probably same needed for macos for the g_desktop_app_info*. Will be happy to test that. For now its breaking librsvg

@sdroege
Copy link
Member

sdroege commented Jan 15, 2020

Yeah that's why I was asking you to create an issue for gio so that's being kept track of and can be fixed :)

@samm-git
Copy link

Ah, so for gtk-rs/gio. not for glib/gio :)

@sdroege
Copy link
Member

sdroege commented Jan 15, 2020

Ah yes, sorry for not being more clear

@bilelmoussaoui
Copy link
Member

I guess this something we can close, as it is not really related to this repository and we can't do much about it with the current design of GIR. The best we could do is manually implement those platform specific functions

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

6 participants