gobject-introspection: improve support for structuredAttrs

With `__structuredAttrs = true;` $outputLib is not available as an exported environment variable.
To avoid polluting the env with a generic variable that could be abused, use a bespoke
and easily greppable variable.
This commit is contained in:
Stefan Frijters
2025-12-19 02:12:29 +01:00
parent 1f082cdcde
commit b5406a6699
2 changed files with 12 additions and 5 deletions
@@ -2,15 +2,12 @@ diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 64575557..1eb0a2b4 100644
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -95,6 +95,39 @@ def get_windows_option_group(parser):
@@ -95,6 +95,36 @@ def get_windows_option_group(parser):
return group
+def _get_default_fallback_libpath():
+ # Newer multiple-output-optimized stdenv has an environment variable
+ # $outputLib which in turn specifies another variable which then is used as
+ # the destination for the library contents (${!outputLib}/lib).
+ store_path = os.environ.get(os.environ.get("outputLib")) if "outputLib" in os.environ else None
+ store_path = os.environ.get("NIX_GOBJECT_INTROSPECTION_DEFAULT_FALLBACK_LIBPATH")
+ if store_path is None:
+ outputs = os.environ.get("outputs", "out").split()
+ if "lib" in outputs:
@@ -10,7 +10,17 @@ make_gobject_introspection_find_gir_files() {
fi
}
export_gobject_introspection_fallback_path() {
# Newer multiple-output-optimized stdenv has a variable $outputLib,
# which in turn specifies another variable which then is used as
# the destination for the library contents (${!outputLib}/lib).
# We export this so it is available to subprocesses, such as giscanner,
# which we patch to prioritize this variable if available.
export NIX_GOBJECT_INTROSPECTION_DEFAULT_FALLBACK_LIBPATH=${!outputLib}
}
addEnvHooks "$targetOffset" make_gobject_introspection_find_gir_files
addEnvHooks "$targetOffset" export_gobject_introspection_fallback_path
giDiscoverSelf() {
if [ -d "$prefix/lib/girepository-1.0" ]; then