public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Michael Zucchi <notzed@gmail.com>
To: Per Bothner <per@bothner.com>, kawa@sourceware.org
Subject: Re: building for jdk / openfx 13 (patch)
Date: Tue, 17 Dec 2019 03:51:00 -0000	[thread overview]
Message-ID: <8d47a991-a45d-8028-dfac-cd08d634a5ec@gmail.com> (raw)
In-Reply-To: <af442ce5-5db0-37c6-8256-078a0293ea6c@bothner.com>

On 17/12/19 11:50 am, Per Bothner wrote:
> On 12/16/19 3:43 PM, Michael Zucchi wrote:
>
>> I wanted to have a look at kawa including the javafx parts but I 
>> didn't want to install the oracle jdk as i've moved everything i do 
>> to openjdk.  So I've created a small patch that allows compilation 
>> with openjdk13 and openjfx13 (although it should work with 11+). It 
>> is enabled by adding --with-javafx-sdk=path to configure:
>
> We already have a --with-javafx, with optional argument: 
> --with-javafx=ARG.
> The ARG is used to set WITH_JAVAFX_ARG, which was intended to be used
> to specify the path the JavaFX, but doesn't seem to be used.
> So probably we should use WITH_JAVAFX_ARG instead of WITH_JAVAFX_SDK_ARG.
>
> The configure script might need to check that the ARG specified for
> --with-javafx is for java 9 or later - i.e. modularized.
Right, no wonder i couldn't find where WITH_JAVAFX_ARG was used.  The 
documentation says it's only needed for javafx on JDK7 but presumably 
that no longer works and isn't worth worrying about any more.

jdk9/10 still include javafx so no path should/need be specified for 
--with-javafx.  For openjdk11+ it is necessary but could also be via 
CLASSPATH (I think).

Below is what i came up with.  If --with-javafx != no|yes it assumes 
it's a path to an sdk.  I removed the jdk7 mention from the docs since 
that shouldn't have worked anyway.  I tested with openjdk13+openjfx13, 
jdk8 and jdk9.

I had to add a WITH_JAVAFX_MODULE conditional so the makefile and script 
can do the right thing.

  Michael


---
  ChangeLog                   |  8 ++++++++
  Make-rules                  |  2 +-
  bin/ChangeLog               |  6 ++++++
  bin/kawa.sh.in              |  7 +++++--
  configure.ac                |  6 +++++-
  doc/ChangeLog               |  5 +++++
  doc/kawa.texi               | 23 ++++++++++++++---------
  gnu/kawa/javafx/ChangeLog   |  5 +++++
  gnu/kawa/javafx/Makefile.am |  4 ++++
  9 files changed, 53 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fb974c2df..0027947ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-12-16  Michael Zucchi  <notzed@gmail.com>
+
+    * Make-rules (KAWA_COMPILER): Add KAWA_COMPILER_JAVA_FLAGS for jvm
+    flags for compiler.
+    * Makefile.am: Enable JAVAFX_SUBDIRS if --with=javafx-sdk used.
+    * configure.ac: Changed --with-javafx=non-empty-path to enable modular
+        java sdk.
+
  2019-08-06  Per Bothner  <per@bothner.com>

      * conigure.ac: Change missing Posix find from error to warning.
diff --git a/Make-rules b/Make-rules
index d08811bed..4793d479f 100644
--- a/Make-rules
+++ b/Make-rules
@@ -15,7 +15,7 @@ java-classes.stamp: $(java_Java)
      echo timestamp > java-classes.stamp
      echo timestamp > $(TO_TOPDIR)/kawa-jar.stamp

-KAWA_COMPILER = $(JAVA) -classpath "$(CLASSPATH)" kawa.repl -d 
$(top_builddir) \
+KAWA_COMPILER = $(JAVA) -classpath "$(CLASSPATH)" 
$(KAWA_COMPILER_JAVA_FLAGS) kawa.repl -d $(top_builddir) \
    -P `echo $(PACKAGE_FNAME)|sed -e s/-/./g`.

  scm-classes.stamp: $(java_SCM)
