I'm building some stuff in a custom prefix (say /opt/foo) which relies on some variable in a pc file to detect where to install. For example, take the catalogdir variable in gladeui-2.0. This is normally in /usr/share/glade/catalogs, and when building modules this is looked up for the install destination. I want to locally override this and install in /opt/foo/share/glade/catalogs instead (and I will then have to set the correct runtime env vars for glade to pick this up). There is currently no great way to do this. I tried setting PKG_CONFIG to "pkg-config --define-variable=catalogdir=/opt/foo/share/glade/catalogs", but that breaks when code doesn't look at PKG_CONFIG, and when code expects it to be an executable rather than a full commandline. It is also global, rather than per package. I propose that we allow overriding package variables using environment variables. For instance in the above case one would set PKG_CONFIG_GLADEUI_2_0_CATALOGDIR=/opt/foo/share/glade/catalogs.
Created attachment 116399 [details] [review] Implement environment overrides of package variables
Comment on attachment 116399 [details] [review] Implement environment overrides of package variables Review of attachment 116399 [details] [review]: ----------------------------------------------------------------- Clever. I'd like to think there was another way to do this, but I think you may have come up with the most surefire way. You could add an overriding pc file, but that's cumbersome. I can't think of any good reason not to take this. Could you please document this in pkg.1? A comment in the code above the block about what's going on would be helpful, too. ::: pkg-config-0.28/pkg.c.env @@ +1012,4 @@ > } > > char * > +var_to_env_var (const char *key, const char *var) It's called key in the struct, but here I think it would be clearer if the local variable was called pkg. @@ +1043,5 @@ > + char *env_var = var_to_env_var (pkg->key, var); > + const char *env_var_content = g_getenv (env_var); > + g_free (env_var); > + if (env_var_content) > + return g_strdup (env_var_content); Can you add a debug statement here that the setting was overrident? Use debug_spew().
Created attachment 116400 [details] [review] New version I don't really know how to write manpages, but this one has at least some semblance of docs.
Created attachment 116401 [details] [review] Now with comment too
Created attachment 116478 [details] [review] Allow overriding package variables with env vars pkg-config allows a way to override package variables through the --define-prefix interface, but this is very cumbersome to do in a global way since it always needs to be passed on the command line and the override cannot be scoped to a single packge. Allow overriding package variables using environment variables of the form PKG_CONFIG_$PACKAGE_$VARIABLE. For example, setting PKG_CONFIG_GLADEUI_2_0_CATALOGDIR will override the variable "catalogdir" in the "gladeui-2.0" package.
While integrating this patch, I added a test case for it. See the attached patch (against git HEAD). Unfortunately, it seems to break as the variable is derived too late and won't be referenced correctly when resolving other variables. For instance, if prefix=/usr and libdir=${prefix}/lib but I override prefix to /foo, libdir is still /usr/lib. I think this needs to happen earlier. You might have to take a look at how --define-variable works.
The reason it breaks is because pkg->key is not set until after we've fully parsed the pc file, and at that time the variables have already been resolved. So, when we resolve them pkg->key is NULL and we don't know what env var to look up in.
Created attachment 116498 [details] [review] Pass key into parse_package_key so it can be set early We will need this to properly pick up environment-overridden per-package vairables.
Created attachment 116499 [details] [review] Allow overriding package variables with env vars pkg-config allows a way to override package variables through the --define-prefix interface, but this is very cumbersome to do in a global way since it always needs to be passed on the command line and the override cannot be scoped to a single packge. Allow overriding package variables using environment variables of the form PKG_CONFIG_$PACKAGE_$VARIABLE. For example, setting PKG_CONFIG_GLADEUI_2_0_CATALOGDIR will override the variable "catalogdir" in the "gladeui-2.0" package.
(Note: The last patch did not actually change)
Created attachment 116501 [details] [review] testoverlay: Add new input stacking test In this case we have a bunch of interactive main children of the overlay, and then a centered overlay that contains both non-interactive (labels) and interactive (entry) widgets. This shows off a problem where the non-interactive parts (the labels) steals input from the overlay main children (breaks button click and hover effects). https://bugzilla.gnome.org/show_bug.cgi?id=750568
Created attachment 116502 [details] [review] gdk: Add gdk_window_set_pass_through An pass_through window is something you can draw in but does not affect event handling. Normally if a window has with no event mask set for a particular event then input events in it go to its parent window (X11 semantics), whereas if pass_through is enabled the window below the window will get the event. The later mode is useful when the window is partially transparent. Note that an pass-through windows can have child windows that are not pass-through so they can still get events on some parts. Semantically, this behaves the same as an regular window with gdk_window_set_child_input_shapes() called on it (and re-called any time a child is changed), but its far more efficient and easy to use. This allows us to fix the testoverlay input stacking test. https://bugzilla.gnome.org/show_bug.cgi?id=750568
Created attachment 116503 [details] [review] overlay: Add reorder_overlay() This allows you to control the z-ordering of overlay children https://bugzilla.gnome.org/show_bug.cgi?id=750568
Created attachment 116504 [details] [review] GtkOverlay: Add support for input pass-through overlays For these widgets we set pass-through on the child window so that input over these widgets (that are not on a child input window) goes to the window below the overlay. https://bugzilla.gnome.org/show_bug.cgi?id=750568
Created attachment 116505 [details] [review] testoverlay: Fix test by using add_pass_through_overlay https://bugzilla.gnome.org/show_bug.cgi?id=750568
Created attachment 116506 [details] [review] testoverlay: Add test for overlay z ordering https://bugzilla.gnome.org/show_bug.cgi?id=750568
Eh, sorry for the spam! Got the wrong bug link into git-bz.
ping? Any chance to get the latest version reviewed?
Ping again? This is very useful when building app bundles as some modules pick up installdir from system .pc files and try to write to /usr, not the prefix.
Fixed in ae0a8b1. I had to tweak the 2nd test case to skip on windows since apparently environment variables are case insensitive there. :/ Thanks!
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.