[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using a function as build-step?
From: |
Ludovic Courtès |
Subject: |
Re: Using a function as build-step? |
Date: |
Mon, 05 Sep 2016 23:01:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Hi!
Hartmut Goebel <address@hidden> skribis:
> while packaging some java apache common packages, I found myself adding
> some build steps over and over again, like this one:
>
> (replace 'install
> (lambda* (#:key outputs #:allow-other-keys)
> (let ((share (string-append (assoc-ref outputs "out")
> "/share/java")))
> (for-each (λ (f) (install-file f share))
> (find-files "target" "\\.jar$")))))
>
> Now I tried replacing this by a simple line like
>
> (add-after 'install 'install-javadocs install-javadocs)
>
> and of course some function:
>
> (define* (install-javadoc #:key outputs #:allow-other-keys)
> (let ((docs (string-append (assoc-ref outputs "doc")
> "/share/doc/" ,name "-" ,version "/")))
> (mkdir-p docs)
> (copy-recursively "target/apidocs" docs)
> ))
Note that the commas here (aka. “unquote”) mean that this expression
must be enclosed in a ` (aka. “quasiquote”). See
<https://www.gnu.org/software/guile/manual/html_node/Expression-Syntax.html#Expression-Syntax>.
> I did not manage this - not even if not using "name" and "version" and
> not using any function parameters.
>
> What is the correct code?
Like David, I would suggest creating a build-side module, say, (guix
build java-utils), or maybe augmenting (guix build ant-build-system),
and putting ‘install-javadoc’ in there (Ricardo?).
The code in there will not be in a quasiquote context, so you won’t be
able to use “,name” and “,version” to get at the package name and
version.
Instead, you could use ‘package-name->name+version’ from (guix build
utils):
(define* (install-javadoc #:key outputs …)
(let ((out (assoc-ref outputs "out")))
(call-with-values
(lambda ()
(package-name->name+version (strip-store-file-name out)))
(lambda (name version)
…))))
HTH!
Ludo’.
Re: Using a function as build-step?,
Ludovic Courtès <=