diff mbox series

[bug#35545,06/17] gnu: javacc: Install binaries.

Message ID 20190503130134.24788-6-julien@lepiller.eu
State Accepted
Headers show
Series [bug#35545,01/17] gnu: Add java-signpost-core. | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied

Commit Message

Julien Lepiller May 3, 2019, 1:01 p.m. UTC
* gnu/packages/java.scm (javacc)[arguments]: Add install-bin phase.
---
 gnu/packages/java.scm | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Comments

Ricardo Wurmus May 4, 2019, 11:52 a.m. UTC | #1
Julien Lepiller <julien@lepiller.eu> writes:

> * gnu/packages/java.scm (javacc)[arguments]: Add install-bin phase.
[…]
> +         (add-after 'install 'install-bin
> +           (lambda* (#:key outputs inputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (dir (string-append out "/share/java"))
> +                    (bin (string-append out "/bin")))
> +               (mkdir-p bin)
> +               (with-output-to-file (string-append bin "/javacc")
> +                 (lambda _
> +                   (display
> +                     (string-append "#!/bin/sh\n"
> +                                    (assoc-ref inputs "jdk") "/bin/java"
> +                                    " -cp " dir "/javacc.jar" " `basename $0`" " $*"))))

I think it’s better not to use basename here.  We already know the store
location.

> +               (chmod (string-append bin "/javacc") #o755)
> +               (symlink (string-append bin "/javacc")
> +                        (string-append bin "/jjdoc"))
> +               (symlink (string-append bin "/javacc")
> +                        (string-append bin "/jjtree"))))))))

Why symlink javacc with different names?

Since you’re reusing the javacc file name so often it makes sense to
let-bind it.

Please end the build phase on #T.

--
Ricardo
Julien Lepiller May 4, 2019, 12:14 p.m. UTC | #2
Le Sat, 04 May 2019 13:52:11 +0200,
Ricardo Wurmus <rekado@elephly.net> a écrit :

> Julien Lepiller <julien@lepiller.eu> writes:
> 
> > * gnu/packages/java.scm (javacc)[arguments]: Add install-bin
> > phase.  
> […]
> > +         (add-after 'install 'install-bin
> > +           (lambda* (#:key outputs inputs #:allow-other-keys)
> > +             (let* ((out (assoc-ref outputs "out"))
> > +                    (dir (string-append out "/share/java"))
> > +                    (bin (string-append out "/bin")))
> > +               (mkdir-p bin)
> > +               (with-output-to-file (string-append bin "/javacc")
> > +                 (lambda _
> > +                   (display
> > +                     (string-append "#!/bin/sh\n"
> > +                                    (assoc-ref inputs "jdk")
> > "/bin/java"
> > +                                    " -cp " dir "/javacc.jar" "
> > `basename $0`" " $*"))))  
> 
> I think it’s better not to use basename here.  We already know the
> store location.

basename gets the filename, not directory name of the command that was
invoked.

> 
> > +               (chmod (string-append bin "/javacc") #o755)
> > +               (symlink (string-append bin "/javacc")
> > +                        (string-append bin "/jjdoc"))
> > +               (symlink (string-append bin "/javacc")
> > +                        (string-append bin "/jjtree"))))))))  
> 
> Why symlink javacc with different names?

the name of the binary is passed as a first argument to javacc.jar, so
their behavior is different.

> 
> Since you’re reusing the javacc file name so often it makes sense to
> let-bind it.
> 
> Please end the build phase on #T.
> 
> --
> Ricardo
>
Ricardo Wurmus May 4, 2019, 5:08 p.m. UTC | #3
Julien Lepiller <julien@lepiller.eu> writes:

> Le Sat, 04 May 2019 13:52:11 +0200,
> Ricardo Wurmus <rekado@elephly.net> a écrit :
>
>> Julien Lepiller <julien@lepiller.eu> writes:
>>
>> > * gnu/packages/java.scm (javacc)[arguments]: Add install-bin
>> > phase.
>> […]
>> > +         (add-after 'install 'install-bin
>> > +           (lambda* (#:key outputs inputs #:allow-other-keys)
>> > +             (let* ((out (assoc-ref outputs "out"))
>> > +                    (dir (string-append out "/share/java"))
>> > +                    (bin (string-append out "/bin")))
>> > +               (mkdir-p bin)
>> > +               (with-output-to-file (string-append bin "/javacc")
>> > +                 (lambda _
>> > +                   (display
>> > +                     (string-append "#!/bin/sh\n"
>> > +                                    (assoc-ref inputs "jdk")
>> > "/bin/java"
>> > +                                    " -cp " dir "/javacc.jar" "
>> > `basename $0`" " $*"))))
>>
>> I think it’s better not to use basename here.  We already know the
>> store location.
>
> basename gets the filename, not directory name of the command that was
> invoked.

Ah, right.  So this is related to the symlinking further down, got it.

>> > +               (chmod (string-append bin "/javacc") #o755)
>> > +               (symlink (string-append bin "/javacc")
>> > +                        (string-append bin "/jjdoc"))
>> > +               (symlink (string-append bin "/javacc")
>> > +                        (string-append bin "/jjtree"))))))))
>>
>> Why symlink javacc with different names?
>
> the name of the binary is passed as a first argument to javacc.jar, so
> their behavior is different.

Could you please add this as a comment?

--
Ricardo
diff mbox series

Patch

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index c17b8572ec..b203856e2f 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -2290,7 +2290,25 @@  debugging, etc.")
        #:test-target "test"
        #:phases
        (modify-phases %standard-phases
-         (replace 'install (install-jars "target")))))
+         (replace 'install (install-jars "target"))
+         (add-after 'install 'install-bin
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (dir (string-append out "/share/java"))
+                    (bin (string-append out "/bin")))
+               (mkdir-p bin)
+               (with-output-to-file (string-append bin "/javacc")
+                 (lambda _
+                   (display
+                     (string-append "#!/bin/sh\n"
+                                    (assoc-ref inputs "jdk") "/bin/java"
+                                    " -cp " dir "/javacc.jar" " `basename $0`" " $*"))))
+               (chmod (string-append bin "/javacc") #o755)
+               (symlink (string-append bin "/javacc")
+                        (string-append bin "/jjdoc"))
+               (symlink (string-append bin "/javacc")
+                        (string-append bin "/jjtree"))))))))
+
     (native-inputs
      `(("javacc" ,javacc-4)))))