@@ -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)))))
@@ -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,39 @@ 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 SBCL package if it's present
+in the native-inputs."
+ ;; TODO: Use lisp-type instead of hardcoding SBCL.
(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-name (string-drop package-name (string-length "cl-")))
+ (define sbcl-source (or (assoc-ref inputs (string-append "sbcl-" no-prefix-name))
+ (assoc-ref inputs (string-append "sbcl-" package-name))))
+
+ (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 sbcl-source
+ (file-exists?
+ (string-append sbcl-source "/share/common-lisp/sbcl-source/")))
+ (let ((source (string-append sbcl-source "/share/common-lisp/sbcl-source/")))
+ (string-append source (first-subdirectory source)))
+ "."))
+ (with-directory-excursion source-directory
+ (copy-files-to-output output
+ (package-name->name+version
+ (strip-store-file-name output)))))
(define* (copy-source #:key outputs asd-system-name #:allow-other-keys)
"Copy the source to the library output."