diff mbox

gnu: tuxguitar: Update to 1.3.2.

Message ID 20160803164503.10103-1-rekado@elephly.net
State New
Headers show

Commit Message

Ricardo Wurmus Aug. 3, 2016, 4:45 p.m. UTC
* gnu/packages/music.scm (tuxguitar): Update to 1.3.2.
[arguments]: Use ant-build-system and rearrange build phases.
[native-inputs]: Remove field.
---
 gnu/packages/music.scm | 97 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 69 insertions(+), 28 deletions(-)

Comments

Andreas Enge Aug. 4, 2016, 8:43 a.m. UTC | #1
Hello,

On Wed, Aug 03, 2016 at 06:45:03PM +0200, Ricardo Wurmus wrote:
> * gnu/packages/music.scm (tuxguitar): Update to 1.3.2.
> [arguments]: Use ant-build-system and rearrange build phases.
> [native-inputs]: Remove field.

looks good!

> +         (add-after 'unpack 'enter-dir-and-set-flags
> +           (lambda _ (chdir "TuxGuitar-lib") #t))

The name of the phase seems to be inherited from a previous edition where
flags were set.

> +               ;; create wrapper
> +               (call-with-output-file (string-append bin "/tuxguitar")
> +                 (lambda (port)
> +                   (let ((classpath (string-join (append (find-files lib "\\.jar$")
> +                                                         (find-files swt "\\.jar$"))
> +                                                 ":")))
> +                     (format
> +                      port
> +                      (string-append "#!/bin/sh\n"
> +                                     (which "java")
> +                                     " -cp " classpath
> +                                     " -Dtuxguitar.home.path=" out
> +                                     " -Dtuxguitar.share.path=" out "/share"
> +                                     " -Dswt.library.path=" swt "/lib"
> +                                     " org.herac.tuxguitar.app.TGMainSingleton"
> +                                     " \"$1\" \"$2\"")))))
> +               (chmod (string-append bin "/tuxguitar") #o555)
> +               #t))))))

This one I do not fully understand; my first impression was that it used
the file names from the build directory for the classpath variable. But this
is working since they are relative file names? And the "-D" parameters make
that they are searched for in the correct directories? Should these be
replaced by absolute file names (which might end up being too long)?

Andreas
Ricardo Wurmus Aug. 4, 2016, 12:41 p.m. UTC | #2
Andreas Enge <andreas@enge.fr> writes:

> Hello,
>
> On Wed, Aug 03, 2016 at 06:45:03PM +0200, Ricardo Wurmus wrote:
>> * gnu/packages/music.scm (tuxguitar): Update to 1.3.2.
>> [arguments]: Use ant-build-system and rearrange build phases.
>> [native-inputs]: Remove field.
>
> looks good!
>
>> +         (add-after 'unpack 'enter-dir-and-set-flags
>> +           (lambda _ (chdir "TuxGuitar-lib") #t))
>
> The name of the phase seems to be inherited from a previous edition where
> flags were set.

Ah, I’ll change this.

>> +               ;; create wrapper
>> +               (call-with-output-file (string-append bin "/tuxguitar")
>> +                 (lambda (port)
>> +                   (let ((classpath (string-join (append (find-files lib "\\.jar$")
>> +                                                         (find-files swt "\\.jar$"))
>> +                                                 ":")))
>> +                     (format
>> +                      port
>> +                      (string-append "#!/bin/sh\n"
>> +                                     (which "java")
>> +                                     " -cp " classpath
>> +                                     " -Dtuxguitar.home.path=" out
>> +                                     " -Dtuxguitar.share.path=" out "/share"
>> +                                     " -Dswt.library.path=" swt "/lib"
>> +                                     " org.herac.tuxguitar.app.TGMainSingleton"
>> +                                     " \"$1\" \"$2\"")))))
>> +               (chmod (string-append bin "/tuxguitar") #o555)
>> +               #t))))))
>
> This one I do not fully understand; my first impression was that it used
> the file names from the build directory for the classpath variable. But this
> is working since they are relative file names? And the "-D" parameters make
> that they are searched for in the correct directories? Should these be
> replaced by absolute file names (which might end up being too long)?

The classpath consists of only absolute paths to jar files.  This is the
install phase and right before the snippet you quoted the jar files were
installed to their target directories.

The “-D” arguments are needed to define resource variables.  They are
unrelated to the classpath.  “swt.library.path” is used to find the
native library component of SWT.

I’ll push this to master tonight.

~~ Ricardo
Andreas Enge Aug. 4, 2016, 12:45 p.m. UTC | #3
On Thu, Aug 04, 2016 at 02:41:27PM +0200, Ricardo Wurmus wrote:
> >> +                   (let ((classpath (string-join (append (find-files lib "\\.jar$")
> >> +                                                         (find-files swt "\\.jar$"))
> The classpath consists of only absolute paths to jar files.  This is the
> install phase and right before the snippet you quoted the jar files were
> installed to their target directories.

Sorry for the confusion, I am so used to find-files looking for files in the
current directory, that I forgot the parameter "." given in these cases and
that it is "lib" and "swt" here.

Andreas
diff mbox

Patch

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 8dbdf2c..9ec75c1 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -31,6 +31,7 @@ 
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system ant)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system python)
   #:use-module (guix build-system waf)
@@ -904,45 +905,85 @@  is subjective.")
 (define-public tuxguitar
   (package
     (name "tuxguitar")
-    (version "1.2")
+    (version "1.3.2")
     (source (origin
               (method url-fetch)
               (uri (string-append
                     "mirror://sourceforge/tuxguitar/TuxGuitar/TuxGuitar-"
-                    version "/tuxguitar-src-" version ".tar.gz"))
+                    version "/tuxguitar-" version "-src.tar.gz"))
               (sha256
                (base32
-                "1g1yf2gd06fzdhqb8kb8dmdcmr602s9y24f01kyl4940wimgr944"))))
-    (build-system gnu-build-system)
+                "0ldml31zvywid1w28mfd65ramyiics55fdl0ch846vm7j7nwv58j"))
+              (modules '((guix build utils)))
+              (snippet
+               ;; Delete pre-built classes
+               '(delete-file-recursively "TuxGuitar-android/bin"))))
+    (build-system ant-build-system)
     (arguments
-     `(#:make-flags (list (string-append "LDFLAGS=-Wl,-rpath="
-                                         (assoc-ref %outputs "out") "/lib")
-                          (string-append "PREFIX="
-                                         (assoc-ref %outputs "out"))
-                          (string-append "SWT_PATH="
-                                         (assoc-ref %build-inputs "java-swt")
-                                         "/share/java/swt.jar"))
-       #:tests? #f ;no "check" target
-       #:parallel-build? #f ;not supported
+     `(#:build-target "build"
+       #:tests? #f ; no tests
        #:phases
        (modify-phases %standard-phases
-         (delete 'configure)
-         (add-before 'build 'enter-dir-and-set-flags
-          (lambda* (#:key inputs #:allow-other-keys)
-            (chdir "TuxGuitar")
-            (substitute* "GNUmakefile"
-              (("GCJFLAGS\\+=(.*)" _ rest)
-               (string-append "GCJFLAGS=-fsource=1.4 -fPIC " rest))
-              (("PROPERTIES\\?=")
-               (string-append "PROPERTIES?= -Dswt.library.path="
-                              (assoc-ref inputs "java-swt") "/lib"))
-              (("\\$\\(GCJ\\) -o") "$(GCJ) $(LDFLAGS) -o"))
-            #t)))))
+         (add-after 'unpack 'enter-dir-and-set-flags
+           (lambda _ (chdir "TuxGuitar-lib") #t))
+         (add-after 'build 'build-editor-utils
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (chdir "..")
+             (let ((cwd (getcwd)))
+               (setenv "CLASSPATH"
+                       (string-append
+                        cwd "/TuxGuitar-lib/tuxguitar-lib.jar" ":"
+                        cwd "/TuxGuitar-editor-utils/build/jar/tuxguitar-editor-utils.jar" ":"
+                        (getenv "CLASSPATH"))))
+             (chdir "TuxGuitar-editor-utils")
+             ;; Generate default build.xml
+             ((@@ (guix build ant-build-system) default-build.xml)
+              "tuxguitar-editor-utils.jar"
+              (string-append (assoc-ref outputs "out")
+                             "/share/java"))
+             ((assoc-ref %standard-phases 'build))))
+         (add-after 'build-editor-utils 'build-application
+           (lambda _
+             (chdir "../TuxGuitar")
+             ((assoc-ref %standard-phases 'build)
+              #:build-target "build")))
+         (replace 'install
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out   (assoc-ref outputs "out"))
+                    (bin   (string-append out "/bin"))
+                    (share (string-append out "/share"))
+                    (lib   (string-append share "/java"))
+                    (swt   (assoc-ref inputs "java-swt")))
+               (mkdir-p bin)
+               (mkdir-p lib)
+               ;; install all jars
+               (for-each (lambda (file)
+                           (install-file file lib))
+                         (find-files ".." "\\.jar$"))
+               ;; install all resources
+               (for-each (lambda (file)
+                           (install-file file share))
+                         (find-files "share" ".*"))
+               ;; create wrapper
+               (call-with-output-file (string-append bin "/tuxguitar")
+                 (lambda (port)
+                   (let ((classpath (string-join (append (find-files lib "\\.jar$")
+                                                         (find-files swt "\\.jar$"))
+                                                 ":")))
+                     (format
+                      port
+                      (string-append "#!/bin/sh\n"
+                                     (which "java")
+                                     " -cp " classpath
+                                     " -Dtuxguitar.home.path=" out
+                                     " -Dtuxguitar.share.path=" out "/share"
+                                     " -Dswt.library.path=" swt "/lib"
+                                     " org.herac.tuxguitar.app.TGMainSingleton"
+                                     " \"$1\" \"$2\"")))))
+               (chmod (string-append bin "/tuxguitar") #o555)
+               #t))))))
     (inputs
      `(("java-swt" ,java-swt)))
-    (native-inputs
-     `(("gcj" ,gcj)
-       ("pkg-config" ,pkg-config)))
     (home-page "http://tuxguitar.com.ar")
     (synopsis "Multitrack tablature editor and player")
     (description