[bug#39747,3/7] gnu: java-openjfx-graphics: Implement a complete compilation.
diff mbox series

Message ID 20200222201755.50425-3-levenson@mmer.org
State Accepted
Headers show
Series
  • [bug#39742,1/7] gnu: java-openjfx-build: Add helpful patch.
Related show

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 Feb. 22, 2020, 8:17 p.m. UTC
---
 gnu/packages/java.scm | 639 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 625 insertions(+), 14 deletions(-)

Comments

Leo Famulari March 4, 2020, 3 a.m. UTC | #1
On Sat, Feb 22, 2020 at 09:17:51PM +0100, Alexey Abramov wrote:
> +           (name "java-openjfx-graphics")
> +           (arguments
> +            `(#:jar-name "java-openjfx-graphics.jar"
> +              #:source-dir "modules/graphics/src/main/java"
> +              #: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))

[...]

Wow, this might be one of the longest package definitions in Guix :)

I can't review it in detail but if it's working for you, okay. Just make
sure to run `./pre-inst-env guix lint java-openjfx-graphics` and fix any
cosmetic issues.

Maybe some of the Guix Java experts can give it a closer review...
Alexey Abramov March 9, 2020, 1:08 p.m. UTC | #2
I have updated the patch. 

Leo Famulari <leo@famulari.name> writes:

> On Sat, Feb 22, 2020 at 09:17:51PM +0100, Alexey Abramov wrote:
>> +           (name "java-openjfx-graphics")
>> +           (arguments
>> +            `(#:jar-name "java-openjfx-graphics.jar"
>
>> +              #:source-dir "modules/graphics/src/main/java"
>> +              #: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))
>
> [...]
>
> Wow, this might be one of the longest package definitions in Guix :)

Yeah, OpenJDK has two build instruction procedures for u8 and u9. I was
thinking about some helpers to reduce the amount of code but wasn't sure
if it's going to work/help for u9. My goal was to package davmail, so I
started packaging what I had been using to run it.

> I can't review it in detail but if it's working for you, okay. Just make
> sure to run `./pre-inst-env guix lint java-openjfx-graphics` and fix any
> cosmetic issues.

In my case it complains about:

1. Patch file name, which is added to the java-openjfx-build package. I
can rename it, but I am guessing it will start complaining on
java-openjfx-build. Bug? Or am I doing something wrong?

2. java-openjfx-build is not under Software Heritage, hence the
message.

3. Lines are too long, All lines are shorter than 120 for
sure. I would prefer to keep them as it is. It is easier to read. 

> Maybe some of the Guix Java experts can give it a closer review...

That would be great, cause I did build a lot of native libraries, but
not all of them. fontT2k for example which is a fallback library for
some fonts engines.

Patch
diff mbox series

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 6f75194256..4e975a0490 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -53,6 +53,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)
@@ -2419,20 +2420,630 @@  distribution.")))
 
 (define-public java-openjfx-graphics
   (package (inherit java-openjfx-build)
-    (name "java-openjfx-graphics")
-    (arguments
-     `(#:jar-name "java-openjfx-graphics.jar"
-       #:source-dir "modules/graphics/src/main/java"
-       #:tests? #f; require X
-       #:test-dir "modules/graphics/src/test"))
-    (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.")))
+           (name "java-openjfx-graphics")
+           (arguments
+            `(#:jar-name "java-openjfx-graphics.jar"
+              #:source-dir "modules/graphics/src/main/java"
+              #: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-generated-src "build/generated-src/jsl-prism"))
+                        (mkdir-p prism-generated-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-generated-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-generated-src "build/generated-src/jsl-prism")
+                             (prism-generated-shaders-src (string-append prism-generated-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-generated-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-generated-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-generated-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-generated-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-generated-src "build/generated-src/jsl-decora"))
+                        (mkdir-p decora-classes)
+                        (apply invoke `("javac"
+                                        "-d" ,decora-classes
+                                        "-cp" ,classes
+                                        ,@javac/h-flags
+                                        ,@(find-files decora-generated-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-generated-headers "build/generated-src/headers/jsl-decora")
+                             (decora-generated-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-generated-headers)
+                        (apply invoke `("javah"
+                                        "-d" ,decora-generated-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-generated-headers
+                                                    "-I" ,decora-generated-src
+                                                    "-I" ,decora-native-src
+                                                    "-o" ,(string-append decora-native-obj  "/"
+                                                                         (basename cc ".cc") ".obj")
+                                                    ,cc)))
+                                  (append (find-files decora-generated-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-generated-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-generated-headers)
+                        (apply invoke `("javah"
+                                        "-d" ,font-generated-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-generated-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-generated-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-generated-headers)
+                        (apply invoke `("javah"
+                                        "-d" ,font-freetype-generated-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-generated-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-generated-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-generated-headers)
+                        (apply invoke `("javah"
+                                        "-d" ,font-pango-generated-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-generated-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-generated-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-generated-headers)
+                        (apply invoke `("javah"
+                                        "-d" ,glass-generated-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-generated-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-generated-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-generated-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-generated-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-generated-headers)
+                        (apply invoke `("javah"
+                                        "-d" ,iio-generated-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-generated-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-generated-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-generated-headers)
+                        (apply invoke `("javah"
+                                        "-d" ,prism-generated-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-generated-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-generated-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)")))
+                        (mkdir-p prism-es2-generated-headers)
+                        (apply invoke `("javah"
+                                        "-d" ,prism-es2-generated-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-generated-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
+                                              (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 (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-generated-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-generated-headers)
+                        (apply invoke `("javah"
+                                        "-d" ,prism-sw-generated-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-generated-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") "/share/amd64")))
+                        (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)))))
 
 (define-public java-openjfx-media
   (package (inherit java-openjfx-build)