diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/glib/default.nix')
-rw-r--r-- | nixpkgs/pkgs/development/libraries/glib/default.nix | 167 |
1 files changed, 116 insertions, 51 deletions
diff --git a/nixpkgs/pkgs/development/libraries/glib/default.nix b/nixpkgs/pkgs/development/libraries/glib/default.nix index 8fb12fc0203a..2f50ed4b259d 100644 --- a/nixpkgs/pkgs/development/libraries/glib/default.nix +++ b/nixpkgs/pkgs/development/libraries/glib/default.nix @@ -1,18 +1,27 @@ -{ config, lib, stdenv, fetchurl, gettext, meson, ninja, pkg-config, perl, python3 -, libiconv, zlib, libffi, pcre, libelf, gnome, libselinux, bash, gnum4, gtk-doc, docbook_xsl, docbook_xml_dtd_45 +{ config +, lib +, stdenv +, fetchurl +, fetchpatch2 +, gettext +, meson +, ninja +, pkg-config +, perl +, python3 +, libiconv, zlib, libffi, pcre2, libelf, gnome, libselinux, bash, gnum4, gtk-doc, docbook_xsl, docbook_xml_dtd_45, libxslt # use util-linuxMinimal to avoid circular dependency (util-linux, systemd, glib) , util-linuxMinimal ? null , buildPackages # this is just for tests (not in the closure of any regular package) -, doCheck ? config.doCheckByDefault or false , coreutils, dbus, libxml2, tzdata , desktop-file-utils, shared-mime-info -, darwin, fetchpatch +, darwin +, makeHardcodeGsettingsPatch +, testers }: -with lib; - assert stdenv.isLinux -> util-linuxMinimal != null; # TODO: @@ -23,7 +32,7 @@ assert stdenv.isLinux -> util-linuxMinimal != null; # $out/bin/gtester-report' to postInstall if this is solved /* * Use --enable-installed-tests for GNOME-related packages, - and use them as a separately installed tests runned by Hydra + and use them as a separately installed tests run by Hydra (they should test an already installed package) https://wiki.gnome.org/GnomeGoals/InstalledTests * Support org.freedesktop.Application, including D-Bus activation from desktop files @@ -41,30 +50,29 @@ let done ln -sr -t "''${!outputInclude}/include/" "''${!outputInclude}"/lib/*/include/* 2>/dev/null || true ''; + + buildDocs = stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.hostPlatform.isStatic; in -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "glib"; - version = "2.72.3"; + version = "2.76.2"; src = fetchurl { - url = "mirror://gnome/sources/glib/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz"; - sha256 = "Sjmi9iS4US1QDVhAFz7af6hfUcEJBS6ugGrOzoXTRfA="; + url = "mirror://gnome/sources/glib/${lib.versions.majorMinor finalAttrs.version}/glib-${finalAttrs.version}.tar.xz"; + sha256 = "JPOEeFex2GdM2wOJo27ewPE8ZmzTznJ+zTQOudqKyp4="; }; - patches = optionals stdenv.isDarwin [ + patches = lib.optionals stdenv.isDarwin [ ./darwin-compilation.patch - ] ++ optionals stdenv.hostPlatform.isMusl [ + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ ./quark_init_on_demand.patch ./gobject_init_on_demand.patch ] ++ [ ./glib-appinfo-watch.patch ./schema-override-variable.patch - # Add support for the GNOME’s default terminal emulator. - # https://gitlab.gnome.org/GNOME/glib/-/issues/2618 - ./gnome-console-support.patch - # Do the same for Pantheon’s terminal emulator. + # Add support for Pantheon’s terminal emulator. ./elementary-terminal-support.patch # GLib contains many binaries used for different purposes; @@ -90,22 +98,28 @@ stdenv.mkDerivation rec { # 3. Tools for desktop environment that cannot go to $bin due to $out depending on them ($out) # * gio-launch-desktop ./split-dev-programs.patch - ] ++ optional doCheck ./skip-timer-test.patch; + + # Disable flaky test. + # https://gitlab.gnome.org/GNOME/glib/-/issues/820 + ./skip-timer-test.patch + ]; outputs = [ "bin" "out" "dev" "devdoc" ]; setupHook = ./setup-hook.sh; buildInputs = [ - libelf setupHook pcre - ] ++ optionals (!stdenv.hostPlatform.isWindows) [ + libelf + finalAttrs.setupHook + pcre2 + ] ++ lib.optionals (!stdenv.hostPlatform.isWindows) [ bash gnum4 # install glib-gettextize and m4 macros for other apps to use - ] ++ optionals stdenv.isLinux [ + ] ++ lib.optionals stdenv.isLinux [ libselinux util-linuxMinimal # for libmount - ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ + ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ AppKit Carbon Cocoa CoreFoundation CoreServices Foundation - ]) ++ optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ + ]) ++ lib.optionals buildDocs [ # Note: this needs to be both in buildInputs and nativeBuildInputs. The # Meson gtkdoc module uses find_program to look it up (-> build dep), but # glib's own Meson configuration uses the host pkg-config to find its @@ -121,10 +135,18 @@ stdenv.mkDerivation rec { strictDeps = true; nativeBuildInputs = [ - (buildPackages.meson.override { - withDarwinFrameworksGtkDocPatch = stdenv.isDarwin; - }) - ninja pkg-config perl python3 gettext gtk-doc docbook_xsl docbook_xml_dtd_45 libxml2 + meson + ninja + pkg-config + perl + python3 + gettext + libxslt + docbook_xsl + ] ++ lib.optionals buildDocs [ + gtk-doc + docbook_xml_dtd_45 + libxml2 ]; propagatedBuildInputs = [ zlib libffi gettext libiconv ]; @@ -132,12 +154,17 @@ stdenv.mkDerivation rec { mesonFlags = [ # Avoid the need for gobject introspection binaries in PATH in cross-compiling case. # Instead we just copy them over from the native output. - "-Dgtk_doc=${boolToString (stdenv.hostPlatform == stdenv.buildPlatform)}" + "-Dgtk_doc=${lib.boolToString buildDocs}" "-Dnls=enabled" "-Ddevbindir=${placeholder "dev"}/bin" + ] ++ lib.optionals (!stdenv.isDarwin) [ + "-Dman=true" # broken on Darwin + ] ++ lib.optionals stdenv.isFreeBSD [ + "-Db_lundef=false" + "-Dxattr=false" ]; - NIX_CFLAGS_COMPILE = toString [ + env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=nonnull" # Default for release buildtype but passed manually because # we're using plain @@ -152,11 +179,26 @@ stdenv.mkDerivation rec { patchShebangs glib/gen-unicode-tables.pl patchShebangs glib/tests/gen-casefold-txt.py patchShebangs glib/tests/gen-casemap-txt.py + patchShebangs tools/gen-visibility-macros.py + + # Needs machine-id, comment the test + sed -e '/\/gdbus\/codegen-peer-to-peer/ s/^\/*/\/\//' -i gio/tests/gdbus-peer.c + sed -e '/g_test_add_func/ s/^\/*/\/\//' -i gio/tests/gdbus-address-get-session.c + # All gschemas fail to pass the test, upstream bug? + sed -e '/g_test_add_data_func/ s/^\/*/\/\//' -i gio/tests/gschema-compile.c + # Cannot reproduce the failing test_associations on hydra + sed -e '/\/appinfo\/associations/d' -i gio/tests/appinfo.c + # Needed because of libtool wrappers + sed -e '/g_subprocess_launcher_set_environ (launcher, envp);/a g_subprocess_launcher_setenv (launcher, "PATH", g_getenv("PATH"), TRUE);' -i gio/tests/gsubprocess.c '' + lib.optionalString stdenv.hostPlatform.isWindows '' substituteInPlace gio/win32/meson.build \ --replace "libintl, " "" ''; + postConfigure = '' + patchShebangs gio/gdbus-2.0/codegen/gdbus-codegen gobject/glib-{genmarshal,mkenums} + ''; + DETERMINISTIC_BUILD = 1; postInstall = '' @@ -165,40 +207,41 @@ stdenv.mkDerivation rec { sed -i "$dev/bin/glib-gettextize" -e "s|^gettext_dir=.*|gettext_dir=$dev/share/glib-2.0/gettext|" # This file is *included* in gtk3 and would introduce runtime reference via __FILE__. - sed '1i#line 1 "${pname}-${version}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \ + sed '1i#line 1 "glib-${finalAttrs.version}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \ -i "$dev"/include/glib-2.0/gobject/gobjectnotifyqueue.c - '' + optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + for i in $bin/bin/*; do + moveToOutput "share/bash-completion/completions/''${i##*/}" "$bin" + done + for i in $dev/bin/*; do + moveToOutput "share/bash-completion/completions/''${i##*/}" "$dev" + done + '' + lib.optionalString (!buildDocs) '' cp -r ${buildPackages.glib.devdoc} $devdoc ''; - checkInputs = [ tzdata desktop-file-utils shared-mime-info ]; + # Move man pages to the same output as their binaries (needs to be + # done after preFixupHooks which moves man pages too - in + # _multioutDocs) + postFixup = '' + for i in $dev/bin/*; do + moveToOutput "share/man/man1/''${i##*/}.1.*" "$dev" + done + ''; - preCheck = optionalString doCheck '' - export LD_LIBRARY_PATH="$NIX_BUILD_TOP/${pname}-${version}/glib/.libs''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" + nativeCheckInputs = [ tzdata desktop-file-utils shared-mime-info ]; + + preCheck = lib.optionalString finalAttrs.doCheck or config.doCheckByDefault or false '' + export LD_LIBRARY_PATH="$NIX_BUILD_TOP/glib-${finalAttrs.version}/glib/.libs''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" export TZDIR="${tzdata}/share/zoneinfo" export XDG_CACHE_HOME="$TMP" export XDG_RUNTIME_HOME="$TMP" export HOME="$TMP" export XDG_DATA_DIRS="${desktop-file-utils}/share:${shared-mime-info}/share" - export G_TEST_DBUS_DAEMON="${dbus.daemon}/bin/dbus-daemon" + export G_TEST_DBUS_DAEMON="${dbus}/bin/dbus-daemon" export PATH="$PATH:$(pwd)/gobject" echo "PATH=$PATH" - - substituteInPlace gio/tests/desktop-files/home/applications/epiphany-weather-for-toronto-island-9c6a4e022b17686306243dada811d550d25eb1fb.desktop \ - --replace "Exec=/bin/true" "Exec=${coreutils}/bin/true" - # Needs machine-id, comment the test - sed -e '/\/gdbus\/codegen-peer-to-peer/ s/^\/*/\/\//' -i gio/tests/gdbus-peer.c - sed -e '/g_test_add_func/ s/^\/*/\/\//' -i gio/tests/gdbus-unix-addresses.c - # All gschemas fail to pass the test, upstream bug? - sed -e '/g_test_add_data_func/ s/^\/*/\/\//' -i gio/tests/gschema-compile.c - # Cannot reproduce the failing test_associations on hydra - sed -e '/\/appinfo\/associations/d' -i gio/tests/appinfo.c - # Needed because of libtool wrappers - sed -e '/g_subprocess_launcher_set_environ (launcher, envp);/a g_subprocess_launcher_setenv (launcher, "PATH", g_getenv("PATH"), TRUE);' -i gio/tests/gsubprocess.c ''; - inherit doCheck; - separateDebugInfo = stdenv.isLinux; passthru = rec { @@ -209,18 +252,40 @@ stdenv.mkDerivation rec { getSchemaPath = pkg: makeSchemaPath pkg pkg.name; getSchemaDataDirPath = pkg: makeSchemaDataDirPath pkg pkg.name; + tests = { + withChecks = finalAttrs.finalPackage.overrideAttrs (_: { doCheck = true; }); + pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + }; + inherit flattenInclude; updateScript = gnome.updateScript { packageName = "glib"; versionPolicy = "odd-unstable"; }; + + mkHardcodeGsettingsPatch = + { + src, + glib-schema-to-var, + }: + builtins.trace + "glib.mkHardcodeGsettingsPatch is deprecated, please use makeHardcodeGsettingsPatch instead" + (makeHardcodeGsettingsPatch { + inherit src; + schemaIdToVariableMapping = glib-schema-to-var; + }); }; meta = with lib; { description = "C library of programming buildings blocks"; - homepage = "https://www.gtk.org/"; + homepage = "https://wiki.gnome.org/Projects/GLib"; license = licenses.lgpl21Plus; maintainers = teams.gnome.members ++ (with maintainers; [ lovek323 raskin ]); + pkgConfigModules = [ + "gio-2.0" + "gobject-2.0" + "gthread-2.0" + ]; platforms = platforms.unix; longDescription = '' @@ -230,4 +295,4 @@ stdenv.mkDerivation rec { set of utility functions for strings and common data structures. ''; }; -} +}) |