From: ludo@gnu.org (Ludovic Courtès)
To: Hartmut Goebel <h.goebel@goebel-consult.de>
Cc: Guix-devel <guix-devel@gnu.org>
Subject: Re: Using a function as build-step?
Date: Mon, 05 Sep 2016 23:01:55 +0200 [thread overview]
Message-ID: <87k2equkl8.fsf@gnu.org> (raw)
In-Reply-To: <0b8f97f5-d931-a344-1000-8ab64233f026@goebel-consult.de> (Hartmut Goebel's message of "Sat, 3 Sep 2016 20:22:37 +0200")
Hi!
Hartmut Goebel <h.goebel@goebel-consult.de> 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’.
next prev parent reply other threads:[~2016-09-05 21:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-03 18:22 Using a function as build-step? Hartmut Goebel
2016-09-03 18:35 ` David Craven
2016-09-04 11:25 ` Hartmut Goebel
2016-09-04 11:29 ` David Craven
2016-09-04 11:43 ` Hartmut Goebel
2016-09-04 11:43 ` Using a function as build-step? (w/ attachement) Hartmut Goebel
2016-09-04 15:33 ` David Craven
2016-09-05 21:01 ` Ludovic Courtès [this message]
2016-09-06 7:20 ` Using a function as build-step? Ricardo Wurmus
2016-09-06 7:35 ` Hartmut Goebel
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=87k2equkl8.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guix-devel@gnu.org \
--cc=h.goebel@goebel-consult.de \
/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.