Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gobject-introspection: propagate self/targetself to avoid having to add gobject-introspection to buildInputs #189215

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pkgs/development/libraries/gobject-introspection/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ stdenv.mkDerivation (finalAttrs: {
})
];

strictDeps = true;

nativeBuildInputs = [
meson
ninja
Expand All @@ -76,7 +78,7 @@ stdenv.mkDerivation (finalAttrs: {
# Build definition checks for the Python modules needed at runtime by importing them.
(buildPackages.python3.withPackages pythonModules)
finalAttrs.setupHook # move .gir files
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ gobject-introspection-unwrapped ];
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ gobject-introspection-unwrapped ];

buildInputs = [
(python3.withPackages pythonModules)
Expand All @@ -95,7 +97,7 @@ stdenv.mkDerivation (finalAttrs: {
"--datadir=${placeholder "dev"}/share"
"-Dcairo=disabled"
"-Dgtk_doc=${lib.boolToString (stdenv.hostPlatform == stdenv.buildPlatform)}"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
"-Dgi_cross_ldd_wrapper=${substituteAll {
name = "g-ir-scanner-lddwrapper";
isExecutable = true;
Expand Down Expand Up @@ -136,6 +138,14 @@ stdenv.mkDerivation (finalAttrs: {
rm $out/lib/libregress-1.0${stdenv.targetPlatform.extensions.sharedLibrary}
'';

# 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
# wrapper uses depsTargetTargetPropagated so ignore it
preFixup = lib.optionalString (!lib.hasSuffix "-wrapped" finalAttrs.pname) ''
mkdir -p $dev/nix-support
echo "$out" > $dev/nix-support/propagated-target-target-deps
'';

setupHook = ./setup-hook.sh;

passthru = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ in

(gobject-introspection-unwrapped.override args).overrideAttrs (previousAttrs: {
pname = "gobject-introspection-wrapped";
depsTargetTargetPropagated = [ gobject-introspection-unwrapped ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still not convinced this is correct solution for the Meson issue. gobject-introspection in buildInputs only makes sense for apps (since they will need cairo’s or GLib’s typelibs). Libraries (for which the Meson’s GIR generation is relevant) should not need those.

Copy link
Member Author

@Artturin Artturin Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to remove it but (meson,configure script,probably cmake too) build systems look for it with pkg-config and use the binary variables in the pc file

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
Expand Down