diff mbox series

[bug#41360,03/12] gnu: java-openjfx-graphics: Implement a complete compilation.

Message ID 20200517135138.1651512-3-levenson@mmer.org
State New
Headers show
Series [bug#41360,01/12] gnu: java-openjfx-build: Add helpful patch. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Alexey Abramov May 17, 2020, 1:51 p.m. UTC
---
 gnu/packages/java.scm | 643 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 635 insertions(+), 8 deletions(-)

Comments

Ludovic Courtès May 23, 2020, 2:04 p.m. UTC | #1
Alexey Abramov <levenson@mmer.org> skribis:

> ---
>  gnu/packages/java.scm | 643 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 635 insertions(+), 8 deletions(-)

Please add a commit log.

> +              (java-aux-class?
> +               (lambda (class)
> +                 (string-match "\\$[0-9]+.class" class)))

Probably “\\.class” instead of “.class”?

> +           (add-after 'chdir-to-a-module-directory 'compile-prism-compilers
> +             (lambda _

Maybe add a comment explaining why this phase is necessary.

> +               (let ((prism-compilers-classes "build/classes/jsl-compilers/prism")
> +                     (prism-src "src/main/jsl-prism/"))
> +                 (mkdir-p prism-compilers-classes)
> +                 (apply invoke `("javac"
> +                                 "-d" ,prism-compilers-classes
> +                                 ,@javac/h-flags
> +                                 ,@(find-files prism-src "\\.java"))))

This can be shortened as:

  (apply invoke "javac" "-d" prism-compilers-classes
         (append javac/h-flags (find-files prism-src "\\.java")))

These two comments apply to the other phases too.

More generally, why are there so many phases?  How do people normally
build it?  Gradle?

Would it make sense to factorize helpers in a new (gnu build
java-openjfx) module or similar?

Thanks,
Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index b5757217dd..4b83e963ea 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -56,6 +56,7 @@ 
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages gl)
+  #:use-module (gnu packages glib)
   #:use-module (gnu packages ghostscript) ;lcms
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages groovy)
@@ -2567,16 +2568,642 @@  distribution.")))
     (arguments
      `(#:jar-name "java-openjfx-graphics.jar"
        #:source-dir "modules/graphics/src/main/java"
-       #:tests? #f; require X
-       #:test-dir "modules/graphics/src/test"))
+       #:tests? #f               ; requires X
+       #:test-dir "modules/graphics/src/test"
+       #:test-include (list "**/*Test.*")
+       #:modules ((guix build ant-build-system)
+                  (guix build utils)
+                  (srfi srfi-1)
+                  (srfi srfi-26)
+                  (ice-9 regex)
+                  (ice-9 match))
+       #:phases
+       (let* ((jdk (assoc-ref %build-inputs "jdk"))
+              (javac/h-flags
+               `(;; When javac is compiling code it doesn't link
+                 ;; against rt.jar by default. Instead it uses special
+                 ;; symbol file lib/ct.sym with class stubs.
+                 ;; Surprisingly this file contains many but not *all*
+                 ;; of internal classes.
+                 "-XDignore.symbol.file"
+                 ;; It’s an internal option for JDK 1.7+ that prevents
+                 ;; the compiler from sharing a table that will never
+                 ;; be reused. When shared, it can’t be garbage
+                 ;; collected, continues to accumulate data, and
+                 ;; therefore wastes memory.
+                 "-XDuseUnsharedTable=true"))
+              (common-flags
+               `("-fno-strict-aliasing" "-fPIC" "-fno-omit-frame-pointer" ;; optimization flags
+                 "-fstack-protector"
+                 "-W" "-Wall" "-Wno-unused" "-Wno-parentheses" "-Werror=implicit-function-declaration"))
+              (cc-flags
+               `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                "-I" ,(string-append jdk "/include")
+                                "-I" ,(string-append jdk "/include/linux")))
+              (link-flags
+               `("-static-libgcc" "-static-libstdc++" "-shared" ,@common-flags
+                 "-z" "relro"
+                 "-Wl,--gc-sections"))
+              (java-aux-class?
+               (lambda (class)
+                 (string-match "\\$[0-9]+.class" class)))
+              (java-list-classes
+               (lambda (path)
+                 ;; For each .java file we need to figure out what
+                 ;; class the .java file belongs in and convert it to a
+                 ;; class name.
+                 (filter-map
+                  (lambda (class)
+                    (let* ((rx (make-regexp (string-append path file-name-separator-string "?")))
+                           (class (string-drop-right class (string-length ".class")))
+                           (class (match:suffix (regexp-exec rx class))))
+                      (if (java-aux-class? class)
+                          #f
+                          (string-join (string-split class #\/) "."))))
+                  (find-files path "\\.class$")))))
+         (modify-phases %standard-phases
+
+           (replace 'build
+             (lambda _
+               ;; Do not mix different classes. There will be more stuff in build/classes
+               (invoke "ant" "compile" "-Dclasses.dir=modules/graphics/build/classes/java/main")
+               #t))
+
+           (add-after 'build 'chdir-to-a-module-directory
+             (lambda _
+               (chdir (string-append (getcwd) "/modules/graphics"))
+               #t))
+
+           (add-after 'chdir-to-a-module-directory 'compile-prism-compilers
+             (lambda _
+               (let ((prism-compilers-classes "build/classes/jsl-compilers/prism")
+                     (prism-src "src/main/jsl-prism/"))
+                 (mkdir-p prism-compilers-classes)
+                 (apply invoke `("javac"
+                                 "-d" ,prism-compilers-classes
+                                 ,@javac/h-flags
+                                 ,@(find-files prism-src "\\.java"))))
+               #t))
+
+           (add-after 'compile-prism-compilers 'generate-prism-shaders
+             (lambda _
+               (let ((prism-compilers-classes "build/classes/jsl-compilers/prism")
+                     (prism-src "src/main/jsl-prism/")
+                     (prism-gen-src "build/generated-src/jsl-prism"))
+                 (mkdir-p prism-gen-src)
+                 (for-each (lambda (file)
+                             (apply invoke `("java"
+                                             "-cp" ,(string-join (list
+                                                                  ;; For CompileJSL
+                                                                  prism-compilers-classes
+                                                                  ;; jsl files are there
+                                                                  prism-src
+                                                                  (getenv "CLASSPATH"))
+                                                                 ":")
+                                             "CompileJSL"
+                                             "-i" ,prism-src
+                                             "-o" ,prism-gen-src
+                                             "-t"
+                                             "-pkg" "com/sun/prism"
+                                             "-d3d"
+                                             "-es2"
+                                             "-name" ,file)))
+                           (find-files prism-src "\\.jsl$")))
+               #t))
+
+           (add-after 'generate-prism-shaders 'compile-prism-shaders
+             (lambda _
+               (let* ((classes "build/classes/java/main")
+                      (prism-classes "build/classes/jsl-prism")
+                      (prism-gen-src "build/generated-src/jsl-prism")
+                      (prism-gen-shaders-src (string-append prism-gen-src "/com/sun/prism/shader")))
+                 (mkdir-p prism-classes)
+                 (apply invoke `("javac"
+                                 "-d" ,prism-classes
+                                 "-cp" ,(string-append classes ":" (getenv "CLASSPATH"))
+                                 ,@javac/h-flags
+                                 ,@(find-files prism-gen-shaders-src))))
+               #t))
+
+           (add-after 'compile-prism-shaders 'compile-decora-compilers
+             (lambda _
+               (let ((classes "build/classes/java/main")
+                     (decora-compilers-classes "build/classes/jsl-compilers/decora")
+                     (decora-src "src/main/jsl-decora/"))
+                 (mkdir-p decora-compilers-classes)
+                 (apply invoke `("javac"
+                                 "-d" ,decora-compilers-classes
+                                 "-cp" ,(string-append classes ":" (getenv "CLASSPATH"))
+                                 ,@javac/h-flags
+                                 ,@(find-files decora-src "\\.java"))))
+               #t))
+
+           (add-after 'compile-decora-compilers 'generate-decora-shaders
+             (lambda _
+               (let ((classes "build/classes/java/main")
+                     (decora-classes "build/classes/jsl-decora/")
+                     (decora-compilers-classes "build/classes/jsl-compilers/decora")
+                     (decora-gen-src "build/generated-src/jsl-decora")
+                     (decora-src "src/main/jsl-decora/")
+                     (decora-components '([(file-name . "ColorAdjust")
+                                           (generator . "CompileJSL")
+                                           (outputs . "-all")]
+                                          [(file-name . "Brightpass")
+                                           (generator . "CompileJSL")
+                                           (outputs . "-all")]
+                                          [(file-name . "SepiaTone")
+                                           (generator . "CompileJSL")
+                                           (outputs . "-all")]
+                                          [(file-name . "PerspectiveTransform")
+                                           (generator . "CompileJSL")
+                                           (outputs . "-all")]
+                                          [(file-name . "DisplacementMap")
+                                           (generator . "CompileJSL")
+                                           (outputs . "-all")]
+                                          [(file-name . "InvertMask")
+                                           (generator . "CompileJSL")
+                                           (outputs . "-all")]
+                                          [(file-name . "Blend")
+                                           (generator . "CompileBlend")
+                                           (outputs . "-all")]
+                                          [(file-name . "PhongLighting")
+                                           (generator . "CompilePhong")
+                                           (outputs . "-all")]
+                                          [(file-name . "LinearConvolve")
+                                           (generator . "CompileLinearConvolve")
+                                           (outputs . "-hw")]
+                                          [(file-name . "LinearConvolveShadow")
+                                           (generator . "CompileLinearConvolve")
+                                           (outputs . "-hw")])))
+                 (mkdir-p decora-gen-src)
+                 (for-each (match-lambda
+                             ((('file-name . file-name)
+                               ('generator . generator)
+                               ('outputs . outputs))
+                              (apply invoke `("java"
+                                              "-cp" ,(string-join (cons* classes
+                                                                         decora-src
+                                                                         ;; CompileJSL
+                                                                         decora-compilers-classes
+                                                                         decora-classes
+                                                                         ;; We need resources from the build
+                                                                         "../../buildSrc/src/main/resources"
+                                                                         (list (getenv "CLASSPATH")))
+                                                                  ":")
+                                              ,generator
+                                              "-i" ,decora-src
+                                              "-o" ,decora-gen-src
+                                              "-t"
+                                              "-pkg" "com/sun/scenario/effect"
+                                              ,outputs
+                                              ,file-name))))
+                           decora-components)
+                 #t)))
+
+           (add-after 'generate-decora-shaders 'compile-decora-shaders
+             (lambda _
+               (let ((classes "build/classes/java/main")
+                     (decora-classes "build/classes/jsl-decora/")
+                     (decora-gen-src "build/generated-src/jsl-decora"))
+                 (mkdir-p decora-classes)
+                 (apply invoke `("javac"
+                                 "-d" ,decora-classes
+                                 "-cp" ,classes
+                                 ,@javac/h-flags
+                                 ,@(find-files decora-gen-src "\\.java$"))))
+               #t))
+
+           (add-after 'compile-decora-shaders 'compile-decora-native-lib
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((classes "build/classes/java/main")
+                      (decora-gen-headers "build/generated-src/headers/jsl-decora")
+                      (decora-gen-src "build/generated-src/jsl-decora")
+                      (decora-native-lib "build/libs/jsl-decora/linux/libdecora_sse.so")
+                      (decora-native-obj "build/native/jsl-decora/linux")
+                      (decora-native-src "src/main/native-decora")
+                      (decora-src "src/main/jsl-decora/")
+                      (decora-classes "build/classes/jsl-decora/")
+                      (decora-cc-flags `(,@cc-flags "-ffast-math")))
+                 (mkdir-p decora-gen-headers)
+                 (apply invoke `("javah"
+                                 "-d" ,decora-gen-headers
+                                 "-cp" ,(string-join (list classes decora-classes) ":")
+                                 ,@javac/h-flags
+                                 ,@(filter (cut string-prefix? "com.sun.scenario.effect.impl.sw.sse" <>)
+                                           (append (java-list-classes classes)
+                                                   (java-list-classes decora-classes)))))
+                 (mkdir-p decora-native-obj)
+                 (for-each (lambda (cc)
+                             (apply invoke `("gcc"
+                                             ,@decora-cc-flags
+                                             "-I" ,decora-gen-headers
+                                             "-I" ,decora-gen-src
+                                             "-I" ,decora-native-src
+                                             "-o" ,(string-append decora-native-obj  "/"
+                                                                  (basename cc ".cc") ".obj")
+                                             ,cc)))
+                           (append (find-files decora-gen-src "\\.cc$")
+                                   (find-files decora-native-src "\\.cc$")))
+                 (mkdir-p (dirname decora-native-lib))
+                 (apply invoke `("g++"
+                                 "-o" ,decora-native-lib
+                                 ,@link-flags
+                                 ,@(find-files decora-native-obj "\\.obj$"))))
+               #t))
+
+           (add-after 'compile-decora-native-lib 'compile-linux-font-native-lib
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((classes "build/classes/java/main")
+                      (font-gen-headers "build/generated-src/headers/font/linux")
+                      (font-native-lib "build/libs/font/linux/libjavafx_font.so")
+                      (font-native-obj "build/native/font/linux")
+                      (font-native-src "src/main/native-font")
+                      ;;
+                      (font-cc-flags `("-DJFXFONT_PLUS" ,@cc-flags)))
+                 (mkdir-p font-gen-headers)
+                 (apply invoke `("javah"
+                                 "-d" ,font-gen-headers
+                                 "-cp" ,classes
+                                 ,@javac/h-flags
+                                 ,@(filter (lambda (class)
+                                             (or (string-prefix? "com.sun.javafx.font" class)
+                                                 (string-prefix? "com.sun.javafx.text" class)))
+                                           (java-list-classes classes))))
+                 (mkdir-p font-native-obj)
+                 (for-each (lambda (cc)
+                             (apply invoke `("gcc"
+                                             ,@font-cc-flags
+                                             "-I" ,font-gen-headers
+                                             "-I" ,font-native-src
+                                             "-o" ,(string-append font-native-obj "/"
+                                                                  (basename cc ".c") ".obj")
+                                             ,cc)))
+                           (find-files font-native-src "\\.c$"))
+                 (mkdir-p (dirname font-native-lib))
+                 (apply invoke `("g++"
+                                 "-o" ,font-native-lib
+                                 ,@link-flags
+                                 ,@(find-files font-native-obj "\\.obj$"))))
+               #t))
+
+           (add-after 'compile-linux-font-native-lib 'compile-linux-font-freetype
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((classes "build/classes/java/main")
+                      ;;
+                      (font-freetype-gen-headers "build/generated-src/headers/fontFreetype/linux")
+                      (font-freetype-native-lib "build/libs/fontFreetype/linux/libjavafx_font_freetype.so")
+                      (font-freetype-native-obj "build/native/fontFreetype/linux")
+                      (font-freetype-native-src "src/main/native-font/freetype.c")
+                      (font-freetype-cc-flags `("-DJFXFONT_PLUS" "-D_ENABLE_PANGO"
+                                                "$(pkg-config --cflags freetype2)" ,@cc-flags))
+                      (font-freetype-link-flags `("$(pkg-config --libs freetype2)" ,@link-flags)))
+                 (mkdir-p font-freetype-gen-headers)
+                 (apply invoke `("javah"
+                                 "-d" ,font-freetype-gen-headers
+                                 "-cp" ,classes
+                                 ,@javac/h-flags
+                                 ,@(filter (cut string-prefix? "com.sun.javafx.font.freetype.OSFreetype" <>)
+                                           (java-list-classes classes))))
+                 (mkdir-p font-freetype-native-obj)
+                 (invoke "bash" "-c"
+                         (string-join `("gcc"
+                                        ,@font-freetype-cc-flags
+                                        "-I" ,font-freetype-gen-headers
+                                        "-I" ,(dirname font-freetype-native-src)
+                                        "-o" ,(string-append font-freetype-native-obj "/"
+                                                             (basename font-freetype-native-src ".c") ".obj")
+                                        ,font-freetype-native-src)))
+                 (mkdir-p (dirname font-freetype-native-lib))
+                 (invoke "bash" "-c"
+                         (string-join `("g++"
+                                        "-o" ,font-freetype-native-lib
+                                        ,@font-freetype-link-flags
+                                        ,@(find-files font-freetype-native-obj "\\.obj$"))))
+                 #t)))
+
+           (add-after 'compile-linux-font-freetype 'compile-linux-font-pango-lib
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((classes "build/classes/java/main")
+                      (font-pango-gen-headers "build/generated-src/headers/fontPango/linux")
+                      (font-pango-native-lib "build/libs/fontPango/linux/libjavafx_font_pango.so")
+                      (font-pango-native-obj "build/native/fontPango/linux")
+                      (font-pango-native-src "src/main/native-font/pango.c")
+                      (font-pango-cc-flags `("-DJFXFONT_PLUS" "-D_ENABLE_PANGO"
+                                             "$(pkg-config --cflags pangoft2)" ,@cc-flags))
+                      (font-pango-link-flags `("$(pkg-config --libs pangoft2)" ,@link-flags)))
+                 (mkdir-p font-pango-gen-headers)
+                 (apply invoke `("javah"
+                                 "-d" ,font-pango-gen-headers
+                                 "-cp" ,classes
+                                 ,@javac/h-flags
+                                 ,@(filter (cut string-prefix? "com.sun.javafx.font.freetype.OSPango" <>)
+                                           (java-list-classes classes))))
+                 (mkdir-p font-pango-native-obj)
+                 (invoke "bash" "-c"
+                         (string-join `("gcc"
+                                        ,@font-pango-cc-flags
+                                        "-I" ,font-pango-gen-headers
+                                        "-I" ,(dirname font-pango-native-src)
+                                        "-o" ,(string-append font-pango-native-obj "/"
+                                                             (basename font-pango-native-src ".c") ".obj")
+                                        ,font-pango-native-src)))
+                 (mkdir-p (dirname font-pango-native-lib))
+                 (invoke "bash" "-c"
+                         (string-join `("g++"
+                                        ,@font-pango-link-flags
+                                        "-o" ,font-pango-native-lib
+                                        ,@(find-files font-pango-native-obj "\\.obj$")))))
+               #t))
+
+           (add-after 'compile-linux-font-pango-lib 'compile-linux-glass-lib
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((classes "build/classes/java/main")
+                      ;; glass
+                      (glass-gen-headers "build/generated-src/headers/glass/linux")
+                      (glass-native-lib "build/libs/glass/linux/libglass.so")
+                      (glass-native-obj "build/native/glass/linux/glass")
+                      (glass-native-src "src/main/native-glass/gtk/launcher.c")
+                      (glass-cc-flags
+                       `(,@cc-flags
+                         "$(pkg-config --cflags glib-2.0 gdk-2.0 gtk+-2.0 gthread-2.0 xtst)"
+                         "-Werror"))
+                      (glass-link-flags
+                       `(,@link-flags "$(pkg-config --libs x11)" "-ldl"))
+                      ;; glass-gtk2
+                      (gtk (assoc-ref inputs "gtk"))
+                      (glass-gtk2-native-obj "build/native/glass/linux/glassgtk2")
+                      (glass-gtk2-native-src (dirname glass-native-src))
+                      (glass-gtk2-native-lib "build/libs/glass/linux/libglassgtk2.so")
+                      (glass-gtk2-cc-flags
+                       `(,@cc-flags
+                         "$(pkg-config --cflags gtk+-2.0 gthread-2.0 xtst)"
+                         "-Werror"))
+                      (glass-gtk2-link-flags
+                       `(,@link-flags
+                         "$(pkg-config --libs gtk+-2.0 gthread-2.0 xtst)"))
+                      ;; glass-gtk3
+                      (gtk3 (assoc-ref inputs "gtk3"))
+                      (glass-gtk3-native-obj "build/native/glass/linux/glassgtk3")
+                      (glass-gtk3-native-src (dirname glass-native-src))
+                      (glass-gtk3-native-lib "build/libs/glass/linux/libglassgtk3.so")
+                      (glass-gtk3-cc-flags
+                       `(,@cc-flags
+                         "$(pkg-config --cflags gtk+-3.0 gthread-2.0 xtst)"
+                         "-Wno-deprecated-declarations" "-Werror"))
+                      (glass-gtk3-link-flags
+                       `(,@link-flags "$(pkg-config --libs gtk+-3.0 gthread-2.0 xtst)")))
+                 ;; glass
+                 (mkdir-p glass-gen-headers)
+                 (apply invoke `("javah"
+                                 "-d" ,glass-gen-headers
+                                 "-cp" ,(string-append classes ":" (getenv "CLASSPATH"))
+                                 ,@javac/h-flags
+                                 ,@(filter (lambda (class)
+                                             (or (string-prefix? "com.sun.glass.events" class)
+                                                 (string-prefix? "com.sun.glass.ui.gtk" class)
+                                                 (string-prefix? "com.sun.glass.ui" class)))
+                                           (java-list-classes classes))))
+                 (mkdir-p glass-native-obj)
+                 (invoke "bash" "-c"
+                         (string-join `("gcc"
+                                        ,@glass-cc-flags
+                                        "-I" ,glass-gen-headers
+                                        "-I" ,(dirname glass-native-src)
+                                        "-o" ,(string-append glass-native-obj "/"
+                                                             (basename glass-native-src ".c") ".obj")
+                                        ,glass-native-src)))
+                 (mkdir-p (dirname glass-native-lib))
+                 (invoke "bash" "-c"
+                         (string-join `("g++"
+                                        ,@glass-link-flags
+                                        "-o" ,glass-native-lib
+                                        ,@(find-files glass-native-obj "\\.obj$"))))
+                 ;; gtk2
+                 (mkdir-p glass-gtk2-native-obj)
+                 (for-each (lambda (cpp)
+                             (invoke "bash" "-c"
+                                     (string-join `("gcc"
+                                                    ,@glass-gtk2-cc-flags
+                                                    "-I" ,glass-gen-headers
+                                                    "-o" ,(string-append glass-gtk2-native-obj "/"
+                                                                         (basename cpp ".cpp") ".obj")
+                                                    ,cpp))))
+                           (find-files glass-gtk2-native-src "\\.cpp$"))
+                 (mkdir-p (dirname glass-gtk2-native-lib))
+                 (invoke "bash" "-c"
+                         (string-join `("g++"
+                                        ,@glass-gtk2-link-flags
+                                        "-o" ,glass-gtk2-native-lib
+                                        ,@(find-files glass-gtk2-native-obj "\\.obj$"))))
+                 ;; gtk3
+                 (mkdir-p glass-gtk3-native-obj)
+                 (for-each (lambda (cpp)
+                             (invoke "bash" "-c"
+                                     (string-join `("gcc"
+                                                    ,@glass-gtk3-cc-flags
+                                                    "-I" ,glass-gen-headers
+                                                    "-o" ,(string-append glass-gtk3-native-obj "/"
+                                                                         (basename cpp ".cpp") ".obj")
+                                                    ,cpp))))
+                           (find-files glass-gtk3-native-src "\\.cpp$"))
+                 (mkdir-p (dirname glass-gtk3-native-lib))
+                 (invoke "bash" "-c"
+                         (string-join `("g++"
+                                        ,@glass-gtk3-link-flags
+                                        "-o" ,glass-gtk3-native-lib
+                                        ,@(find-files glass-gtk3-native-obj "\\.obj$")))))
+               #t))
+
+           (add-after 'compile-linux-glass-lib  'compile-linux-iio
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((classes "build/classes/java/main")
+                      (iio-gen-headers "build/generated-src/headers/iio/linux")
+                      (iio-native-lib "build/libs/iio/linux/libjavafx_iio.so")
+                      (iio-native-obj "build/native/iio/linux")
+                      (iio-native-src "src/main/native-iio")
+                      (iio-cc-flags cc-flags)
+                      (iio-link-flags link-flags))
+                 (mkdir-p iio-gen-headers)
+                 (apply invoke `("javah"
+                                 "-d" ,iio-gen-headers
+                                 "-cp" ,(string-append classes ":" (getenv "CLASSPATH"))
+                                 ,@javac/h-flags
+                                 ,@(filter (cut string-prefix? "com.sun.javafx.iio" <>)
+                                           (java-list-classes classes))))
+                 (mkdir-p iio-native-obj)
+                 (for-each (lambda (c)
+                             (invoke "bash" "-c"
+                                     (string-join `("gcc"
+                                                    ,@iio-cc-flags
+                                                    "-I" ,iio-gen-headers
+                                                    "-o" ,(string-append iio-native-obj "/"
+                                                                         (basename c ".c") ".obj")
+                                                    ,c))))
+                           (find-files iio-native-src "\\.c$"))
+                 (mkdir-p (dirname iio-native-lib))
+                 (invoke "bash" "-c"
+                         (string-join `("g++"
+                                        ,@iio-link-flags
+                                        "-o" ,iio-native-lib
+                                        ,@(find-files iio-native-obj "\\.obj$"))))
+                 #t)))
+
+           (add-after 'compile-linux-iio 'compile-linux-prism
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((classes "build/classes/java/main")
+                      (prism-gen-headers "build/generated-src/headers/prism/linux")
+                      (prism-native-lib "build/libs/prism/linux/libprism_common.so")
+                      (prism-native-obj "build/native/prism/linux")
+                      (prism-native-src "src/main/native-prism")
+                      (prism-cc-flags `(,@cc-flags "-DINLINE=inline"))
+                      (prism-link-flags link-flags))
+                 (mkdir-p prism-gen-headers)
+                 (apply invoke `("javah"
+                                 "-d" ,prism-gen-headers
+                                 "-cp" ,(string-append classes ":" (getenv "CLASSPATH"))
+                                 ,@javac/h-flags
+                                 ,@(filter (lambda (class)
+                                             (or (string-prefix? "com.sun.prism.impl" class)
+                                                 (string-prefix? "com.sun.prism.PresentableState" class)))
+                                           (java-list-classes classes))))
+                 (mkdir-p prism-native-obj)
+                 (for-each (lambda (c)
+                             (invoke "bash" "-c"
+                                     (string-join `("gcc"
+                                                    ,@prism-cc-flags
+                                                    "-I" ,prism-gen-headers
+                                                    "-I" ,prism-native-src
+                                                    "-o" ,(string-append prism-native-obj "/"
+                                                                         (basename c ".c") ".obj")
+                                                    ,c))))
+                           (find-files prism-native-obj "\\.c$"))
+                 (mkdir-p (dirname prism-native-lib))
+                 (invoke "bash" "-c"
+                         (string-join `("g++"
+                                        ,@prism-link-flags
+                                        "-o" ,prism-native-lib
+                                        ,@(find-files prism-native-obj "\\.obj$"))))
+                 #t)))
+
+           (add-after 'compile-linux-prism 'compile-linux-prism-es2
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((classes "build/classes/java/main")
+                      (prism-es2-gen-headers "build/generated-src/headers/prismES2/linux")
+                      (prism-es2-native-lib "build/libs/prism/linux/libprism_es2.so")
+                      (prism-es2-native-obj "build/native/prismES2/linux")
+                      (prism-es2-native-src "src/main/native-prism-es2")
+                      (prism-es2-cc-flags `("-DLINUX" ,@cc-flags))
+                      (prism-es2-link-flags
+                       `(,@link-flags "$(pkg-config --libs x11 xxf86vm gl)"))
+                      ;; We need all *.c files in the root and only those
+                      ;; which are in a specific directories.
+                      (filter-src
+                       (lambda (abs _)
+                         (or (regexp-exec (make-regexp (string-append prism-es2-native-src "[^/]*\\.c$"))
+                                          abs)
+                             (regexp-exec (make-regexp (string-append prism-es2-native-src "(x11/|GL/)"))
+                                          abs)))))
+                 (mkdir-p prism-es2-gen-headers)
+                 (apply invoke `("javah"
+                                 "-d" ,prism-es2-gen-headers
+                                 "-cp" ,(string-append classes ":" (getenv "CLASSPATH"))
+                                 ,@javac/h-flags
+                                 ,@(filter (cut string-prefix? "com.sun.prism.es2" <>)
+                                           (java-list-classes classes))))
+                 (mkdir-p prism-es2-native-obj)
+                 (for-each (lambda (c)
+                             (apply invoke `("gcc"
+                                             ,@prism-es2-cc-flags
+                                             "-I" ,glass-native-src
+                                             "-I" ,prism-es2-gen-headers
+                                             "-I" ,prism-es2-native-src
+                                             "-I" ,(string-append prism-es2-native-src "/GL")
+                                             "-I" ,(string-append prism-es2-native-src "/x11")
+                                             "-o" ,(string-append prism-es2-native-obj "/"
+                                                                  (basename c ".c") ".obj")
+                                             ,c)))
+                           (find-files prism-es2-native-src filter-src))
+                 (mkdir-p (dirname prism-es2-native-lib))
+                 (invoke "bash" "-c"
+                         (string-join `("g++"
+                                        ,@prism-es2-link-flags
+                                        "-o" ,prism-es2-native-lib
+                                        ,@(find-files prism-es2-native-obj "\\.obj$"))))
+                 #t)))
+
+           (add-after 'compile-linux-prism-es2 'compile-linux-prism-sw
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((classes "build/classes/java/main")
+                      (prism-sw-gen-headers "build/generated-src/headers/prismSW/linux")
+                      (prism-sw-native-lib "build/libs/prism/linux/libprism_sw.so")
+                      (prism-sw-native-obj "build/native/prismSW/linux")
+                      (prism-sw-native-src "src/main/native-prism-sw")
+                      ;;
+                      (prism-sw-cc-flags `(,@cc-flags "-DINLINE=inline"))
+                      (prism-sw-link-flags link-flags))
+                 (mkdir-p prism-sw-gen-headers)
+                 (apply invoke `("javah"
+                                 "-d" ,prism-sw-gen-headers
+                                 "-cp" ,(string-append classes ":" (getenv "CLASSPATH"))
+                                 ,@javac/h-flags
+                                 ,@(filter (cut string-prefix? "com.sun.pisces" <>)
+                                           (java-list-classes classes))))
+                 (mkdir-p prism-sw-native-obj)
+                 (for-each (lambda (c)
+                             (invoke "bash" "-c"
+                                     (string-join `("gcc"
+                                                    ,@prism-sw-cc-flags
+                                                    "-I" ,prism-sw-gen-headers
+                                                    "-I" ,prism-sw-native-src
+                                                    "-o" ,(string-append prism-sw-native-obj "/"
+                                                                         (basename c ".c") ".obj")
+                                                    ,c))))
+                           (find-files prism-sw-native-src "\\.c$"))
+                 (mkdir-p (dirname prism-sw-native-lib))
+                 (apply invoke `("g++"
+                                 ,@prism-sw-link-flags
+                                 "-o" ,prism-sw-native-lib
+                                 ,@(find-files prism-sw-native-obj "\\.obj$")))
+                 #t)))
+
+           (add-before 'check 'chdir-to-root
+             (lambda _
+               (chdir (dirname (dirname (getcwd))))
+               #t))
+
+           (add-after 'chdir-to-root 'install-native
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
+                 (for-each (lambda (file)
+                             (install-file file lib))
+                           (find-files "." "\\.so$"))
+                 #t)))
+
+           (add-after 'install-native 'build-jar
+             (lambda _
+               (let* ((module (string-append (getcwd) "/modules/graphics"))
+                      (resources (string-append module "/src/main/resources"))
+                      (classes (string-append module "/build/classes/java/main")))
+                 (copy-recursively resources classes)
+
+                 (invoke "ant" "jar" (string-append "-Dclasses.dir=" classes)))
+               #t))))))
+    (native-inputs
+     `(("freetype" ,freetype)
+       ("fontconfig" ,fontconfig)
+       ("gcc" ,gcc)
+       ("glib" ,glib)
+       ("zlib" ,zlib)
+       ("gtk" ,gtk+-2)
+       ("gtk3" ,gtk+)
+       ("jpeg" ,libjpeg)
+       ("libxtst" ,libxtst)
+       ("pango" ,pango)
+       ("libpng" ,libpng)
+       ("pkg-config" ,pkg-config)))
     (propagated-inputs
      `(("java-openjfx-base" ,java-openjfx-base)
-       ("java-swt" ,java-swt)))
-    (description "OpenJFX is a client application platform for desktop,
-mobile and embedded systems built on Java.  Its goal is to produce a
-modern, efficient, and fully featured toolkit for developing rich client
-applications.  This package contains graphics-related classes for the
-OpenJFX distribution.")))
+       ("java-swt" ,java-swt)))))
 
 (define-public java-openjfx-media
   (package (inherit java-openjfx-build)