unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Using a function as build-step?
@ 2016-09-03 18:22 Hartmut Goebel
  2016-09-03 18:35 ` David Craven
  2016-09-05 21:01 ` Using a function as build-step? Ludovic Courtès
  0 siblings, 2 replies; 10+ messages in thread
From: Hartmut Goebel @ 2016-09-03 18:22 UTC (permalink / raw)
  To: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]

Hi,

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)
      ))

I did not manage this - not even if not using "name" and "version" and
not using any function parameters.

What is the correct code?

-- 
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software
Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: http://www.goebel-consult.de/blog/feiertagsarbeit-bei-teletrust
Kolumne: http://www.cissp-gefluester.de/2010-06-adobe-und-der-maiszunsler


[-- Attachment #2: Type: text/html, Size: 2773 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Using a function as build-step?
  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-05 21:01 ` Using a function as build-step? Ludovic Courtès
  1 sibling, 1 reply; 10+ messages in thread
From: David Craven @ 2016-09-03 18:35 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: Guix-devel

I think the problem is that the build steps are executed inside a
chroot created by the nix-daemon. So you'll have to do  (add-after
'install 'install-javadocs ,install-javadocs) to make it available.

If this is used in more than just this file, you'll have to add the
routine in a file inside guix/build/java-utils.scm and use #:modules
and #:import-modules. See the qt-utils.scm file for a simple example
and the greenisland or sddm packages that are on the mailinglist for
how to use it.

HTH!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Using a function as build-step?
  2016-09-03 18:35 ` David Craven
@ 2016-09-04 11:25   ` Hartmut Goebel
  2016-09-04 11:29     ` David Craven
  0 siblings, 1 reply; 10+ messages in thread
From: Hartmut Goebel @ 2016-09-04 11:25 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 574 bytes --]

Hi David,
> So you'll have to do  (add-after
> 'install 'install-javadocs ,install-javadocs) to make it available.

