libportal icon indicating copy to clipboard operation
libportal copied to clipboard

meson: default the backends list to 'auto'

Open whot opened this issue 3 years ago • 5 comments

This changes the 'backends' option to the special string 'auto' - all backends become optional by default and are built if the dependencies are available.

If need be this can be combined with explicitly listing a backend, so backends=auto,gtk3 will require the GTK3 backend and optionally build the Qt5 and GTK4 backends. A summary is printed to list the actually enabled backends and a warning where no backends are enabled at all.

This makes life easier for new users since the majority of them will not have GTK3, GTK4 and Qt5 headers installed by default and thus are almost guaranteed to run into a meson error on first configure.

Fixes https://github.com/flatpak/libportal/issues/94

whot avatar Jul 01 '22 00:07 whot

cc @eli-schwartz for the inevitable meson magic that already exists for this and that I'm not aware of ;)

whot avatar Jul 01 '22 00:07 whot

gentle ping

whot avatar Jul 14 '22 04:07 whot

gentle ping again

whot avatar Jul 29 '22 02:07 whot

monthly ping again

whot avatar Aug 30 '22 05:08 whot

@GeorgesStavracas - any chance we can merge this? Not having to manually supply the backends to build libportal from git is a rather nice feature.

whot avatar Sep 06 '22 03:09 whot

ping again?

whot avatar Nov 28 '22 21:11 whot

@eli-schwartz I'd actually like to hear your thoughts on the "auto" magic that's happening here. I'm not convinced this is a great idea. Or, at least, I'd love to hear what a Mesonic way to implement this would look like.

GeorgesStavracas avatar Nov 28 '22 22:11 GeorgesStavracas

@whot sorry, completely dropped the ball here

GeorgesStavracas avatar Nov 28 '22 22:11 GeorgesStavracas

My guess would be that the mesonic way would be to have each backend as separate feature option (instead of a "backends" array with a special string). That'd be easy enough to introduce but changes the build invocations.

whot avatar Nov 28 '22 22:11 whot

Yeah, adding a separate option for each one would be the most obvious way to handle it.

If you want to keep the existing option, I guess you could make each option default to auto, and then use something like:

backends = get_option('backends')
x_opt = 'x' in backends ? true : get_option('x')
y_opt = 'y' in backends ? true : get_option('y')

The option will then usually be a feature option, but will be a boolean true (equal to enabled when used inside required: kwargs) if the existing option specifies to build that backend. Check for the dependencies using required: x_opt, and they will use:

  • auto /check by default
  • the feature value specifically passed for that option
  • true / enabled if listed in backends

Whichever one matches last.

eli-schwartz avatar Nov 28 '22 22:11 eli-schwartz

Changed this PR to use -Dbackend-gtk3=enabled and so on. I tried keeping backends as list for backwards compatibility but tbh the conditions got confusing enough (in particular: -Dbackends=gtk3 must also set the others to disabled) that I didn't really see the value in keeping it, so it's removed now.

whot avatar Dec 08 '22 04:12 whot