all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Olivier Dion via Guix-patches via <guix-patches@gnu.org>
To: Olivier Dion <olivier.dion@polymtl.ca>,
	Maxime Devos <maximedevos@telenet.be>,
	54780@debbugs.gnu.org
Subject: [bug#54780] [PATCH v3 1/2] guix: build: Add absolute-inclusions.scm.
Date: Thu, 21 Apr 2022 12:46:18 -0400	[thread overview]
Message-ID: <f8fd0d5178c557c999299907c09f71e08ec3402a.1650559513.git.olivier.dion@polymtl.ca> (raw)
In-Reply-To: <4b19827ee0d266ecd80dc7c5d776f3ffd764a575.1649459701.git.olivier.dion@polymtl.ca>

* guix/build/absolute-inclusions.scm: New file.
* Makefile.am (MODULES): Add it here.
---
 Makefile.am                        |  1 +
 guix/build/absolute-inclusions.scm | 59 ++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
 create mode 100644 guix/build/absolute-inclusions.scm

diff --git a/Makefile.am b/Makefile.am
index fecce7c6f7..394df67016 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -181,6 +181,7 @@ MODULES =					\
   guix/diagnostics.scm				\
   guix/ui.scm					\
   guix/status.scm				\
+  guix/build/absolute-inclusions.scm		\
   guix/build/android-ndk-build-system.scm	\
   guix/build/ant-build-system.scm		\
   guix/build/download.scm			\
diff --git a/guix/build/absolute-inclusions.scm b/guix/build/absolute-inclusions.scm
new file mode 100644
index 0000000000..34aecf198a
--- /dev/null
+++ b/guix/build/absolute-inclusions.scm
@@ -0,0 +1,59 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2022 Olivier Dion <olivier.dion@polymtl.ca>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build absolute-inclusions)
+  #:use-module (guix build utils)
+  #:use-module (ice-9 match)
+  #:use-module (rnrs exceptions)
+  #:export (absolute-inclusions patch-header-inclusions))
+
+(define (absolute-inclusions files header-locations)
+  (substitute* files
+    (("^[ \t]*#[ \t]*include[ \t]*<(.*)>[ \t]*" original header-name)
+     (guard (c ((search-error? c) original))
+       (format #f "#include <~a>"
+               (search-input-file header-locations
+                (string-append "include/" header-name)))))))
+
+(define header-file?
+  ;; See gcc(1) for the list of suffixes.
+  (let ((suffixes (list "h" "hh" "H" "hp" "hxx" "hpp" "HPP" "h++" "tcc")))
+    (file-name-predicate
+     (format #f "\\.(~a)$" (string-join suffixes "|" 'infix)))))
+
+(define (excluded-input? input)
+  ;; Exclude glibc to avoid increasing the closure size when a
+  ;; static library + binary is build.  Likewise, exclude
+  ;; linux-libre-headers.
+  (match input
+    ((_ . store-item)
+     (or (file-exists? (string-append store-item "/include/stdlib.h"))
+         (directory-exists? (string-append store-item "/include/linux"))))))
+
+(define* (patch-header-inclusions #:key inputs outputs #:allow-other-keys)
+  "Patch inclusions in C headers in OUTPUTS to use absolute file names."
+  (define header-locations
+    (filter (negate excluded-input?) (append outputs inputs)))
+  (for-each (match-lambda
+              ((_ . output)
+               (absolute-inclusions
+                (find-files (string-append output "/include")
+                            header-file?)
+                header-locations)))
+            outputs))
-- 
2.35.1





  reply	other threads:[~2022-04-21 17:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08  0:18 [bug#54780] [PATCH] gnu: lttng-ust: Fix dependencies Olivier Dion via Guix-patches via
2022-04-08 14:04 ` Maxime Devos
2022-04-08 14:23   ` Olivier Dion via Guix-patches via
2022-04-08 14:28     ` Olivier Dion via Guix-patches via
2022-04-08 15:32       ` [bug#54780] (C include header depropagation) " Maxime Devos
2022-04-08 15:39       ` Maxime Devos
2022-04-08 15:59         ` Olivier Dion via Guix-patches via
2022-04-08 17:17         ` Olivier Dion via Guix-patches via
2022-04-08 19:41           ` Maxime Devos
2022-04-08 22:56             ` Olivier Dion via Guix-patches via
2022-04-08 23:15               ` [bug#54780] [PATCH v2 1/2] guix: build: Add absolute-inclusions.scm Olivier Dion via Guix-patches via
2022-04-21 16:46                 ` Olivier Dion via Guix-patches via [this message]
2022-04-21 16:46                 ` [bug#54780] [PATCH v3 2/2] gnu: packages: Use absolute headers inclusion Olivier Dion via Guix-patches via
2022-04-08 23:15               ` [bug#54780] [PATCH v2 " Olivier Dion via Guix-patches via
2022-04-09  9:11               ` [bug#54780] [PATCH] gnu: lttng-ust: Fix dependencies Maxime Devos
2022-04-09  9:13                 ` Maxime Devos
2022-04-09 14:40                   ` Olivier Dion via Guix-patches via
2022-04-09 16:01                     ` Maxime Devos
2022-04-09 16:34                       ` Olivier Dion via Guix-patches via
2022-04-08 15:23     ` Maxime Devos
2022-05-17 20:38 ` Olivier Dion via Guix-patches via
2022-06-14 21:26   ` bug#54780: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f8fd0d5178c557c999299907c09f71e08ec3402a.1650559513.git.olivier.dion@polymtl.ca \
    --to=guix-patches@gnu.org \
    --cc=54780@debbugs.gnu.org \
    --cc=maximedevos@telenet.be \
    --cc=olivier.dion@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.