diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-12-06 19:57:55 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-02-08 13:48:30 +0000 |
commit | bf3aadfdd39aa197e18bade671fab6726349ffa4 (patch) | |
tree | 698567af766ed441d757b57a7b21e68d4a342a2b /nixpkgs/pkgs/development/libraries/gobject-introspection | |
parent | f4afc5a01d9539ce09e47494e679c51f80723d07 (diff) | |
parent | 99665eb45f58d959d2cb9e49ddb960c79d596f33 (diff) | |
download | nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.gz nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.bz2 nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.lz nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.xz nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.zst nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.zip |
Merge commit '99665eb45f58d959d2cb9e49ddb960c79d596f33'
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/gobject-introspection')
6 files changed, 101 insertions, 9 deletions
diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/default.nix b/nixpkgs/pkgs/development/libraries/gobject-introspection/default.nix index b457331983aa..bb07d8c792ce 100644 --- a/nixpkgs/pkgs/development/libraries/gobject-introspection/default.nix +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/default.nix @@ -17,6 +17,8 @@ , cairo , gnome , substituteAll +, buildPackages +, gobject-introspection-unwrapped , nixStoreDir ? builtins.storeDir , x11Support ? true }: @@ -25,7 +27,7 @@ # it may be worth thinking about using multiple derivation outputs # In that case its about 6MB which could be separated -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "gobject-introspection"; version = "1.72.0"; @@ -35,7 +37,7 @@ stdenv.mkDerivation rec { outputBin = "dev"; src = fetchurl { - url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz"; + url = "mirror://gnome/sources/gobject-introspection/${lib.versions.majorMinor finalAttrs.version}/gobject-introspection-${finalAttrs.version}.tar.xz"; sha256 = "Av6OWQhh2I+DBg3TnNpcyqYLLaHSHQ+VSZMBsYa+qrw="; }; @@ -66,8 +68,8 @@ stdenv.mkDerivation rec { docbook-xsl-nons docbook_xml_dtd_45 python3 - setupHook # move .gir files - ]; + finalAttrs.setupHook # move .gir files + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ gobject-introspection-unwrapped ]; buildInputs = [ python3 @@ -86,7 +88,17 @@ stdenv.mkDerivation rec { "--datadir=${placeholder "dev"}/share" "-Ddoctool=disabled" "-Dcairo=disabled" - "-Dgtk_doc=true" + "-Dgtk_doc=${lib.boolToString (stdenv.hostPlatform == stdenv.buildPlatform)}" + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-Dgi_cross_ldd_wrapper=${substituteAll { + name = "g-ir-scanner-lddwrapper"; + isExecutable = true; + src = ./wrappers/g-ir-scanner-lddwrapper.sh; + inherit (buildPackages) bash; + buildobjdump = "${buildPackages.stdenv.cc.bintools}/bin/objdump"; + }}" + "-Dgi_cross_use_prebuilt_gi=true" + "-Dgi_cross_binary_wrapper=${stdenv.hostPlatform.emulator buildPackages}" ]; doCheck = !stdenv.isAarch64; @@ -97,6 +109,14 @@ stdenv.mkDerivation rec { 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, @@ -114,7 +134,7 @@ stdenv.mkDerivation rec { passthru = { updateScript = gnome.updateScript { - packageName = pname; + packageName = "gobject-introspection"; versionPolicy = "odd-unstable"; }; }; @@ -122,7 +142,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "A middleware layer between C libraries and language bindings"; homepage = "https://gi.readthedocs.io/"; - maintainers = teams.gnome.members ++ (with maintainers; [ lovek323 ]); + maintainers = teams.gnome.members ++ (with maintainers; [ lovek323 artturin ]); platforms = platforms.unix; license = with licenses; [ gpl2 lgpl2 ]; @@ -134,4 +154,4 @@ stdenv.mkDerivation rec { automatically provide bindings to call into the C library. ''; }; -} +}) diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/setup-hook.sh b/nixpkgs/pkgs/development/libraries/gobject-introspection/setup-hook.sh index 6bee47aeb096..50571a8f914d 100644 --- a/nixpkgs/pkgs/development/libraries/gobject-introspection/setup-hook.sh +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/setup-hook.sh @@ -10,7 +10,7 @@ make_gobject_introspection_find_gir_files() { fi } -addEnvHooks "$hostOffset" make_gobject_introspection_find_gir_files +addEnvHooks "$targetOffset" make_gobject_introspection_find_gir_files giDiscoverSelf() { if [ -d "$prefix/lib/girepository-1.0" ]; then diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/wrapper.nix b/nixpkgs/pkgs/development/libraries/gobject-introspection/wrapper.nix new file mode 100644 index 000000000000..4b3fa1a19819 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/wrapper.nix @@ -0,0 +1,57 @@ +{ lib +, stdenv +, buildPackages +, targetPackages +, gobject-introspection-unwrapped +, ... +}@_args: + +# to build, run +# `nix build ".#pkgsCross.aarch64-multiplatform.buildPackages.gobject-introspection"` + +let + # ensure that `.override` works when gobject-introspection == gobject-introspection-wrapped + args = builtins.removeAttrs _args [ "buildPackages" "targetPackages" "gobject-introspection-unwrapped" ]; + # passing this stdenv to `targetPackages...` breaks due to splicing not working in `.override`` + argsForTarget = builtins.removeAttrs args [ "stdenv" ]; +in + +(gobject-introspection-unwrapped.override args).overrideAttrs (previousAttrs: { + pname = "gobject-introspection-wrapped"; + postFixup = (previousAttrs.postFixup or "") + '' + mv $dev/bin/g-ir-compiler $dev/bin/.g-ir-compiler-wrapped + mv $dev/bin/g-ir-scanner $dev/bin/.g-ir-scanner-wrapped + + ( + export bash="${buildPackages.bash}" + export emulator=${lib.escapeShellArg (stdenv.targetPlatform.emulator buildPackages)} + export buildobjdump="${buildPackages.stdenv.cc.bintools}/bin/objdump" + + export targetgir="${lib.getDev (targetPackages.gobject-introspection-unwrapped.override argsForTarget)}" + + 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" + chmod +x "$dev/bin/g-ir-compiler" + chmod +x "$dev/bin/g-ir-scanner" + chmod +x "$dev/bin/g-ir-scanner-lddwrapper" + ) + '' + # 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 + ''; +}) diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/wrappers/g-ir-compiler.sh b/nixpkgs/pkgs/development/libraries/gobject-introspection/wrappers/g-ir-compiler.sh new file mode 100644 index 000000000000..69642831c8a0 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/wrappers/g-ir-compiler.sh @@ -0,0 +1,4 @@ +#! @bash@/bin/bash +# shellcheck shell=bash + +exec @emulator@ @targetgir@/bin/g-ir-compiler "$@" diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/wrappers/g-ir-scanner-lddwrapper.sh b/nixpkgs/pkgs/development/libraries/gobject-introspection/wrappers/g-ir-scanner-lddwrapper.sh new file mode 100644 index 000000000000..1bf9c3659dc5 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/wrappers/g-ir-scanner-lddwrapper.sh @@ -0,0 +1,4 @@ +#! @bash@/bin/bash +# shellcheck shell=bash + +exec @buildobjdump@ -p "$@" diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/wrappers/g-ir-scanner.sh b/nixpkgs/pkgs/development/libraries/gobject-introspection/wrappers/g-ir-scanner.sh new file mode 100644 index 000000000000..6a222191c7b2 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/wrappers/g-ir-scanner.sh @@ -0,0 +1,7 @@ +#! @bash@/bin/bash +# shellcheck shell=bash + +exec @dev@/bin/.g-ir-scanner-wrapped \ + --use-binary-wrapper=@emulator@ \ + --use-ldd-wrapper=@dev@/bin/g-ir-scanner-lddwrapper \ + "$@" |