unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Pierre Neidhardt <mail@ambrevar.xyz>
To: 41135@debbugs.gnu.org
Subject: [bug#41135] [PATCH 1/4] build: asdf-build-system: Use SBCL source in CL packages.
Date: Fri,  8 May 2020 19:39:37 +0200	[thread overview]
Message-ID: <20200508173940.20147-1-mail@ambrevar.xyz> (raw)
In-Reply-To: <20200508064827.1270-1-mail@ambrevar.xyz>

* guix/build/asdf-build-system.scm (copy-files-to-output): Don't attempt to
  reset timestamps on files without write access.
  (install): When parent SBCL package is in the inputs, use its source.  This
  way we get possibly patched sources in CL packages as well (e.g. for FFI).
  This is also useful for sources that generate files on load-op, like cl-unicode.

* guix/build-system/asdf.scm (package-with-build-system): Forward the SBCL
  parent as a native input so that it can be used in the install phase above.
---
 guix/build-system/asdf.scm       |  5 ++-
 guix/build/asdf-build-system.scm | 54 ++++++++++++++++++++++++++++----
 2 files changed, 52 insertions(+), 7 deletions(-)

diff --git a/guix/build-system/asdf.scm b/guix/build-system/asdf.scm
index f794bf006b..630b99e2bf 100644
--- a/guix/build-system/asdf.scm
+++ b/guix/build-system/asdf.scm
@@ -230,7 +230,10 @@ set up using CL source package conventions."
              ((#:phases phases) (list phases-transformer phases))))
           (inputs (new-inputs package-inputs))
           (propagated-inputs (new-propagated-inputs))
-          (native-inputs (new-inputs package-native-inputs))
+          (native-inputs (append (if target-is-source?
+                                     (list (list (package-name pkg) pkg))
+                                     '())
+                                 (new-inputs package-native-inputs)))
           (outputs (if target-is-source?
                        '("out")
                        (package-outputs pkg)))))
diff --git a/guix/build/asdf-build-system.scm b/guix/build/asdf-build-system.scm
index f3f4b49bcf..25dd031962 100644
--- a/guix/build/asdf-build-system.scm
+++ b/guix/build/asdf-build-system.scm
@@ -85,7 +85,8 @@ valid."
     ;; files before compiling.
     (for-each (lambda (file)
                 (let ((s (lstat file)))
-                  (unless (eq? (stat:type s) 'symlink)
+                  (unless (or (eq? (stat:type s) 'symlink)
+                              (not (access? file W_OK)))
                     (utime file 0 0 0 0))))
               (find-files source #:directories? #t))
     (copy-recursively source target #:keep-mtime? #t)
@@ -97,12 +98,53 @@ valid."
      (find-files target "\\.asd$"))
     #t))
 
-(define* (install #:key outputs #:allow-other-keys)
-  "Copy and symlink all the source files."
+(define* (install #:key inputs outputs #:allow-other-keys)
+  "Copy and symlink all the source files.
+The source files are taken from the corresponding compile package (e.g. SBCL)
+if it's present in the native-inputs."
   (define output (assoc-ref outputs "out"))
-  (copy-files-to-output output
-                        (package-name->name+version
-                         (strip-store-file-name output))))
+  (define package-name
+    (package-name->name+version
+     (strip-store-file-name output)))
+  (define (no-prefix pkgname)
+    (if (string-index pkgname #\-)
+        (string-drop pkgname (1+ (string-index pkgname #\-)))
+        pkgname))
+  (define parent
+    (match (assoc package-name inputs
+                  (lambda (key alist-car)
+                    (let* ((alt-key (no-prefix key))
+                           (alist-car (no-prefix alist-car)))
+                      (or (string=? alist-car key)
+                          (string=? alist-car alt-key)))))
+      (#f #f)
+      (p (cdr p))))
+  (define parent-name
+    (and parent
+         (package-name->name+version (strip-store-file-name parent))))
+  (define parent-source
+    (and parent
+         (string-append parent "/share/common-lisp/"
+                        (string-take parent-name
+                                     (string-index parent-name #\-))
+                        "-source")))
+
+  (define (first-subdirectory directory) ; From gnu-build-system.
+    "Return the file name of the first sub-directory of DIRECTORY."
+    (match (scandir directory
+                    (lambda (file)
+                      (and (not (member file '("." "..")))
+                           (file-is-directory? (string-append directory "/"
+                                                              file)))))
+      ((first . _) first)))
+  (define source-directory
+    (if (and parent-source
+             (file-exists? parent-source))
+        (string-append parent-source "/" (first-subdirectory parent-source))
+        "."))
+
+  (with-directory-excursion source-directory
+    (copy-files-to-output output package-name)))
 
 (define* (copy-source #:key outputs asd-system-name #:allow-other-keys)
   "Copy the source to the library output."
-- 
2.25.1





  parent reply	other threads:[~2020-05-08 17:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08  6:48 [bug#41135] [PATCH 1/3] build: asdf-build-system: Use SBCL source in CL packages Pierre Neidhardt
2020-05-08  6:58 ` [bug#41135] [PATCH 2/3] gnu: cl-dexador: Fix build with new sbcl-package->cl-source-package function Pierre Neidhardt
2020-05-08  6:58   ` [bug#41135] [PATCH 3/3] gnu: cl-iolib: Propagate libfixposix or else it won't compile Pierre Neidhardt
2020-05-08 10:37 ` [bug#41135] [Patch v2 1/4] build: asdf-build-system: Use SBCL source in CL packages Pierre Neidhardt
2020-05-08 10:37   ` [bug#41135] [Patch v2 2/4] gnu: cl-dexador: Fix build with new sbcl-package->cl-source-package function Pierre Neidhardt
2020-05-08 10:37   ` [bug#41135] [Patch v2 3/4] gnu: cl-iolib: Propagate libfixposix or else it won't compile Pierre Neidhardt
     [not found] ` <handler.41135.B.158892052723318.ack@debbugs.gnu.org>
2020-05-08 16:36   ` [bug#41135] Acknowledgement ([PATCH 1/3] build: asdf-build-system: Use SBCL source in CL packages.) Pierre Neidhardt
2020-05-21  9:54     ` Pierre Neidhardt
2020-05-08 17:39 ` Pierre Neidhardt [this message]
2020-05-08 17:39   ` [bug#41135] [PATCH 2/4] gnu: cl-dexador: Fix build with new sbcl-package->cl-source-package function Pierre Neidhardt
2020-05-08 17:39   ` [bug#41135] [PATCH 3/4] gnu: cl-iolib: Propagate libfixposix or else it won't compile Pierre Neidhardt
2020-05-08 17:42 ` [bug#41135] [Patch v3 1/4] build: asdf-build-system: Use SBCL source in CL packages Pierre Neidhardt
2020-05-08 17:43   ` [bug#41135] [Patch v3 2/4] gnu: cl-dexador: Fix build with new sbcl-package->cl-source-package function Pierre Neidhardt
2020-05-08 17:43   ` [bug#41135] [Patch v3 3/4] gnu: cl-iolib: Propagate libfixposix or else it won't compile Pierre Neidhardt
2020-05-09  8:50   ` [bug#41135] [Patch v3 4/4] gnu: cl-cffi-gtk-gobject: Fix build with new Pierre Neidhardt

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20200508173940.20147-1-mail@ambrevar.xyz \
    --to=mail@ambrevar.xyz \
    --cc=41135@debbugs.gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).