[oe] [meta-java][PATCH 1/2] classes:java: move version_specific_cflags to java.bbclass

Andreas Obergschwandtner andreas.obergschwandtner at skidata.com
Thu Aug 2 14:45:22 UTC 2018


moved version_specific_cflags from openjfdk-8-common.inc to java.bbclass and
renamed it to java_version_specific_cflags because it will be used for a fix
in icedtea7

Signed-off-by: Andreas Obergschwandtner <andreas.obergschwandtner at skidata.com>
---
 classes/java.bbclass                      | 29 +++++++++++++++++++++
 recipes-core/openjdk/openjdk-8-common.inc | 31 ++---------------------
 2 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/classes/java.bbclass b/classes/java.bbclass
index aa012ab..906bf8e 100644
--- a/classes/java.bbclass
+++ b/classes/java.bbclass
@@ -28,6 +28,35 @@ STAGING_LIBDIR_JVM_NATIVE ?= "${STAGING_LIBDIR_NATIVE}/jvm"
 EXTRA_OEMAKE_remove_task-compile = "${PARALLEL_MAKE}"
 EXTRA_OEMAKE_remove_task-install = "${PARALLEL_MAKEINST}"
 
+# Determine the version specific compiler flags depending on the used
+# host gcc version
+def java_version_specific_cflags(d):
+    import re
+
+    extraflags = None
+    version = None
+
+    if bb.data.inherits_class('native', d):
+        from subprocess import Popen, PIPE
+
+        cmd = d.expand('${CC} -dumpversion').split()
+        cc = Popen(cmd, stdout=PIPE, stderr=PIPE)
+        version = cc.communicate()[0].decode('utf-8')[0]
+    else:
+        # in the cross case, trust that GCCVERSION is correct. This won't
+        # work if the native toolchain is Clang, but as of this writing that
+        # doesn't work anyway.
+        version = d.getVar('GCCVERSION', expand=True)[0]
+        # skip non digit characters at the beginning, e.g. from "linaro-6.2%"
+        match = re.search("\d", version)
+        if match:
+            version = version[match.start():]
+
+    if version.isdigit():
+        extraflags = d.getVar('FLAGS_GCC%d' % int(version), True) or ''
+        return extraflags
+    return ''
+
 # OpenJDK supports parallel compilation but uses a plain number for this.
 # In OE we have PARALLEL_MAKE which is the actual option passed to make,
 # e.g. "-j 4".
diff --git a/recipes-core/openjdk/openjdk-8-common.inc b/recipes-core/openjdk/openjdk-8-common.inc
index 0af320d..5fae03a 100644
--- a/recipes-core/openjdk/openjdk-8-common.inc
+++ b/recipes-core/openjdk/openjdk-8-common.inc
@@ -224,33 +224,6 @@ FLAGS_GCC7 = "-fno-lifetime-dse -fno-delete-null-pointer-checks"
 # version is and only add the flags that are appropriate for that GCC
 # version.
 
-def version_specific_cflags(d):
-    import re
-
-    extraflags = None
-    version = None
-
-    if bb.data.inherits_class('native', d):
-        from subprocess import Popen, PIPE
-
-        cmd = d.expand('${CC} -dumpversion').split()
-        cc = Popen(cmd, stdout=PIPE, stderr=PIPE)
-        version = cc.communicate()[0].decode('utf-8')[0]
-    else:
-        # in the cross case, trust that GCCVERSION is correct. This won't
-        # work if the native toolchain is Clang, but as of this writing that
-        # doesn't work anyway.
-        version = d.getVar('GCCVERSION', expand=True)[0]
-        # skip non digit characters at the beginning, e.g. from "linaro-6.2%"
-        match = re.search("\d", version)
-        if match:
-            version = version[match.start():]
-
-    if version.isdigit():
-        extraflags = d.getVar('FLAGS_GCC%d' % int(version), True) or ''
-        return extraflags
-    return ''
-
-CFLAGS_append = " ${@version_specific_cflags(d)}"
-CXXFLAGS_append = " ${@version_specific_cflags(d)}"
+CFLAGS_append = " ${@java_version_specific_cflags(d)}"
+CXXFLAGS_append = " ${@java_version_specific_cflags(d)}"
 CXX_append = " -std=gnu++98"
-- 
2.17.1




More information about the Openembedded-devel mailing list