From patchwork Wed Oct 27 04:51:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 34095 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5D63727BBE3; Wed, 27 Oct 2021 05:55:27 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 621AE27BBE1 for ; Wed, 27 Oct 2021 05:55:26 +0100 (BST) Received: from localhost ([::1]:39678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfayD-0003gn-HY for patchwork@mira.cbaines.net; Wed, 27 Oct 2021 00:55:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfawy-0001wn-NV for guix-patches@gnu.org; Wed, 27 Oct 2021 00:54:09 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfawy-0003pG-Fa for guix-patches@gnu.org; Wed, 27 Oct 2021 00:54:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfawy-0005A9-FF for guix-patches@gnu.org; Wed, 27 Oct 2021 00:54:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51428] [PATCH core-update-frozen 16/20] build: glib-or-gtk: Generate the gdk-pixbuf-loaders cache file in a phase. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 27 Oct 2021 04:54:08 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51428 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 51428@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 51428-submit@debbugs.gnu.org id=B51428.163531041819671 (code B ref 51428); Wed, 27 Oct 2021 04:54:08 +0000 Received: (at 51428) by debbugs.gnu.org; 27 Oct 2021 04:53:38 +0000 Received: from localhost ([127.0.0.1]:48148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfawT-000576-GX for submit@debbugs.gnu.org; Wed, 27 Oct 2021 00:53:37 -0400 Received: from mail-qk1-f177.google.com ([209.85.222.177]:37757) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfawA-00054D-CW for 51428@debbugs.gnu.org; Wed, 27 Oct 2021 00:53:19 -0400 Received: by mail-qk1-f177.google.com with SMTP id bl14so1350158qkb.4 for <51428@debbugs.gnu.org>; Tue, 26 Oct 2021 21:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lcJyvTDuX1Mct9JWU1O38Y0Gv546sTduEy0txgkIzc8=; b=pH9Ft0HaaJO3gon2zGXmN3ryf8hPWBuLL1ywcdUHYOcfgwLPNadguStUaPBU3hAw1z HQ+ahH2uRR/5GKBiP/YdE+OSw+kCXSe8FuYXzBy/lOpkx1ynEgoyRj0BGFqS0s+1/wqG OrNsdyixyBv8vovrcGhNN/MOa2Q3h3qNohP14CjVyPTUiJGnU7OpyWV9GqvZ+pvAZICB Dzv0WmUpFDXjbvdYqe3IgnkaNTEP6vOYkDY0HIhuY4Lz+3UwUpGpcOtUaN1MU+ZyD2fM ubFsf6w/S2KBwn+OlVo6Hox6YwGmsds6vo4nNF+dIfLgYOBb6iE0aLGyvk+0cddYaFDG 4Ayw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lcJyvTDuX1Mct9JWU1O38Y0Gv546sTduEy0txgkIzc8=; b=XchTZT0Y9wQjOmc8P+tdyIyu9BAxbbsWPA35o19vQHA1guZ8xUCojmfsgIcdbSjCvO dLj/aNKf0RGzmmA7bLdO9XIr34hUMYAhmVwTmekUcP0o3sJotqn0VzaaVi9OTC3RS1my Iz1S34Q6QC8eSHKgHwPg22/7ex9mxESuxYAMkOzQDK5kh6fyCZmjfNzRa9magVRa6ufZ t4y2ba7Ptx1XVPDnyPbA2V9OgtXmD9VOthObM8Pepw5epmNVXy1Hvf5JaqZvYyTWwnAc DeXkqB3S7Lt+PFbehGyYgWglfl80tpU+2/F3pA+GR5qtmJWPWTkcf0Q0njhMvgTaCKx/ /oOg== X-Gm-Message-State: AOAM532h9pC4BdEL+bp21UuGRTXsAqYLc3qjlpuJojRrXmNX9O+s0TVI 3e7hwpSud758wWCyEsCwcMYlx+khdHM= X-Google-Smtp-Source: ABdhPJwUuN8usioYLtTm3ZmC139yeVWgxXRHKlsfnTpK6rUWoljPn2mGBBhL8w3VTpNHuWRtYeWNtw== X-Received: by 2002:a37:b045:: with SMTP id z66mr22883336qke.271.1635310392631; Tue, 26 Oct 2021 21:53:12 -0700 (PDT) Received: from localhost.localdomain (dsl-10-133-98.b2b2c.ca. [72.10.133.98]) by smtp.gmail.com with ESMTPSA id bk13sm11868197qkb.58.2021.10.26.21.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:53:12 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 27 Oct 2021 00:51:47 -0400 Message-Id: <20211027045151.9889-16-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027045151.9889-1-maxim.cournoyer@gmail.com> References: <20211027045151.9889-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Adding a profile hook to do so covers most use cases, but it is still necessary to have the gdk-pixbuf loaders cache file computed at build time, as software may expect to find loaders support at that time. * guix/build/glib-or-gtk-build-system.scm: Delete trailing #t. (%gdk-pixbuf-loaders-cache-file-prefix): New variable. (generate-gdk-pixbuf-loaders-cache): New procedure. (generate-gdk-pixbuf-loaders-cache-file): Add procedure... (%standard-phases): ... and register it as a build phase. --- guix/build-system/glib-or-gtk.scm | 5 ++- guix/build/glib-or-gtk-build-system.scm | 55 +++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm index 0c88f039d2..aa9703829b 100644 --- a/guix/build-system/glib-or-gtk.scm +++ b/guix/build-system/glib-or-gtk.scm @@ -26,6 +26,8 @@ (define-module (guix build-system glib-or-gtk) #:use-module (guix monads) #:use-module (guix derivations) #:use-module (guix search-paths) + #:use-module ((guix build glib-or-gtk-build-system) + #:select (%gdk-pixbuf-loaders-cache-file)) #:use-module (guix build-system) #:use-module (guix build-system gnu) #:use-module (guix packages) @@ -33,7 +35,8 @@ (define-module (guix build-system glib-or-gtk) #:export (%glib-or-gtk-build-system-modules glib-or-gtk-build glib-or-gtk-cross-build - glib-or-gtk-build-system)) + glib-or-gtk-build-system) + #:re-export (%gdk-pixbuf-loaders-cache-file)) ;for convenience ;; Commentary: ;; diff --git a/guix/build/glib-or-gtk-build-system.scm b/guix/build/glib-or-gtk-build-system.scm index c2f814eaeb..785eb54fdc 100644 --- a/guix/build/glib-or-gtk-build-system.scm +++ b/guix/build/glib-or-gtk-build-system.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2014, 2015 Ludovic Courtès ;;; Copyright © 2018 Mark H Weaver ;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2021 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -28,6 +29,8 @@ (define-module (guix build glib-or-gtk-build-system) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:export (%standard-phases + %gdk-pixbuf-loaders-cache-file + generate-gdk-pixbuf-loaders-cache glib-or-gtk-build)) ;; Commentary: @@ -183,8 +186,7 @@ (define handle-output (apply wrap-program program #:sh (sh) env-vars)) bin-list)))))) - (for-each handle-output outputs) - #t) + (for-each handle-output outputs)) (define* (compile-glib-schemas #:key outputs #:allow-other-keys) "Implement phase \"glib-or-gtk-compile-schemas\": compile \"glib\" schemas @@ -197,11 +199,56 @@ (define* (compile-glib-schemas #:key outputs #:allow-other-keys) (not (file-exists? (string-append schemasdir "/gschemas.compiled")))) (invoke "glib-compile-schemas" schemasdir))))) - outputs) - #t) + outputs)) + +(define %gdk-pixbuf-loaders-cache-file + "lib/gdk-pixbuf-2.0/2.10.0/loaders.cache") + +(define (generate-gdk-pixbuf-loaders-cache directories outputs) + "Generate the loaders.cache file used by gdk-pixbuf to locate the available +loaders among DIRECTORIES, and set the GDK_PIXBUF_MODULE_FILE environment +variable. The cache file is installed under OUTPUTS. Return the first cache +file name if one was created else #f." + (let* ((loaders (append-map + (cut find-files <> "^libpixbufloader-.*\\.so$") + directories)) + (outputs* (map (cut string-append <> "/" + %gdk-pixbuf-loaders-cache-file) + outputs)) + (loaders.cache (first outputs*)) + (loaders.cache-copies (cdr outputs*))) + (if (not (null? loaders)) + (begin + (mkdir-p (dirname loaders.cache)) + (setenv "GDK_PIXBUF_MODULE_FILE" loaders.cache) + (apply invoke "gdk-pixbuf-query-loaders" "--update-cache" loaders) + (for-each (lambda (f) + (mkdir-p (dirname f)) + (copy-file loaders.cache f)) + loaders.cache-copies) + loaders.cache) + #f))) + +(define* (generate-gdk-pixbuf-loaders-cache-file #:key inputs outputs + #:allow-other-keys) + "Build phase that Wraps the GENERATE-GDK-PIXBUF-LOADERS-CACHE procedure." + ;; Conditionally compute the cache file if the gdk-pixbuf command is + ;; available on PATH (it comes with gdk-pixbuf). + (when (which "gdk-pixbuf-query-loaders") + (let ((loaders.cache (generate-gdk-pixbuf-loaders-cache + (map cdr inputs) + (filter-map identity + (list + (assoc-ref outputs "out") + (assoc-ref outputs "bin") + (assoc-ref outputs "lib")))))) + (when loaders.cache + (format #t "GDK_PIXBUF_MODULE_FILE set to `~a'~%" loaders.cache))))) (define %standard-phases (modify-phases gnu:%standard-phases + (add-after 'unpack 'generate-gdk-pixbuf-loaders-cache-file + generate-gdk-pixbuf-loaders-cache-file) (add-after 'install 'glib-or-gtk-compile-schemas compile-glib-schemas) (add-after 'install 'glib-or-gtk-wrap wrap-all-programs)))