various: enable gobject-introspection when cross-compiling

and fix cross in some
This commit is contained in:
Artturin 2022-07-07 21:34:37 +03:00
parent bf15263d1c
commit 1bd8727a4c
15 changed files with 116 additions and 90 deletions

View File

@ -44,10 +44,6 @@ stdenv.mkDerivation rec {
glib
];
mesonFlags = [
"-Dintrospection=${lib.boolToString (stdenv.buildPlatform == stdenv.hostPlatform)}"
];
doCheck = true;
passthru = {

View File

@ -16,22 +16,18 @@
, libjpeg
, libpng
, gnome
, gobject-introspection
, buildPackages
, doCheck ? false
, makeWrapper
, lib
, withIntrospection ? (stdenv.buildPlatform == stdenv.hostPlatform)
, gobject-introspection
}:
let
withGtkDoc = stdenv.buildPlatform == stdenv.hostPlatform;
in
stdenv.mkDerivation rec {
pname = "gdk-pixbuf";
version = "2.42.8";
outputs = [ "out" "dev" "man" ]
++ lib.optional withGtkDoc "devdoc"
outputs = [ "out" "dev" "man" "devdoc" ]
++ lib.optional (stdenv.buildPlatform == stdenv.hostPlatform) "installedTests";
src = fetchurl {
@ -60,6 +56,7 @@ stdenv.mkDerivation rec {
makeWrapper
glib
gi-docgen
gobject-introspection
# for man pages
libxslt
@ -67,8 +64,6 @@ stdenv.mkDerivation rec {
docbook_xml_dtd_43
] ++ lib.optionals stdenv.isDarwin [
fixDarwinDylibNames
] ++ lib.optionals withIntrospection [
gobject-introspection
];
propagatedBuildInputs = [
@ -79,9 +74,8 @@ stdenv.mkDerivation rec {
];
mesonFlags = [
"-Dgtk_doc=${lib.boolToString withGtkDoc}"
"-Dintrospection=${if withIntrospection then "enabled" else "disabled"}"
"-Dgio_sniffing=false"
"-Dgtk_doc=true"
];
postPatch = ''
@ -89,10 +83,13 @@ stdenv.mkDerivation rec {
patchShebangs build-aux
substituteInPlace tests/meson.build --subst-var-by installedtestsprefix "$installedTests"
'';
preInstall = ''
PATH=$PATH:$out/bin # for install script
# Run-time dependency gi-docgen found: NO (tried pkgconfig and cmake)
# it should be a build-time dep for build
# TODO: send upstream
substituteInPlace docs/meson.build \
--replace "dependency('gi-docgen'," "dependency('gi-docgen', native:true," \
--replace "'gi-docgen', req" "'gi-docgen', native:true, req"
'';
postInstall =
@ -108,9 +105,9 @@ stdenv.mkDerivation rec {
install_name_tool -change @rpath/libgdk_pixbuf-2.0.0.dylib $out/lib/libgdk_pixbuf-2.0.0.dylib $f
mv $f ''${f%.dylib}.so
done
'' + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
'' + ''
# We need to install 'loaders.cache' in lib/gdk-pixbuf-2.0/2.10.0/
$dev/bin/gdk-pixbuf-query-loaders --update-cache
${stdenv.hostPlatform.emulator buildPackages} $dev/bin/gdk-pixbuf-query-loaders --update-cache
'';
# The fixDarwinDylibNames hook doesn't patch binaries.
@ -120,7 +117,7 @@ stdenv.mkDerivation rec {
done
'';
postFixup = lib.optionalString withGtkDoc ''
postFixup = ''
# Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
moveToOutput "share/doc" "$devdoc"
'';

View File

@ -4,6 +4,7 @@
, fetchpatch
, intltool
, meson
, mesonEmulatorHook
, ninja
, pkg-config
, gtk-doc
@ -74,6 +75,8 @@ stdenv.mkDerivation rec {
gtk-doc
docbook-xsl-nons
docbook_xml_dtd_412
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
mesonEmulatorHook
];
buildInputs = [

View File

@ -158,7 +158,6 @@ stdenv.mkDerivation rec {
"-Dbroadway_backend=${lib.boolToString broadwaySupport}"
"-Dx11_backend=${lib.boolToString x11Support}"
"-Dquartz_backend=${lib.boolToString (stdenv.isDarwin && !x11Support)}"
"-Dintrospection=${lib.boolToString (stdenv.buildPlatform == stdenv.hostPlatform)}"
];
doCheck = false; # needs X11

View File

@ -34,7 +34,6 @@ let
inherit (lib) optional optionals optionalString;
mesonFeatureFlag = opt: b:
"-D${opt}=${if b then "enabled" else "disabled"}";
isNativeCompilation = stdenv.buildPlatform == stdenv.hostPlatform;
in
stdenv.mkDerivation {
@ -70,7 +69,10 @@ stdenv.mkDerivation {
(mesonFeatureFlag "coretext" withCoreText)
(mesonFeatureFlag "graphite" withGraphite2)
(mesonFeatureFlag "icu" withIcu)
(mesonFeatureFlag "introspection" isNativeCompilation)
];
depsBuildBuild = [
pkg-config
];
nativeBuildInputs = [
@ -86,8 +88,7 @@ stdenv.mkDerivation {
];
buildInputs = [ glib freetype ]
++ lib.optionals withCoreText [ ApplicationServices CoreText ]
++ lib.optionals isNativeCompilation [ gobject-introspection ];
++ lib.optionals withCoreText [ ApplicationServices CoreText ];
propagatedBuildInputs = optional withGraphite2 graphite2
++ optionals withIcu [ icu harfbuzz ];

View File

@ -6,10 +6,10 @@
, ninja
, pkg-config
, gettext
, withIntrospection ? stdenv.buildPlatform == stdenv.hostPlatform
, gobject-introspection
, fixDarwinDylibNames
, gi-docgen
, libxslt
, fixDarwinDylibNames
, gnome
}:
@ -17,8 +17,7 @@ stdenv.mkDerivation rec {
pname = "json-glib";
version = "1.6.6";
outputs = [ "out" "dev" ]
++ lib.optional withIntrospection "devdoc";
outputs = [ "out" "dev" "devdoc" ];
src = fetchurl {
url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
@ -37,22 +36,26 @@ stdenv.mkDerivation rec {
pkg-config
gettext
glib
] ++ lib.optional stdenv.hostPlatform.isDarwin [
fixDarwinDylibNames
] ++ lib.optionals withIntrospection [
libxslt
gobject-introspection
gi-docgen
] ++ lib.optional stdenv.hostPlatform.isDarwin [
fixDarwinDylibNames
];
propagatedBuildInputs = [
glib
];
mesonFlags = lib.optionals (!withIntrospection) [
"-Dintrospection=disabled"
# gi-docgen relies on introspection data
"-Dgtk_doc=disabled"
];
# Run-time dependency gi-docgen found: NO (tried pkgconfig and cmake)
# it should be a build-time dep for build
# TODO: send upstream
postPatch = ''
substituteInPlace doc/meson.build \
--replace "'gi-docgen', ver" "'gi-docgen', native:true, ver" \
--replace "'gi-docgen', req" "'gi-docgen', native:true, req"
'';
doCheck = true;

View File

@ -13,7 +13,6 @@
, python3
, tzdata
, fixDarwinDylibNames
, withIntrospection ? stdenv.buildPlatform == stdenv.hostPlatform
, gobject-introspection
, vala
}:
@ -37,6 +36,8 @@ stdenv.mkDerivation rec {
ninja
perl
pkg-config
gobject-introspection
vala
# Docs building fails:
# https://github.com/NixOS/nixpkgs/pull/67204
# previously with https://github.com/NixOS/nixpkgs/pull/61657#issuecomment-495579489
@ -44,15 +45,12 @@ stdenv.mkDerivation rec {
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
# provides ical-glib-src-generator that runs during build
libical
] ++ lib.optionals withIntrospection [
gobject-introspection
vala
] ++ lib.optionals stdenv.isDarwin [
fixDarwinDylibNames
];
installCheckInputs = [
# running libical-glib tests
(python3.withPackages (pkgs: with pkgs; [
(python3.pythonForBuild.withPackages (pkgs: with pkgs; [
pygobject3
]))
];
@ -61,14 +59,10 @@ stdenv.mkDerivation rec {
glib
libxml2
icu
] ++ lib.optionals withIntrospection [
gobject-introspection
];
cmakeFlags = [
"-DENABLE_GTK_DOC=False"
"-DGOBJECT_INTROSPECTION=${if withIntrospection then "True" else "False"}"
"-DICAL_GLIB_VAPI=${if withIntrospection then "True" else "False"}"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DIMPORT_ICAL_GLIB_SRC_GENERATOR=${lib.getDev buildPackages.libical}/lib/cmake/LibIcal/IcalGlibSrcGenerator.cmake"
];

View File

@ -2,6 +2,7 @@
, fetchurl
, ninja
, meson
, mesonEmulatorHook
, pkg-config
, vala
, gobject-introspection
@ -34,6 +35,8 @@ stdenv.mkDerivation rec {
gtk-doc
docbook-xsl-nons
docbook_xml_dtd_43
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
mesonEmulatorHook
];
buildInputs = [

View File

@ -31,6 +31,10 @@ stdenv.mkDerivation rec {
sha256 = "P7PONA/NfbVNh8iT5pv8Kx9uTUsnkGX/5m2snw/RK00=";
};
depsBuildBuild = [
pkg-config
];
nativeBuildInputs = [
meson
ninja

View File

@ -8,16 +8,13 @@
, pkg-config
, gnome
, libsysprof-capture
, gobject-introspection
, vala
, libpsl
, brotli
, gnomeSupport ? true
, sqlite
, glib-networking
, gobject-introspection
, withIntrospection ? stdenv.buildPlatform == stdenv.hostPlatform
, vala
, withVala ? stdenv.buildPlatform == stdenv.hostPlatform
, libpsl
, python3
, brotli
}:
stdenv.mkDerivation rec {
@ -31,19 +28,20 @@ stdenv.mkDerivation rec {
sha256 = "sha256-8KQnZW5f4Z4d9xwQfojfobLmc8JcVHt4I7YBi0DQEVk=";
};
depsBuildBuild = [
pkg-config
];
nativeBuildInputs = [
meson
ninja
pkg-config
glib
] ++ lib.optionals withIntrospection [
gobject-introspection
] ++ lib.optionals withVala [
vala
];
buildInputs = [
python3
sqlite
libpsl
glib.out
@ -60,8 +58,6 @@ stdenv.mkDerivation rec {
mesonFlags = [
"-Dtls_check=false" # glib-networking is a runtime dependency, not a compile-time dependency
"-Dgssapi=disabled"
"-Dvapi=${if withVala then "enabled" else "disabled"}"
"-Dintrospection=${if withIntrospection then "enabled" else "disabled"}"
"-Dgnome=${lib.boolToString gnomeSupport}"
"-Dntlm=disabled"
] ++ lib.optionals (!stdenv.isLinux) [
@ -73,6 +69,12 @@ stdenv.mkDerivation rec {
doCheck = false; # ERROR:../tests/socket-test.c:37:do_unconnected_socket_test: assertion failed (res == SOUP_STATUS_OK): (2 == 200)
postPatch = ''
# fixes finding vapigen when cross-compiling
# the commit is in 3.0.6
# https://gitlab.gnome.org/GNOME/libsoup/-/commit/5280e936d0a76f94dbc5d8489cfbdc0a06343f65
substituteInPlace meson.build \
--replace "required: vapi_opt)" "required: vapi_opt, native: false)"
patchShebangs libsoup/
'';

View File

@ -35,6 +35,10 @@ stdenv.mkDerivation rec {
(lib.withFeature sslSupport "ssl")
];
preConfigure = ''
export PKG_CONFIG="$(command -v "$PKG_CONFIG")"
'';
passthru = {inherit compressionSupport sslSupport;};
meta = with lib; {

View File

@ -13,6 +13,7 @@
, protobuf
, config
, ocl-icd
, buildPackages
, enableJPEG ? true
, libjpeg
@ -291,11 +292,15 @@ stdenv.mkDerivation {
"-DOPENCV_GENERATE_PKGCONFIG=ON"
"-DWITH_OPENMP=ON"
"-DBUILD_PROTOBUF=OFF"
"-DProtobuf_PROTOC_EXECUTABLE=${lib.getExe buildPackages.protobuf}"
"-DPROTOBUF_UPDATE_FILES=ON"
"-DOPENCV_ENABLE_NONFREE=${printEnabled enableUnfree}"
"-DBUILD_TESTS=OFF"
"-DBUILD_PERF_TESTS=OFF"
"-DBUILD_DOCS=${printEnabled enableDocs}"
# "OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT"
# but we have proper separation of build and host libs :), fixes cross
"-DOPENCV_ENABLE_PKG_CONFIG=ON"
(opencvFlag "IPP" enableIpp)
(opencvFlag "TIFF" enableTIFF)
(opencvFlag "WEBP" enableWebP)

View File

@ -16,26 +16,21 @@
, ninja
, glib
, python3
, x11Support? !stdenv.isDarwin, libXft
, withIntrospection ? (stdenv.buildPlatform == stdenv.hostPlatform)
, gobject-introspection
, withDocs ? (stdenv.buildPlatform == stdenv.hostPlatform)
, x11Support? !stdenv.isDarwin, libXft
}:
stdenv.mkDerivation rec {
pname = "pango";
version = "1.50.7";
outputs = [ "bin" "out" "dev" ]
++ lib.optionals withDocs [ "devdoc" ];
outputs = [ "bin" "out" "dev" "devdoc" ];
src = fetchurl {
url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
sha256 = "BHfzaaPUxpXfcpmmmJ3ABHVqf03ifuysQFxnkLfjrTM=";
};
strictDeps = !withIntrospection;
depsBuildBuild = [
pkg-config
];
@ -44,9 +39,7 @@ stdenv.mkDerivation rec {
meson ninja
glib # for glib-mkenum
pkg-config
] ++ lib.optionals withIntrospection [
gobject-introspection
] ++ lib.optionals withDocs [
gi-docgen
python3
];
@ -71,8 +64,7 @@ stdenv.mkDerivation rec {
];
mesonFlags = [
"-Dgtk_doc=${lib.boolToString withDocs}"
"-Dintrospection=${if withIntrospection then "enabled" else "disabled"}"
"-Dgtk_doc=true"
] ++ lib.optionals (!x11Support) [
"-Dxft=disabled" # only works with x11
];
@ -82,9 +74,20 @@ stdenv.mkDerivation rec {
fontDirectories = [ freefont_ttf ];
};
# Run-time dependency gi-docgen found: NO (tried pkgconfig and cmake)
# it should be a build-time dep for build
# TODO: send upstream
postPatch = ''
substituteInPlace meson.build \
--replace "dependency('gi-docgen', ver" "dependency('gi-docgen', native:true, ver"
substituteInPlace docs/meson.build \
--replace "'gi-docgen', req" "'gi-docgen', native:true, req"
'';
doCheck = false; # test-font: FAIL
postFixup = lib.optionalString withDocs ''
postFixup = ''
# Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
moveToOutput "share/doc" "$devdoc"
'';

View File

@ -6,6 +6,7 @@
, expat
, pam
, meson
, mesonEmulatorHook
, ninja
, perl
, rsync
@ -23,10 +24,6 @@
, useSystemd ? stdenv.isLinux
, systemd
, elogind
# needed until gobject-introspection does cross-compile (https://github.com/NixOS/nixpkgs/pull/88222)
, withIntrospection ? (stdenv.buildPlatform == stdenv.hostPlatform)
# cross build fails on polkit-1-scan (https://github.com/NixOS/nixpkgs/pull/152704)
, withGtkDoc ? (stdenv.buildPlatform == stdenv.hostPlatform)
# A few tests currently fail on musl (polkitunixusertest, polkitunixgrouptest, polkitidentitytest segfault).
# Not yet investigated; it may be due to the "Make netgroup support optional"
# patch not updating the tests correctly yet, or doing something wrong,
@ -88,6 +85,10 @@ stdenv.mkDerivation rec {
})
];
depsBuildBuild = [
pkg-config
];
nativeBuildInputs = [
glib
gtk-doc
@ -97,7 +98,8 @@ stdenv.mkDerivation rec {
ninja
perl
rsync
(python3.withPackages (pp: with pp; [
gobject-introspection
(python3.pythonForBuild.withPackages (pp: with pp; [
dbus-python
(python-dbusmock.overridePythonAttrs (attrs: {
# Avoid dependency cycle.
@ -109,17 +111,18 @@ stdenv.mkDerivation rec {
libxslt
docbook-xsl-nons
docbook_xml_dtd_412
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
mesonEmulatorHook
];
buildInputs = [
expat
pam
spidermonkey_78
dbus
] ++ lib.optionals stdenv.isLinux [
# On Linux, fall back to elogind when systemd support is off.
(if useSystemd then systemd else elogind)
] ++ lib.optionals withIntrospection [
gobject-introspection
];
propagatedBuildInputs = [
@ -136,9 +139,7 @@ stdenv.mkDerivation rec {
"-Dsystemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
"-Dpolkitd_user=polkituser" #TODO? <nixos> config.ids.uids.polkituser
"-Dos_type=redhat" # only affects PAM includes
"-Dintrospection=${lib.boolToString withIntrospection}"
"-Dtests=${lib.boolToString doCheck}"
"-Dgtk_doc=${lib.boolToString withGtkDoc}"
"-Dman=true"
] ++ lib.optionals stdenv.isLinux [
"-Dsession_tracking=${if useSystemd then "libsystemd-login" else "libelogind"}"

View File

@ -25,6 +25,7 @@
, json-glib
, systemd
, dbus
, writeText
}:
stdenv.mkDerivation rec {
@ -46,6 +47,10 @@ stdenv.mkDerivation rec {
patchShebangs utils/data-generators/cc/generate
'';
depsBuildBuild = [
pkg-config
];
nativeBuildInputs = [
meson
ninja
@ -58,11 +63,8 @@ stdenv.mkDerivation rec {
gobject-introspection
docbook-xsl-nons
docbook_xml_dtd_45
python3 # for data-generators
systemd # used for checks to install systemd user service
dbus # used for checks and pkg-config to install dbus service/s
] ++ checkInputs; # gi is in the main meson.build and checked regardless of
# whether tests are enabled
(python3.pythonForBuild.withPackages (p: [ p.pygobject3 ]))
];
buildInputs = [
glib
@ -74,15 +76,24 @@ stdenv.mkDerivation rec {
libuuid
json-glib
libstemmer
];
checkInputs = with python3.pkgs; [
pygobject3
dbus
systemd
];
mesonFlags = [
"-Ddocs=true"
];
] ++ (
let
# https://gitlab.gnome.org/GNOME/tracker/-/blob/master/meson.build#L159
crossFile = writeText "cross-file.conf" ''
[properties]
sqlite3_has_fts5 = '${lib.boolToString (lib.hasInfix "-DSQLITE_ENABLE_FTS3" sqlite.NIX_CFLAGS_COMPILE)}'
'';
in
[
"--cross-file=${crossFile}"
]
);
doCheck = true;