diff --git a/bin/ChangeLog b/bin/ChangeLog
index 7263f0543..bc6f755d3 100644
--- a/bin/ChangeLog
+++ b/bin/ChangeLog
@@ -1,3 +1,9 @@
+2019-12-16  Michael Zucchi  <notzed@gmail.com>
+
+    * kawa.sh.in (JAVAFX_HOME, JVM_FLAGS): If JAVAFX_HOME is defined
+    or configure was compiled using --with-javafx=path then add javafx
+    modules to module path.
+
  2017-05-03  Per Bothner  <per@bothner.com>

      * kawa.sh.in:  Avoid needless bash-specific 'type' command.
diff --git a/bin/kawa.sh.in b/bin/kawa.sh.in
index 296ce731f..c263e26b6 100644
--- a/bin/kawa.sh.in
+++ b/bin/kawa.sh.in
@@ -34,6 +34,9 @@ else
      JAVA=${JAVA-java}
  fi

+@WITH_JAVAFX_MODULE_TRUE@ JAVAFX_HOME=${JAVAFX_HOME:=@WITH_JAVAFX_ARG@}
+JVM_FLAGS=${JAVAFX_HOME:+"--module-path=${JAVAFX_HOME}/lib" 
--add-modules=javafx.web}
+
  # This ugly duplication is so we only have to use arrays and substrings
  # (which are non-Posix and non-portable) if there is a -D or -J option.
  case "$1" in
@@ -53,9 +56,9 @@ case "$1" in
                  ;;
              esac
          done
-        exec ${JAVA} -Dkawa.command.line="${command_line}" 
-Dkawa.command.pid="$$" -Dkawa.home="${kawadir}" "${jvm_args[@]}" 
kawa.repl ${no_console} "$@"
+        exec ${JAVA} ${JVM_FLAGS} -Dkawa.command.line="${command_line}" 
-Dkawa.command.pid="$$" -Dkawa.home="${kawadir}" "${jvm_args[@]}" 
kawa.repl ${no_console} "$@"
          ;;
      *)
-        exec ${JAVA} -Dkawa.command.line="${command_line}" 
-Dkawa.command.pid="$$" -Dkawa.home="${kawadir}" kawa.repl ${no_console} 
"$@"
+        exec ${JAVA} ${JVM_FLAGS} -Dkawa.command.line="${command_line}" 
-Dkawa.command.pid="$$" -Dkawa.home="${kawadir}" kawa.repl ${no_console} 
"$@"
          ;;
  esac
