From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Using a function as build-step? Date: Mon, 05 Sep 2016 23:01:55 +0200 Message-ID: <87k2equkl8.fsf@gnu.org> References: <0b8f97f5-d931-a344-1000-8ab64233f026@goebel-consult.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bh11o-0004bs-5W for guix-devel@gnu.org; Mon, 05 Sep 2016 17:02:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bh11k-0000Wl-1a for guix-devel@gnu.org; Mon, 05 Sep 2016 17:02:03 -0400 In-Reply-To: <0b8f97f5-d931-a344-1000-8ab64233f026@goebel-consult.de> (Hartmut Goebel's message of "Sat, 3 Sep 2016 20:22:37 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Hartmut Goebel Cc: Guix-devel Hi! Hartmut Goebel 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 (=CE=BB (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. =E2=80=9Cunquote=E2=80=9D) mean that this e= xpression must be enclosed in a ` (aka. =E2=80=9Cquasiquote=E2=80=9D). See . > 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 =E2=80=98install-javadoc=E2=80=99 in there (Ricardo?). The code in there will not be in a quasiquote context, so you won=E2=80=99t= be able to use =E2=80=9C,name=E2=80=9D and =E2=80=9C,version=E2=80=9D to get a= t the package name and version. Instead, you could use =E2=80=98package-name->name+version=E2=80=99 from (g= uix build utils): (define* (install-javadoc #:key outputs =E2=80=A6) (let ((out (assoc-ref outputs "out"))) (call-with-values (lambda () (package-name->name+version (strip-store-file-name out))) (lambda (name version) =E2=80=A6)))) HTH! Ludo=E2=80=99.