push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
From 7b2d3699ad117199bc316c7007cc5984c3b09368 Mon Sep 17 00:00:00 2001
From: Maximiliano Sandoval <msandova@gnome.org>
Date: Thu, 20 Mar 2025 22:52:54 +0100
Subject: [PATCH] scanner: Prefer some getters over others
At the moment the current set of heuristics to determine a getter for a
property is good for finding *a* getter. However, if there are multiple
candidates we might declare the wrong method as a getter.
We introduce a priority system to determine which getter candidate is
the most appropriate as the getter. The weight were chosen with gaps in
between so that new and better heuristics have space to thrive.
For a property named `p`, these are the possible getter candidates:
- A method declared via the `(getter p)` annotation
- The method `get_p`
- The method `is_p`
- The method `p`
we declare the getter to be the first candidate in the list for which a
method of the same name is available.
See https://gitlab.gnome.org/GNOME/gjs/-/issues/681.
---
giscanner/maintransformer.py | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index a81b1777..9aaf2578 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -1612,7 +1612,10 @@ method or constructor of some type."""
if not prop.introspectable:
continue
setter = None
- getter = []
+ # They keys are method names of candidates for getters. The values
+ # are priority weights that measure how tasteful was the heuristic
+ # used to propose their candidate.
+ getter = {}
if prop.setter is None:
if prop.writable and not prop.construct_only:
setter = 'set_' + normalized_name
@@ -1620,17 +1623,17 @@ method or constructor of some type."""
setter = prop.setter
if prop.getter is None:
if prop.readable:
- getter = ['get_' + normalized_name]
+ getter[f"get_{normalized_name}"] = 50
# Heuristic: boolean properties can have getters that are
# prefixed by is_property_name, like: gtk_window_is_maximized()
if prop.type.is_equiv(ast.TYPE_BOOLEAN) and not normalized_name.startswith("is_"):
- getter.append(f"is_{normalized_name}")
+ getter[f"is_{normalized_name}"] = 25
# Heuristic: read-only properties can have getters that are
# just the property name, like: gtk_widget_has_focus()
if not prop.writable and prop.type.is_equiv(ast.TYPE_BOOLEAN):
- getter.append(normalized_name)
+ getter[normalized_name] = 10
else:
- getter = [prop.getter]
+ getter[prop.getter] = 99
for method in node.methods:
if not method.introspectable:
continue
@@ -1645,7 +1648,7 @@ method or constructor of some type."""
method.set_property = prop.name
prop.setter = method.name
continue
- if getter is not [] and method.name in getter:
+ if getter is not {} and method.name in getter:
if method.get_property is None:
method.get_property = prop.name
elif method.get_property != prop.name:
@@ -1654,7 +1657,12 @@ method or constructor of some type."""
"mismatched '(get-property %s)' annotation" %
(method.symbol, prop.name, method.get_property))
method.get_property = prop.name
- prop.getter = method.name
+ # Check the priority of the last matching getter
+ current_priority = -1
+ if current_getter := prop.getter:
+ current_priority = getter.get(current_getter, -1)
+ if getter[method.name] >= current_priority:
+ prop.getter = method.name
continue
def _pass_member_numeric_name(self, node):
--
2.48.1

View File

@@ -0,0 +1,13 @@
diff --git a/gir/cairo-1.0.gir.in b/gir/cairo-1.0.gir.in
index e4c9fb3d..3351b184 100644
--- a/gir/cairo-1.0.gir.in
+++ b/gir/cairo-1.0.gir.in
@@ -6,7 +6,7 @@
<package name="@CAIRO_GIR_PACKAGE@"/>
<c:include name="cairo-gobject.h"/>
<namespace name="cairo" version="1.0"
- shared-library="@CAIRO_SHARED_LIBRARY@"
+ shared-library="@cairoLib@/@CAIRO_SHARED_LIBRARY@"
c:identifier-prefixes="cairo"
c:symbol-prefixes="cairo">
<record name="Context" c:type="cairo_t" foreign="1"