I has tried this already. For some reason this did not work for me. :-(

-- 
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software
Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: http://www.goebel-consult.de/blog/feiertagsarbeit-bei-teletrust
Kolumne: http://www.cissp-gefluester.de/2010-06-adobe-und-der-maiszunsler


[-- Attachment #2: Type: text/html, Size: 1711 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Using a function as build-step?
  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
  0 siblings, 2 replies; 10+ messages in thread
From: David Craven @ 2016-09-04 11:29 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: guix-devel

> I have tried this already. For some reason this did not work for me. :-(

Mmh. Maybe you could post a patch so that we can test it? Or maybe
someone more knowledgeable has an answer...

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Using a function as build-step?
  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
  1 sibling, 0 replies; 10+ messages in thread
From: Hartmut Goebel @ 2016-09-04 11:43 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

Am 04.09.2016 um 13:29 schrieb David Craven:(
> Mmh. Maybe you could post a patch so that we can test it? Or maybe
> someone more knowledgeable has an answer...
>

Enclosed. I assume for someone knowledgeable in guile this is a no-brainer.

-- 
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software
Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: http://www.goebel-consult.de/blog/get-current-locale-with-ansible
Kolumne: http://www.cissp-gefluester.de/2010-08-scheingefechte-um-rim


[-- Attachment #2: Type: text/html, Size: 1756 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Using a function as build-step? (w/ attachement)
  2016-09-04 11:29     ` David Craven
  2016-09-04 11:43       ` Hartmut Goebel
@ 2016-09-04 11:43       ` Hartmut Goebel
  2016-09-04 15:33         ` David Craven
  1 sibling, 1 reply; 10+ messages in thread
From: Hartmut Goebel @ 2016-09-04 11:43 UTC (permalink / raw)
  To: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 624 bytes --]

Am 04.09.2016 um 13:29 schrieb David Craven:(
> Mmh. Maybe you could post a patch so that we can test it? Or maybe
> someone more knowledgeable has an answer...
>

Enclosed. I assume for someone knowledgeable in guile this is a no-brainer.

-- 
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software
Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: http://www.goebel-consult.de/blog/get-current-locale-with-ansible
Kolumne: http://www.cissp-gefluester.de/2010-08-scheingefechte-um-rim


[-- Attachment #1.2: Type: text/html, Size: 1735 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: commons.scm --]
[-- Type: text/x-scheme; name="commons.scm", Size: 3849 bytes --]

(use-modules (guix)
             (guix build-system ant)
             (guix licenses)
(gnu packages base)
(gnu packages java)
(gnu packages zip)
)

(define* (apache-commons-url projname version 
                             #:optional (basename 
                                         (string-append "commons-" projname)))
  (string-append
   "https://archive.apache.org/dist/commons/" projname "/source/"
   basename "-" version "-src.tar.gz"))

; todo: how to use these as a phase, like
;  (replace 'install install-jars)
;  (add-after 'build build-javadoc)

(define* (symlink-junit-jar #:key outputs #:allow-other-keys)
; Put a symlink to the acutal junit.jar into lib/jsunit-VERSION.jar
  (let ((junit (assoc-ref inputs "java-junit"))
        (junit-version "4.12")) ; from build.xml
    (mkdir-p "lib")
    (symlink (string-append junit "/share/java/junit.jar")
             (string-append "lib/junit-" junit-version ".jar"))))


(define* (install-jars #:key outputs #:allow-other-keys)
  (let ((share (string-append (assoc-ref outputs "out")
                              "/share/java")))
    (for-each (λ (f) (install-file f share))
              (find-files "." "\\.jar2$"))))

(define* (build-javadoc #:key (make-flags '()) #:allow-other-keys)
; build command for calling the ant task "javadoc"
  (zero? (apply system* `("ant" "javadoc" ,@make-flags))))

(define* (install-javadoc #:key outputs #:allow-other-keys)
; build command for installing the javs docs into
; DOC/share/doc/NAME-VERSION
  (let ((docs (string-append (assoc-ref outputs "doc")
                             "/share/doc/" name "-" version "/")))
    (mkdir-p docs)
    (copy-recursively "target/apidocs" docs)))


(define-public java-commons-io
  (package
    (name "java-commons-io")
    (version "2.5")
    (source (origin
      (method url-fetch)
      (uri (apache-commons-url "io" version))
      (sha256 (base32 "0q5y41jrcjvx9hzs47x5kdhnasdy6rm4bzqd2jxl02w717m7a7v3"))))
    (build-system ant-build-system)
    (outputs '("out" "doc"))
    (arguments
     `(#:test-target "test"
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'symlink-junit.jar ;symlink-junit-jar)
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((junit (assoc-ref inputs "java-junit"))
                   (junit-version "4.12")) ; from build.xml
               (mkdir-p "lib")
	       (symlink (string-append junit "/share/java/junit.jar")
			(string-append "lib/junit-" junit-version ".jar")))
             ))
         (add-after 'build 'build-javadoc ;`build-javadoc)
           (lambda* (#:key (make-flags '()) #:allow-other-keys)
             (zero? (apply system* `("ant" "javadoc" ,@make-flags)))))
         (replace 'install ;`install-jars)
           (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$")))))
         (add-after 'install 'install-doc ;install-javadoc)
           (lambda* (#:key outputs #:allow-other-keys)
;             (`install-javadoc outputs ,name ,version)
             (let ((docs (string-append (assoc-ref outputs "doc")
                                        "/share/doc/" ,name "-" ,version "/")))
               (mkdir-p docs)
               (copy-recursively "target/apidocs" docs)
               )))

)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("(java-hamcrest-core" ,java-hamcrest-core)))
    (home-page "http://commons.apache.org/io/")
    (synopsis "Common useful IO related classes")
    (description "Commons-IO contains utility classes, stream implementations,
file filters and endian classes.")
    (license asl2.0)
))

java-commons-io

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Using a function as build-step? (w/ attachement)
  2016-09-04 11:43       ` Using a function as build-step? (w/ attachement) Hartmut Goebel
@ 2016-09-04 15:33         ` David Craven
  0 siblings, 0 replies; 10+ messages in thread
From: David Craven @ 2016-09-04 15:33 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: guix-devel

I'd put those functions in guix build java-utils.scm, that will work,
and you'll have to do that anyway...

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Using a function as build-step?
  2016-09-03 18:22 Using a function as build-step? Hartmut Goebel
  2016-09-03 18:35 ` David Craven
@ 2016-09-05 21:01 ` Ludovic Courtès
  2016-09-06  7:20   ` Ricardo Wurmus
  1 sibling, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2016-09-05 21:01 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: Guix-devel

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’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Using a function as build-step?
  2016-09-05 21:01 ` Using a function as build-step? Ludovic Courtès
@ 2016-09-06  7:20   ` Ricardo Wurmus
  2016-09-06  7:35     ` Hartmut Goebel
  0 siblings, 1 reply; 10+ messages in thread
From: Ricardo Wurmus @ 2016-09-06  7:20 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Guix-devel, Hartmut Goebel


Ludovic Courtès <ludo@gnu.org> writes:

> 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?).

I agree.

The “ant-build-system” was designed around the packages that I started
with.  It does not claim to be complete.  Having a configurable
“install-javadoc” phase in the “ant-build-system” seems useful.

~~ Ricardo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Using a function as build-step?
  2016-09-06  7:20   ` Ricardo Wurmus
@ 2016-09-06  7:35     ` Hartmut Goebel
  0 siblings, 0 replies; 10+ messages in thread
From: Hartmut Goebel @ 2016-09-06  7:35 UTC (permalink / raw)
  To: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 714 bytes --]

> Ludovic Courtès <ludo@gnu.org> writes:
>
>>
>> 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?).
> I agree.

I did this. Patches to come later this week.

-- 
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software
Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: http://www.goebel-consult.de/blog/ehrlichkeit-made-in-germany
Kolumne: http://www.cissp-gefluester.de/2010-06-adobe-und-der-maiszunsler


[-- Attachment #1.2: Type: text/html, Size: 1937 bytes --]

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 2430 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-09-06  7:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` Using a function as build-step? Ludovic Courtès
2016-09-06  7:20   ` Ricardo Wurmus
2016-09-06  7:35     ` Hartmut Goebel

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).