diff --git a/configure.ac b/configure.ac
index bd1f8cd37..c9ab36517 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ AC_ARG_WITH(android,
    AS_HELP_STRING(--with-android@<:@=android.jar@:>@,Build for the 
Android platform))

  AC_ARG_WITH(javafx,
-  AS_HELP_STRING(--with-javafx@<:@=jfxrt.jar@:>@,Enable support for 
JavaFX))
+ AS_HELP_STRING(--with-javafx@<:@=javafx-sdk-home@:>@,Enable support 
for JavaFX))
  WITH_JAVAFX_ARG="${with_javafx}"

  AC_ARG_WITH(lsp4j,
@@ -196,6 +196,9 @@ AM_CONDITIONAL(WITH_DOMTERM,
    test "$with_domterm" != "" -a "$with_domterm" != "no")
  AM_CONDITIONAL(WITH_JAVAFX,
    test "$with_javafx" != "" -a "$with_javafx" != "no")
+AM_CONDITIONAL(WITH_JAVAFX_MODULE,
+  test "$with_javafx" != "" -a "$with_javafx" != "no" -a "$with_javafx" 
!= "yes")
+
  AM_CONDITIONAL(WITH_SWT, test "$with_swt" = "yes")
  AM_CONDITIONAL(WITH_AWT, test "$with_awt" != "no")
  AM_CONDITIONAL(WITH_SAX2, test "$with_sax2" != "no")
@@ -264,6 +267,7 @@ AC_SUBST(pathsep)
  AC_SUBST(filesep)
  AC_SUBST(WITH_SERVLET_ARG)
  AC_SUBST(WITH_JAVAFX_ARG)
+AC_SUBST(WITH_JAVAFX_MODULE)
  AC_SUBST(WITH_JLINE3)
  AC_SUBST(WITH_GSON_PATH)
  AC_SUBST(WITH_JLINE_PATH)
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 0cc771bfe..6ea8e8a17 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-16  Michael Zucchi  <notzed@gmail.com>
+
+    * kawa.texi (Building JavaFX applications): Removed the subsection 
about
+        JDK7 and added subsection about JDK11+ JavaFX.
+
  2019-01-17  Per Bothner  <per@bothner.com>

      * kawa.texi (Arithmetic operations): Document 'expt'.
diff --git a/doc/kawa.texi b/doc/kawa.texi
index d709b7100..2a300f057 100644
--- a/doc/kawa.texi
+++ b/doc/kawa.texi
@@ -23119,21 +23119,26 @@ and
  The @code{browse-kawa-manual} script in the @code{doc} directory 
(source only)
  uses JavaFX WebView to create a window for browsing the Kawa 
documentation.

-@subsection Using JavaFX with JDK 7
-JDK 8 ships with JavaFX, and it is in the default @code{CLASSPATH}.
-JDK 7 update 9 or later does have JavaFX included, but it is a separate
-@code{jfxrt.jar} which not in the default @code{CLASSPATH}.
-Thus you have to explicitly add @code{jfxrt.jar}.
+@subsection Using JavaFX with JDK 11+
+Starting with JDK 11, JavaFX has been moved to a separate project and
+is no longer included in the JDK.  The separate project OpenJFX
+provides an SDK that includes modular jar files which can be added to
+the @code{CLASSPATH} or via the @code{--module-path} parameter to
+@code{javac} and @code{java}.
+
  To run the previous @code{HelloButton1.scm} you can do:
  @example
-java -cp $JAVA_HOME/lib/jfxrt.jar:$KAWA_HOME/kawa.jar HelloButton1.scm
+$ java -cp $KAVA_HOME/kawa.jar --module-path $JAVAFX_HOME/lib \
+  --add-modules javafx.web HelloButton1.scm
  @end example

-If you build Kawa from source, do:
+If you build Kawa from source you must use an appropriate JDK version
+and enable the modular OpenJFX SDK:
  @example
-$ ./configure --with-javafx=$JAVA_HOME --enable-kawa-frontend 
...other-args...
+$ ./configure --with-javafx-sdk=path-to-sdk ...other-args...
  @end example
-The resulting Kawa binary sets up the path to @code{jfxrt.jar} so you 
just need to do:
+The resulting Kawa binary sets up the module path and the boostrap
+module so you just need to do:
  @example
  $ kawa HelloButton1.scm
  @end example
diff --git a/gnu/kawa/javafx/ChangeLog b/gnu/kawa/javafx/ChangeLog
index 3c8b6d99f..99d2f1f88 100644
--- a/gnu/kawa/javafx/ChangeLog
+++ b/gnu/kawa/javafx/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-16  Michael Zucchi  <notzed@gmail.com>
+
+    * Makefile.am (KAVA_COMPILER_JAVA_FLAGS): Add support for modular
+    javafx sdk.
+
  2017-05-13  Per Bothner  <per@bothner.com>

      * MakeScene.scm (add): Don't set root.
diff --git a/gnu/kawa/javafx/Makefile.am b/gnu/kawa/javafx/Makefile.am
index 5d0325aad..68554aca2 100644
--- a/gnu/kawa/javafx/Makefile.am
+++ b/gnu/kawa/javafx/Makefile.am
@@ -2,6 +2,10 @@

  include $(top_srcdir)/Make-rules

+if WITH_JAVAFX_MODULE
+KAWA_COMPILER_JAVA_FLAGS=--module-path $(WITH_JAVAFX_ARG)/lib 
--add-modules javafx.web
+endif
+
  java_sources=

  java_SCM = GroupObjectBuilder.scm MakeScene.scm defs.scm
-- 
2.24.1


  reply	other threads:[~2019-12-17  3:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16 23:43 Michael Zucchi
2019-12-16 23:49 ` ian
2019-12-17  1:53   ` Per Bothner
2019-12-17  1:20 ` Per Bothner
2019-12-17  3:51   ` Michael Zucchi [this message]
2019-12-17  5:58     ` Per Bothner
2019-12-17  6:31       ` Michael Zucchi
2019-12-19 17:51         ` Per Bothner
2019-12-19 20:05           ` spellcard199
2019-12-19 20:09             ` Per Bothner
2019-12-20  1:43             ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d47a991-a45d-8028-dfac-cd08d634a5ec@gmail.com \
    --to=notzed@gmail.com \
    --cc=kawa@sourceware.org \
    --cc=per@bothner.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).