View File

@@ -0,0 +1,192 @@
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):
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
+ if store_path is None:
+ outputs = os.environ.get("outputs", "out").split()
+ if "lib" in outputs:
+ # For multiple output derivations let's try whether there is a $lib
+ # environment variable and use that as the base store path.
+ store_path = os.environ.get("lib")
+ elif "out" in outputs:
+ # Otherwise we have a single output derivation, so the libraries
+ # most certainly will end up in "$out/lib".
+ store_path = os.environ.get("out")
+
+ if store_path is not None:
+ # Even if we have a $lib as output, there still should be a $lib/lib
+ # directory.
+ return os.path.join(store_path, 'lib')
+ else:
+ # If we haven't found a possible scenario, let's return an empty string
+ # so that the shared library won't be prepended with a path.
+ #
+ # Note that this doesn't mean that all hope is lost, because after all
+ # we can still use --fallback-library-path to set one.
+ #
+ # Also, we're not returning None, because that would make it very
+ # difficult to disable adding fallback paths altogether using something
+ # like: --fallback-library-path=""
+ return ""
+
+
def _get_option_parser():
parser = optparse.OptionParser('%prog [options] sources',
version='%prog ' + giscanner.__version__)
@@ -214,6 +247,10 @@ match the namespace prefix.""")
parser.add_option("", "--c-include",
action="append", dest="c_includes", default=[],
help="headers which should be included in C programs")
+ parser.add_option("", "--fallback-library-path",
+ action="store", dest="fallback_libpath",
+ default=_get_default_fallback_libpath(),
+ help="Path to prepend to unknown shared libraries")
parser.add_option("", "--filelist",
action="store", dest="filelist", default=[],
help="file containing headers and sources to be scanned")
diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
index 9f8ab5df..af325022 100644
--- a/giscanner/shlibs.py
+++ b/giscanner/shlibs.py
@@ -57,6 +57,12 @@ def _ldd_library_pattern(library_name):
$""" % re.escape(library_name), re.VERBOSE)
+def _ldd_library_nix_pattern(library_name):
+ nix_store_dir = re.escape('@nixStoreDir@'.rstrip('/'))
+ pattern = r'(%s(?:/[^/]*)+lib%s[^A-Za-z0-9_-][^\s\(\)]*)'
+ return re.compile(pattern % (nix_store_dir, re.escape(library_name)))
+
+
# This is a what we do for non-la files. We assume that we are on an
# ELF-like system where ldd exists and the soname extracted with ldd is
# a filename that can be opened with dlopen().
@@ -108,7 +114,8 @@ def _resolve_non_libtool(options, binary, libraries):
output = output.decode("utf-8", "replace")
shlibs = resolve_from_ldd_output(libraries, output)
- return list(map(sanitize_shlib_path, shlibs))
+ fallback_libpath = options.fallback_libpath or "";
+ return list(map(lambda p: os.path.join(fallback_libpath, p), map(sanitize_shlib_path, shlibs)))
def sanitize_shlib_path(lib):
@@ -117,19 +124,18 @@ def sanitize_shlib_path(lib):
# In case we get relative paths on macOS (like @rpath) then we fall
# back to the basename as well:
# https://gitlab.gnome.org/GNOME/gobject-introspection/issues/222
- if sys.platform == "darwin":
- if not os.path.isabs(lib):
- return os.path.basename(lib)
- return lib
- else:
+
+ # Always use absolute paths if available
+ if not os.path.isabs(lib):
return os.path.basename(lib)
+ return lib
def resolve_from_ldd_output(libraries, output):
patterns = {}
for library in libraries:
if not os.path.isfile(library):
- patterns[library] = _ldd_library_pattern(library)
+ patterns[library] = (_ldd_library_pattern(library), _ldd_library_nix_pattern(library))
if len(patterns) == 0:
return []
@@ -141,8 +147,11 @@ def resolve_from_ldd_output(libraries, output):
if line.endswith(':'):
continue
for word in line.split():
- for library, pattern in patterns.items():
- m = pattern.match(word)
+ for library, (pattern, nix_pattern) in patterns.items():
+ if line.find('@nixStoreDir@') != -1:
+ m = nix_pattern.match(word)
+ else:
+ m = pattern.match(word)
if m:
del patterns[library]
shlibs.append(m.group())
diff --git a/giscanner/utils.py b/giscanner/utils.py
index 31c7ea48..630002a8 100644
--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -114,16 +114,11 @@ def extract_libtool_shlib(la_file):
if dlname is None:
return None
- # Darwin uses absolute paths where possible; since the libtool files never
- # contain absolute paths, use the libdir field
- if platform.system() == 'Darwin':
- dlbasename = os.path.basename(dlname)
- libdir = _extract_libdir_field(la_file)
- if libdir is None:
- return dlbasename
- return libdir + '/' + dlbasename
- # Older libtools had a path rather than the raw dlname
- return os.path.basename(dlname)
+ dlbasename = os.path.basename(dlname)
+ libdir = _extract_libdir_field(la_file)
+ if libdir is None:
+ return dlbasename
+ return libdir + '/' + dlbasename
# Returns arguments for invoking libtool, if applicable, otherwise None
diff --git a/tests/scanner/test_shlibs.py b/tests/scanner/test_shlibs.py
index a8337c60..72789d76 100644
--- a/tests/scanner/test_shlibs.py
+++ b/tests/scanner/test_shlibs.py
@@ -7,6 +7,30 @@ from giscanner.shlibs import resolve_from_ldd_output, sanitize_shlib_path
class TestLddParser(unittest.TestCase):
+ def test_resolve_from_ldd_output_nix(self):
+ output = '''\
+ libglib-2.0.so.0 => @nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libglib-2.0.so.0 (0x00007f0ee1b28000)
+ libgobject-2.0.so.0 => @nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libgobject-2.0.so.0 (0x00007f0ee18cf000)
+ libgio-2.0.so.0 => @nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libgio-2.0.so.0 (0x00007f0ee1502000)
+ libxml2.so.2 => @nixStoreDir@/72mxkk74cv266snkjpz1kwl1i2rg8rpc-libxml2-2.9.8/lib/libxml2.so.2 (0x00007f0ee119c000)
+ libsqlite3.so.0 => @nixStoreDir@/ck5ay23hsmlc67pg3m34kzd1k2hhvww0-sqlite-3.24.0/lib/libsqlite3.so.0 (0x00007f0ee0e98000)
+ libpsl.so.5 => @nixStoreDir@/qn3l2gn7m76f318676wflrs2z6d4rrkj-libpsl-0.20.2-list-2017-02-03/lib/libpsl.so.5 (0x00007f0ee0c88000)
+ libc.so.6 => @nixStoreDir@/g2yk54hifqlsjiha3szr4q3ccmdzyrdv-glibc-2.27/lib/libc.so.6 (0x00007f0ee08d4000)
+ libpcre.so.1 => @nixStoreDir@/hxbq8lpc53qsf1bc0dfcsm47wmcxzjvh-pcre-8.42/lib/libpcre.so.1 (0x00007f0ee0662000)
+ @nixStoreDir@/g2yk54hifqlsjiha3szr4q3ccmdzyrdv-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007f0ee20ff000)
+ libblkid.so.1 => @nixStoreDir@/q0kgnq21j0l2yd77gdlld371246cwghh-util-linux-2.32.1/lib/libblkid.so.1 (0x00007f0edd0cd000)
+ libuuid.so.1 => @nixStoreDir@/q0kgnq21j0l2yd77gdlld371246cwghh-util-linux-2.32.1/lib/libuuid.so.1 (0x00007f0edcec5000)
+ librt.so.1 => @nixStoreDir@/g2yk54hifqlsjiha3szr4q3ccmdzyrdv-glibc-2.27/lib/librt.so.1 (0x00007f0edccbd000)
+ libstdc++.so.6 => @nixStoreDir@/3v5r7fkrbkw2qajadvjbf6p6qriz9p1i-gcc-7.3.0-lib/lib/libstdc++.so.6 (0x00007f0edc936000)
+ libgcc_s.so.1 => @nixStoreDir@/g2yk54hifqlsjiha3szr4q3ccmdzyrdv-glibc-2.27/lib/libgcc_s.so.1 (0x00007f0edc720000)
+ '''
+ libraries = ['glib-2.0', 'gio-2.0']
+
+ self.assertEqual(
+ ['@nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libglib-2.0.so.0',
+ '@nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libgio-2.0.so.0'],
+ resolve_from_ldd_output(libraries, output))
+
def test_resolve_from_ldd_output(self):
output = '''\
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fbe12d68000)
@@ -40,7 +64,8 @@ class TestLddParser(unittest.TestCase):
self.assertEqual(
sanitize_shlib_path('/foo/bar'),
- '/foo/bar' if sys.platform == 'darwin' else 'bar')
+ # NixOS always want the absolute path
+ '/foo/bar')
def test_unresolved_library(self):
output = ''

View File

@@ -0,0 +1,204 @@
{
stdenv,
lib,
fetchurl,
fetchpatch,
glib,
flex,
bison,
meson,
ninja,
gtk-doc,
docbook-xsl-nons,
docbook_xml_dtd_45,
pkg-config,
libffi,
python3,
cctools,
cairo,
gnome,
replaceVars,
replaceVarsWith,
buildPackages,
gobject-introspection-unwrapped,
nixStoreDir ? builtins.storeDir,
x11Support ? true,
testers,
propagateFullGlib ? true,
}:
# now that gobject-introspection creates large .gir files (eg gtk3 case)
# it may be worth thinking about using multiple derivation outputs
# In that case its about 6MB which could be separated
let
pythonModules = pp: [
pp.mako
pp.markdown
pp.setuptools
];
# https://discourse.gnome.org/t/dealing-with-glib-and-gobject-introspection-circular-dependency/18701
glib' = glib.override { withIntrospection = false; };
in
stdenv.mkDerivation (finalAttrs: {
pname = "gobject-introspection";
version = "1.84.0";
# outputs TODO: share/gobject-introspection-1.0/tests is needed during build
# by pygobject3 (and maybe others), but it's only searched in $out
outputs = [
"out"
"dev"
"devdoc"
"man"
];
outputBin = "dev";
src = fetchurl {
url = "mirror://gnome/sources/gobject-introspection/${lib.versions.majorMinor finalAttrs.version}/gobject-introspection-${finalAttrs.version}.tar.xz";
hash = "sha256-lFtX2n7CYuXCZrieCR0UvoAMxCQnfYKgKHK315SoR3k=";
};
patches = [
# Make g-ir-scanner put absolute path to GIR files it generates
# so that programs can just dlopen them without having to muck
# with LD_LIBRARY_PATH environment variable.
(replaceVars ./absolute_shlib_path.patch {
inherit nixStoreDir;
})
# Fix getter heuristics regression
# https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/529
./0001-scanner-Prefer-some-getters-over-others.patch
]
++ lib.optionals x11Support [
# Hardcode the cairo shared library path in the Cairo gir shipped with this package.
# https://github.com/NixOS/nixpkgs/issues/34080
(replaceVars ./absolute_gir_path.patch {
cairoLib = "${lib.getLib cairo}/lib";
# original source code in patch's context
CAIRO_GIR_PACKAGE = null;
CAIRO_SHARED_LIBRARY = null;
})
];
strictDeps = true;
nativeBuildInputs = [
meson
ninja
pkg-config
flex
bison
gtk-doc
docbook-xsl-nons
docbook_xml_dtd_45
# Build definition checks for the Python modules needed at runtime by importing them.
(buildPackages.python3.withPackages pythonModules)
finalAttrs.setupHook # move .gir files
# can't use canExecute, we need prebuilt when cross
]
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ gobject-introspection-unwrapped ];
buildInputs = [
(python3.withPackages pythonModules)
];
nativeCheckInputs = lib.optionals stdenv.hostPlatform.isDarwin [
cctools # for otool
];
propagatedBuildInputs = [
libffi
(if propagateFullGlib then glib else glib')
];
mesonFlags = [
"--datadir=${placeholder "dev"}/share"
"-Dcairo=disabled"
"-Dgtk_doc=${lib.boolToString (stdenv.hostPlatform == stdenv.buildPlatform)}"
]
++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
"-Dgi_cross_ldd_wrapper=${
replaceVarsWith {
name = "g-ir-scanner-lddwrapper";
isExecutable = true;
src = ./wrappers/g-ir-scanner-lddwrapper.sh;
replacements = {
inherit (buildPackages) bash;
buildlddtree = "${buildPackages.pax-utils}/bin/lddtree";
};
}
}"
"-Dgi_cross_binary_wrapper=${stdenv.hostPlatform.emulator buildPackages}"
# can't use canExecute, we need prebuilt when cross
]
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
"-Dgi_cross_use_prebuilt_gi=true"
];
doCheck = !stdenv.hostPlatform.isAarch64;
# During configurePhase, two python scripts are generated and need this. See
# https://github.com/NixOS/nixpkgs/pull/98316#issuecomment-695785692
postConfigure = ''
patchShebangs tools/*
'';
postInstall = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
cp -r ${buildPackages.gobject-introspection-unwrapped.devdoc} $devdoc
# these are uncompiled c and header files which aren't installed when cross-compiling because
# code that installs them is in tests/meson.build which is only run when not cross-compiling
# pygobject3 needs them
cp -r ${buildPackages.gobject-introspection-unwrapped.dev}/share/gobject-introspection-1.0/tests $dev/share/gobject-introspection-1.0/tests
'';
preCheck = ''
# Our gobject-introspection patches make the shared library paths absolute
# in the GIR files. When running tests, the library is not yet installed,
# though, so we need to replace the absolute path with a local one during build.
# We are using a symlink that we will delete before installation.
mkdir -p $out/lib
ln -s $PWD/tests/scanner/libregress-1.0${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libregress-1.0${stdenv.hostPlatform.extensions.sharedLibrary}
'';
postCheck = ''
rm $out/lib/libregress-1.0${stdenv.hostPlatform.extensions.sharedLibrary}
'';
setupHook = ./setup-hook.sh;
passthru = {
updateScript = gnome.updateScript {
packageName = "gobject-introspection";
versionPolicy = "odd-unstable";
};
tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
};
meta = with lib; {
description = "Middleware layer between C libraries and language bindings";
homepage = "https://gi.readthedocs.io/";
maintainers = with maintainers; [
lovek323
artturin
];
teams = [ teams.gnome ];
pkgConfigModules = [ "gobject-introspection-1.0" ];
platforms = platforms.unix;
badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
license = with licenses; [
gpl2
lgpl2
];
longDescription = ''
GObject introspection is a middleware layer between C libraries (using
GObject) and language bindings. The C library can be scanned at compile
time and generate a metadata file, in addition to the actual native C
library. Then at runtime, language bindings can read this metadata and
automatically provide bindings to call into the C library.
'';
};
})

View File

@@ -0,0 +1,29 @@
make_gobject_introspection_find_gir_files() {
# required for .typelib files, eg mypaint git version
if [ -d "$1/lib/girepository-1.0" ]; then
addToSearchPath GI_TYPELIB_PATH $1/lib/girepository-1.0
fi
# XDG_DATA_DIRS: required for finding .gir files
if [ -d "$1/share/gir-1.0" ]; then
addToSearchPath XDG_DATA_DIRS $1/share
fi
}
addEnvHooks "$targetOffset" make_gobject_introspection_find_gir_files
giDiscoverSelf() {
if [ -d "$prefix/lib/girepository-1.0" ]; then
addToSearchPath GI_TYPELIB_PATH $prefix/lib/girepository-1.0
fi
}
# gappsWrapperArgsHook expects GI_TYPELIB_PATH variable to be set by this.
# Until we have dependency mechanism in generic builder, we need to use this hack.
postInstallHooks+=(giDiscoverSelf)
_multioutMoveGlibGir() {
moveToOutput share/gir-1.0 "${!outputDev}"
}
preFixupHooks+=(_multioutMoveGlibGir)

View File

@@ -0,0 +1,115 @@
{
lib,
stdenv,
buildPackages,
targetPackages,
gobject-introspection-unwrapped,
...
}@_args:
# to build, run
# `nix build ".#pkgsCross.aarch64-multiplatform.buildPackages.gobject-introspection"`
# a comment for both depsTargetTargetPropagated's
# add self to buildInputs to avoid needing to add gobject-introspection to buildInputs in addition to nativeBuildInputs
# builds use target-pkg-config to look for gobject-introspection instead of just looking for binaries in $PATH
let
# ensure that `.override` works
args = removeAttrs _args [
"buildPackages"
"targetPackages"
"gobject-introspection-unwrapped"
];
# passing this stdenv to `targetPackages...` breaks due to splicing not working in `.override``
argsForTarget = removeAttrs args [ "stdenv" ];
overriddenUnwrappedGir = gobject-introspection-unwrapped.override args;
# if we have targetPackages.gobject-introspection then propagate that
overridenTargetUnwrappedGir =
if targetPackages ? gobject-introspection-unwrapped then
targetPackages.gobject-introspection-unwrapped.override argsForTarget
else
overriddenUnwrappedGir;
in
# wrap both pkgsCrossX.buildPackages.gobject-introspection and {pkgs,pkgsSomethingExecutableOnBuildSystem).buildPackages.gobject-introspection
if
(!stdenv.hostPlatform.canExecute stdenv.targetPlatform)
&& stdenv.targetPlatform.emulatorAvailable buildPackages
then
overriddenUnwrappedGir.overrideAttrs (previousAttrs: {
pname = "gobject-introspection-wrapped";
passthru = previousAttrs.passthru // {
unwrapped = overriddenUnwrappedGir;
};
dontStrip = true;
depsTargetTargetPropagated = [ overridenTargetUnwrappedGir ];
buildCommand = ''
eval fixupPhase
${lib.concatMapStrings (output: ''
mkdir -p ${"$" + "${output}"}
${lib.getExe buildPackages.xorg.lndir} ${overriddenUnwrappedGir.${output}} ${"$" + "${output}"}
'') overriddenUnwrappedGir.outputs}
cp $dev/bin/g-ir-compiler $dev/bin/.g-ir-compiler-wrapped
cp $dev/bin/g-ir-scanner $dev/bin/.g-ir-scanner-wrapped
(
rm "$dev/bin/g-ir-compiler"
rm "$dev/bin/g-ir-scanner"
export bash="${buildPackages.bash}"
export emulator=${lib.escapeShellArg (stdenv.targetPlatform.emulator buildPackages)}
export emulatorwrapper="$dev/bin/g-ir-scanner-qemuwrapper"
export buildlddtree="${buildPackages.pax-utils}/bin/lddtree"
export targetgir="${lib.getDev overridenTargetUnwrappedGir}"
substituteAll "${./wrappers/g-ir-compiler.sh}" "$dev/bin/g-ir-compiler"
substituteAll "${./wrappers/g-ir-scanner.sh}" "$dev/bin/g-ir-scanner"
substituteAll "${./wrappers/g-ir-scanner-lddwrapper.sh}" "$dev/bin/g-ir-scanner-lddwrapper"
substituteAll "${./wrappers/g-ir-scanner-qemuwrapper.sh}" "$dev/bin/g-ir-scanner-qemuwrapper"
chmod +x $dev/bin/g-ir-compiler
chmod +x $dev/bin/g-ir-scanner*
)
''
# when cross-compiling and using the wrapper then when a package looks up the g_ir_X
# variable with pkg-config they'll get the host version which can't be run
# override the variable to use the absolute path to g_ir_X in PATH which can be run
+ ''
cat >> $dev/nix-support/setup-hook <<-'EOF'
override-pkg-config-gir-variables() {
PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_SCANNER="$(type -p g-ir-scanner)"
PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_COMPILER="$(type -p g-ir-compiler)"
PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_GENERATE="$(type -p g-ir-generate)"
export PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_SCANNER
export PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_COMPILER
export PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_G_IR_GENERATE
}
preConfigureHooks+=(override-pkg-config-gir-variables)
EOF
'';
})
else
overriddenUnwrappedGir.overrideAttrs (previousAttrs: {
pname = "gobject-introspection-wrapped";
passthru = previousAttrs.passthru // {
unwrapped = overriddenUnwrappedGir;
};
dontStrip = true;
# Conditional is for `pkgsCross.x86_64-freebsd.pkgsBuildHost.gobject-introspection` `error: Don't know how to run x86_64-unknown-freebsd executables.`
# `pkgsCross.x86_64-freebsd.buildPackages.python3.withPackages (pp: [ pp.pygobject3 ])`
# Using the python module does not need this propagation
depsTargetTargetPropagated = lib.optionals (stdenv.targetPlatform.emulatorAvailable buildPackages) [
overridenTargetUnwrappedGir
];
buildCommand = ''
eval fixupPhase
${lib.concatMapStrings (output: ''
mkdir -p ${"$" + "${output}"}
${lib.getExe buildPackages.xorg.lndir} ${overriddenUnwrappedGir.${output}} ${"$" + "${output}"}
'') overriddenUnwrappedGir.outputs}
'';
})

View File

@@ -0,0 +1,4 @@
#! @bash@/bin/bash
# shellcheck shell=bash
exec @emulatorwrapper@ @targetgir@/bin/g-ir-compiler "$@"

View File

@@ -0,0 +1,4 @@
#! @bash@/bin/bash
# shellcheck shell=bash
exec @buildlddtree@ "$@"

View File

@@ -0,0 +1,23 @@
#! @bash@/bin/bash
# shellcheck shell=bash
# fixes issues like
# libdbusmenu-gtk3-aarch64-unknown-linux-gnu> /build/libdbusmenu-16.04.0/libdbusmenu-gtk/tmp-introspect2jhtiwwn/.libs/DbusmenuGtk3-0.4:
# error while loading shared libraries: libdbusmenu-glib.so.4: cannot open shared object file: No such file or directory
# in non-meson builds
# see: https://github.com/void-linux/void-packages/blob/master/srcpkgs/gobject-introspection/files/g-ir-scanner-qemuwrapper
# https://github.com/openembedded/openembedded-core/blob/c5a14f39a6717a99b510cb97aa2fb403d4b98d99/meta/recipes-gnome/gobject-introspection/gobject-introspection_1.72.0.bb#L74
while read -r d; do \
# some meson projects may have subprojects which use makefiles for docs(e.g. gi-docgen), ignore those as they will never be needed
if [[ -f "$d/Makefile" && "$d" != *"subproject"* ]]; then
GIR_EXTRA_LIBS_PATH="$(readlink -f "$d/.libs"):$GIR_EXTRA_LIBS_PATH"
export GIR_EXTRA_LIBS_PATH
fi
done < <(find "$NIX_BUILD_TOP" -type d)
# quoting broke the build of atk
# shellcheck disable=2086
exec @emulator@ ${GIR_EXTRA_OPTIONS:-} \
${GIR_EXTRA_LIBS_PATH:+-E LD_LIBRARY_PATH="${GIR_EXTRA_LIBS_PATH}"} \
"$@"

View File

@@ -0,0 +1,7 @@
#! @bash@/bin/bash
# shellcheck shell=bash
exec @dev@/bin/.g-ir-scanner-wrapped \
--use-binary-wrapper=@emulatorwrapper@ \
--use-ldd-wrapper=@dev@/bin/g-ir-scanner-lddwrapper \
"$@"