[oe] [PATCH 1/2] Add support for building Java recipes using java-native
Kyle Russell
bkylerussell at gmail.com
Tue Feb 5 15:53:24 UTC 2019
Repurpose the old java-native class to setup a native JDK for building
Java code in other layers' recipes. This provides a modern JDK, like
openjdk-8-native, for building Java recipes where some of the bootstrap
VMs are not sufficient.
Since there don't appear to be any usages of NATIVE_INSTALL_WORKS,
java-native.bbclass appears to only provide an 'inherit native', which
would be more straightforward to declare in the individual recipes.
Analogous to pythonnative and perlnative classes provided by oe-core.
Signed-off-by: Kyle Russell <bkylerussell at gmail.com>
---
README | 7 +++++++
classes/java-native.bbclass | 17 ++++++++++-------
.../ant-contrib/ant-contrib-native_1.0b3.bb | 2 +-
recipes-core/ant/ant-native_1.8.1.bb | 2 +-
recipes-core/openjdk/openjdk-8-native.inc | 2 ++
5 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/README b/README
index 031709e..96132e8 100644
--- a/README
+++ b/README
@@ -126,3 +126,10 @@ Please note that libstdc++ static is needed on your host to compile icedtea7-nat
(install libstdc++-static on a Fedora).
For debian-based distributions you need the libstdc++6-$compilerversion-dev package.
+
+To build a native JDK for using java tools like javac to build your own recipes,
+define the following variable in a distro include or local.conf and inherit java-native
+from your recipe.
+
+# Possible provider: openjdk-8-native
+PREFERRED_PROVIDER_virtual/jdk-native = "openjdk-8-native"
diff --git a/classes/java-native.bbclass b/classes/java-native.bbclass
index cade7b1..58d7266 100644
--- a/classes/java-native.bbclass
+++ b/classes/java-native.bbclass
@@ -1,9 +1,12 @@
-# This is to be used by recipes which rely on java-library.bbclass
-# infrastructure and are a *-native recipe which needs to install
-# jar files into staging.
-#
-# This class has nothing to do with Java's JNI.
+# Configures EXTRANATIVEPATH for recipes that need a modern,
+# native JDK to use java tools.
-inherit native
+inherit java
-NATIVE_INSTALL_WORKS = "1"
+JAVA_BUILD_VERSION ?= "${PREFERRED_PROVIDER_virtual/jdk-native}"
+
+export JAVA_HOME="${STAGING_LIBDIR_JVM_NATIVE}/${JAVA_BUILD_VERSION}"
+export CLASSPATH += "${STAGING_LIBDIR_JVM_NATIVE}/${JAVA_BUILD_VERSION}/lib/tools.jar"
+EXTRANATIVEPATH += "../${baselib}/jvm/${JAVA_BUILD_VERSION}/bin"
+
+DEPENDS += "virtual/jdk-native"
diff --git a/recipes-core/ant-contrib/ant-contrib-native_1.0b3.bb b/recipes-core/ant-contrib/ant-contrib-native_1.0b3.bb
index 2a44ea2..db79626 100644
--- a/recipes-core/ant-contrib/ant-contrib-native_1.0b3.bb
+++ b/recipes-core/ant-contrib/ant-contrib-native_1.0b3.bb
@@ -12,7 +12,7 @@ DEPENDS = "ant-native commons-cli-native commons-codec-native \
oro-native bcel-native xerces-j-native \
"
-inherit java-library java-native
+inherit java-library native
SRC_URI = "${SOURCEFORGE_MIRROR}/ant-contrib/ant-contrib-${PV}-src.zip"
diff --git a/recipes-core/ant/ant-native_1.8.1.bb b/recipes-core/ant/ant-native_1.8.1.bb
index 5a39f42..7839abd 100644
--- a/recipes-core/ant/ant-native_1.8.1.bb
+++ b/recipes-core/ant/ant-native_1.8.1.bb
@@ -11,7 +11,7 @@ SRC_URI = "http://archive.apache.org/dist/ant/source/apache-ant-${PV}-src.tar.gz
S = "${WORKDIR}/apache-ant-${PV}"
-inherit java-library java-native
+inherit java-library native
DEPENDS = " \
jsch-native bsf-native xalan-j-native xerces-j-native \
diff --git a/recipes-core/openjdk/openjdk-8-native.inc b/recipes-core/openjdk/openjdk-8-native.inc
index bae5d09..3909096 100644
--- a/recipes-core/openjdk/openjdk-8-native.inc
+++ b/recipes-core/openjdk/openjdk-8-native.inc
@@ -7,6 +7,8 @@ DEPENDS = "\
ca-certificates-native openssl-native coreutils-native \
"
+PROVIDES += "virtual/jdk-native"
+
PACKAGECONFIG ??= "gif jpeg png zlib"
PACKAGECONFIG[x11] = "--with-x,,libx11-native xorgproto-native libxt-native libxext-native libxrender-native"
PACKAGECONFIG[cups] = "--with-cups,,cups"
--
2.20.1
More information about the Openembedded-devel
mailing list