Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 181734 Details for
Bug 21477
support for gcj as a JDK
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch against portage java-utils-2.eclass to fully support gcj-jdk and native java packages
java-utils-2.eclass.patch (text/plain), 13.95 KB, created by
Steven Newbury
on 2009-02-12 04:05:21 UTC
(
hide
)
Description:
Patch against portage java-utils-2.eclass to fully support gcj-jdk and native java packages
Filename:
MIME Type:
Creator:
Steven Newbury
Created:
2009-02-12 04:05:21 UTC
Size:
13.95 KB
patch
obsolete
>--- /usr/portage/eclass/java-utils-2.eclass 2008-12-29 00:37:46.000000000 +0000 >+++ java-utils-2.eclass 2009-02-12 03:46:50.224853603 +0000 >@@ -23,7 +23,7 @@ > # > # ----------------------------------------------------------------------------- > >-inherit eutils versionator multilib >+inherit check-reqs eutils flag-o-matic multilib versionator > > IUSE="elibc_FreeBSD" > >@@ -175,6 +175,60 @@ > JAVA_PKG_QA_VIOLATIONS=0 > > # ----------------------------------------------------------------------------- >+# @variable-internal JAVA_PKG_NATIVE_CLASSMAP >+# >+# Explicitly set classmap.gcjdb database file >+# This is set by java-pkg_native_init_ once the libgcj ABI is known. >+# Previously, it was externally configurable and defaulted to >+# JAVA_PKG_NATIVE_CLASSMAP="/usr/share/java/classmap.gcjdb" >+# ----------------------------------------------------------------------------- >+JAVA_PKG_NATIVE_CLASSMAP="" >+ >+# ----------------------------------------------------------------------------- >+# @variable-internal JAVA_PKG_NATIVE_CACHE_FLAGS >+# >+# Required flags for native library >+# ----------------------------------------------------------------------------- >+JAVA_PKG_NATIVE_CACHE_FLAGS="-shared -Wl,-Bsymbolic -fPIC -findirect-dispatch -fjni" >+ >+# ----------------------------------------------------------------------------- >+# @variable-internal JAVA_PKG_NATIVE_BIN_FLAGS >+# >+# Required ldflags for native binary >+# ----------------------------------------------------------------------------- >+JAVA_PKG_NATIVE_BIN_FLAGS="-Wl,-Bsymbolic -findirect-dispatch -fjni" >+ >+# ----------------------------------------------------------------------------- >+# @variable-internal JAVA_PKG_NATIVE_INC >+# >+# Set include files (jar) to compile native code >+# This is generated by java-pkg_gen-native-cp >+# ----------------------------------------------------------------------------- >+JAVA_PKG_NATIVE_INC="" >+ >+# ----------------------------------------------------------------------------- >+# @variable-internal JAVA_PKG_NATIVE_LIB >+# >+# Set library files (jar.so) to link native code >+# This is generated by java-pkg_gen-native-cp >+# ----------------------------------------------------------------------------- >+JAVA_PKG_NATIVE_LIB="" >+ >+# ----------------------------------------------------------------------------- >+# @variable-internal JAVA_PKG_NATIVE_SKIP >+# >+# Jar files that match pattern will be skipped. >+# >+# @example >+# java-pkg_skip-cachejar org.eclipse.jdt.core_ org.eclipse.jdt.apt >+# java-pkg_skip-cachejar 2000 org.eclipse.jdt.ui_ >+# >+# param $1 - optional: memory size to check >+# param $@ - pattern of Jar files to skip >+# ----------------------------------------------------------------------------- >+JAVA_PKG_NATIVE_SKIP="" >+ >+# ----------------------------------------------------------------------------- > # @section-end variables > # ----------------------------------------------------------------------------- > >@@ -291,6 +345,7 @@ > done > > java-pkg_do_write_ >+ java-pkg_cachejar_ > } > > # ------------------------------------------------------------------------------ >@@ -1604,7 +1659,7 @@ > else > # for everything else, try to determine from an env file > >- local compiler_env="/usr/share/java-config-2/compiler/${compiler}" >+ local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" > if [[ -f ${compiler_env} ]]; then > local old_javac=${JAVAC} > unset JAVAC >@@ -2569,6 +2624,336 @@ > } > > # ------------------------------------------------------------------------------ >+# @internal-function java-pkg_gcjflags >+# >+# sanitze CFLAGS for GCJ native. >+# ------------------------------------------------------------------------------ >+java-pkg_gcjflags() { >+ strip-flags >+ filter-flags "-ftree-loop-distribution -ftree-vectorize" >+ replace-flags "-O?" "-Os" >+ append-flags -w >+ >+ filter-ldflags -Wl,--as-needed --as-needed >+} >+ >+# ------------------------------------------------------------------------------ >+# @internal-function java-pkg_native_init_ >+# >+# Check for issues, set default classmap db depending upon ABI >+# >+# @return 0 - procede with native build >+# @return 1 - skip native build >+# ------------------------------------------------------------------------------ >+java-pkg_native_init_() { >+ if ! has gcj "${IUSE}" || ! use gcj ; then >+ return 1 >+ fi >+ >+ # The libgcj ABI has a habbit of changing incompatibly between versions, >+ # if the current java-jdk is set to gcj-jdk, compare the ABI version >+ # with the current gcc libgcj ABI version, if it differs use the gcj >+ # from the java-jdk version, otherwise use the most recent installed >+ # gcj >+ local gccversion=$(gcc-config -c) >+ local gccbin=$(gcc-config -B) >+ local tc_libgcj_soversion=$(ls -l $(${gccbin}/gcj -print-file-name=libgcj.so) | sed -r 's:.*\.so\.([0-9]*).*$:\1:') >+ >+ if [[ $(echo "$(java-config -f)" | grep 'gcj-jdk') ]]; then >+ local jdk_libgcj_soversion=$(java-config -O | sed -r 's:.*-([0-9]*)$:\1:') >+ >+ if [[ "${tc_libgcj_soversion}" != "${jdk_libgcj_soversion}" ]]; then >+ local gccversion_=${gccversion} >+ gccversion=${CHOST}-$(java-config -O | sed -r 's:.*gcj-(.*)-[0-9]*$:\1:') >+ gccbin=$(gcc-config -B ${gccversion}) >+ einfo "The selected gcj-jdk uses a different ABI version (${jdk_libgcj_soversion})" >+ einfo "than the currently selected gcc (${gccversion_}; ABI version ${tc_libgcj_soversion})." >+ einfo "" >+ fi >+ else >+ if ! [[ $(echo "$(java-config -L)" | grep 'gcj-jdk') ]]; then >+ ewarn "gcj-jdk must be installed to use gcc/gcj as a JDK"; >+ ewarn "and to compile java packages to native binaries."; >+ return 1 >+ fi >+ for gccversion in $(ls -1r /etc/env.d/gcc/${CHOST}-*); do >+ gccbin=$(gcc-config -B ${gccversion}) >+ if ( [[ -x ${gccbin}/gcj ]] && >+ [[ -x ${gccbin}/gcj-dbtool ]] ); then >+ local jdk_libgcj_soversion=$(ls -l $(${gccbin}/gcj \ >+ -print-file-name=libgcj.so) \ >+ | sed -r 's#.*\.so\.([0-9]*).*$#\1#') >+ break >+ fi >+ done >+ einfo "The Java JDK is not set to gcj-jdk." >+ fi >+ >+ # The ABI for libgcj must match the native binary/library >+ JAVA_PKG_NATIVE_CLASSMAP="/usr/share/java/classmap.gcjdb.${jdk_libgcj_soversion}" >+ >+ gcj="${gccbin}/gcj" >+ gcj_dbtool="${gccbin}/gcj-dbtool" >+ >+ if [[ ( ! -x "$(which ${gcj})" ) || ( ! -x "$(which ${gcj_dbtool})" ) ]] ; then >+ # Do we want to die here? >+ ewarn "java native tools unusable!" >+ return 1 >+ fi >+ >+ einfo "Using ${gccversion} to build native pkg..." >+ >+ java-pkg_gcjflags >+ >+ return 0 >+} >+ >+# ------------------------------------------------------------------------------ >+# @ebuild-function java-pkg_gen-native-cp >+# >+# Set include and library paths for native build. >+# >+# Example: >+# java-pkg_gen-native-cp junit gnu-crypto ... >+# >+# @param $@ - space-separated list of packages >+# ------------------------------------------------------------------------------ >+java-pkg_gen-native-cp() { >+ java-pkg_native_init_ || return 0 >+ >+ local pkg cp item lib >+ for pkg in ${@} ; do >+ cp="$(java-config --classpath=${pkg})" >+ for item in ${cp//:/ } ; do >+ if [[ ( -f "${item}" ) && ( ".jar" == "${item: -4:4}" ) ]] ; then >+ lib="$(dirname ${item})/lib$(basename ${item}).so" >+ [ ! -f "${lib}" ] && die "Native library ${lib} from ${pkg} missing!" >+ JAVA_PKG_NATIVE_INC="${JAVA_PKG_NATIVE_INC} -I${item}" >+ JAVA_PKG_NATIVE_LIB="${JAVA_PKG_NATIVE_LIB} ${lib}" >+ fi >+ done >+ done >+} >+ >+# ------------------------------------------------------------------------------ >+# @ebuild-function java-pkg_donative >+# >+# Compile Java source to native. >+# >+# Example: >+# java-pkg_donative src/java/* ... >+# Where '*' is org or com et cetera >+# >+# @param $@ - path to java source(s) >+# ------------------------------------------------------------------------------ >+java-pkg_donative() { >+ java-pkg_native_init_ || return 0 >+ einfo "Compile Java source to native ..." >+ >+ local buildpath="${S}/build/native" >+ mkdir -p "${buildpath}" >+ >+ local path >+ for path in ${@} ; do >+ cp -a "${path}" "${buildpath}" >+ done >+ >+ pushd "${buildpath}" >/dev/null || die "no native build there!" >+ >+ local file >+ for file in $(find -type f -name '*.java' | cut -c3-) ; do >+ echo ${gcj} -c -g0 ${CFLAGS} -Wno-deprecated \ >+ ${JAVA_PKG_NATIVE_INC} ${file} -o ${file/\.java/.o} >+ ${gcj} -c -g0 ${CFLAGS} -Wno-deprecated \ >+ ${JAVA_PKG_NATIVE_INC} ${file} -o ${file/\.java/.o} \ >+ || die "java native compile failed! (${file})" >+ done >+ >+ # Any other resource formats out there? >+ # .properties, .rsc, .xml >+ >+ for file in $(find -type f \( -name '*.properties' -o -name '*.rsc' -o -name '*.xml' \) | cut -c3-) ; do >+ echo ${gcj} -c -g0 ${CFLAGS} -Wno-deprecated \ >+ --resource ${file} ${file} -o ${file}.o >+ ${gcj} -c -g0 ${CFLAGS} -Wno-deprecated \ >+ --resource ${file} ${file} -o ${file}.o \ >+ || die "java native compile failed! (${file})" >+ done >+ >+ popd >/dev/null >+} >+ >+# ------------------------------------------------------------------------------ >+# @ebuild-function java-pkg_donative-bin >+# >+# Create native binary. >+# >+# Example: >+# java-pkg_donative-bin com.example.my.Main <name of native binary> >+# java-pkg_donative-bin com.example.my.Main <path to jar file> >+# >+# @param $1 - main function to call on execution of the native binary >+# @param $2 - optional: the name of resulting binary >+# path to jar file to turn native >+# ------------------------------------------------------------------------------ >+java-pkg_donative-bin() { >+ java-pkg_native_init_ || return 0 >+ [ -z "${1}" ] && die "set the main function to call for the binary!" >+ >+ if [ ".jar" == "${2: -4:4}" ] ; then >+ pushd "${S}" >/dev/null >+ >+ echo ${gcj} --main=${1} -o ${2/\.jar} ${2} \ >+ ${JAVA_PKG_NATIVE_BIN_FLAGS} ${CFLAGS} ${LDFLAGS} \ >+ ${JAVA_PKG_NATIVE_INC} ${JAVA_PKG_NATIVE_LIB} >+ ${gcj} --main=${1} -o ${2/\.jar} ${2} \ >+ ${JAVA_PKG_NATIVE_BIN_FLAGS} ${CFLAGS} ${LDFLAGS} \ >+ ${JAVA_PKG_NATIVE_INC} ${JAVA_PKG_NATIVE_LIB} \ >+ || die "build of native binary failed! (from jar)" >+ else >+ pushd "${S}/build/native" >/dev/null || die "no native build there!" >+ >+ local file files >+ for file in $(find -type f -name '*.o' | cut -c3-) ; do >+ files="${files} ${file}" >+ done >+ >+ local bin="" >+ if [ -n "${2}" ] ; then >+ bin="${2}" >+ elif [[ ( -n "${SLOT}" ) && ( "${SLOT}" != "0" ) ]] ; then >+ bin="${PN}-native-${SLOT}" >+ else >+ bin="${PN}-native" >+ fi >+ >+ echo ${gcj} ${JAVA_PKG_NATIVE_BIN_FLAGS} \ >+ --main=${1} -o ../${bin} ${LDFLAGS} \ >+ ${JAVA_PKG_NATIVE_LIB} ... >+ ${gcj} ${JAVA_PKG_NATIVE_BIN_FLAGS} \ >+ --main=${1} -o ../${bin} ${LDFLAGS} \ >+ ${JAVA_PKG_NATIVE_LIB} ${files} \ >+ || die "build of native binary failed! (from source)" >+ fi >+ >+ popd >/dev/null >+} >+ >+# ------------------------------------------------------------------------------ >+# @ebuild-function java-pkg_skip-cachejar >+# >+# Skip caching of Jar files that match pattern. >+# >+# Example: >+# java-pkg_skip-cachejar org.eclipse.jdt.core_ org.eclipse.jdt.apt >+# java-pkg_skip-cachejar 2000 org.eclipse.jdt.ui_ >+# >+# param $1 - optional: memory size to check >+# param $@ - pattern of Jar files to skip >+# ------------------------------------------------------------------------------ >+java-pkg_skip-cachejar() { >+ java-pkg_native_init_ || return 0 >+ >+ if [[ ${1} =~ ^[0-9]+$ ]] ; then >+ CHECKREQS_MEMORY="${1}" >+ check_reqs_conditional && return 0 >+ shift >+ fi >+ >+ JAVA_PKG_NATIVE_SKIP="${JAVA_PKG_NATIVE_SKIP} ${@}" >+} >+ >+# ------------------------------------------------------------------------------ >+# @ebuild-function java-pkg_cachejar >+# >+# Create native library from jar. >+# For packages not using java-pkg_dojar. >+# >+# Example: >+# use gcj && java-pkg_cachejar >+# >+# @param $@ - none >+# ------------------------------------------------------------------------------ >+java-pkg_cachejar() { >+ java-pkg_native_init_ || return 0 >+ pushd "${D}" >/dev/null || die "This function is for src_install!" >+ >+ local jars jar >+ for jar in $(find -type f -name '*.jar' | cut -c2-) ; do >+ jars="${jars} ${jar}" >+ done >+ >+ java-pkg_cachejar_ "${jars}" >+ >+ popd >/dev/null >+} >+ >+# ------------------------------------------------------------------------------ >+# @internal-function java-pkg_cachejar_ >+# >+# Create native library from jar >+# ------------------------------------------------------------------------------ >+java-pkg_cachejar_() { >+ java-pkg_native_init_ || return 0 >+ >+ local jars >+ [ ${#} -lt 1 ] \ >+ && jars="${JAVA_PKG_CLASSPATH//:/ }" \ >+ || jars="${@}" >+ >+ local item jar to >+ for jar in ${jars} ; do >+ for item in ${JAVA_PKG_NATIVE_SKIP} ; do >+ if [[ ${jar} =~ ${item} ]] ; then >+ ewarn "skip: ${jar}" >+ jar="no_native_lib" >+ break >+ fi >+ done >+ >+ to="$(dirname ${jar})/lib$(basename ${jar}).so" >+ if [[ ( -f "${D}${jar}" ) && ( ".jar" == "${jar: -4:4}" ) && ( ! -e "${D}${to}" ) ]] ; then >+ echo ${gcj} ${JAVA_PKG_NATIVE_CACHE_FLAGS} \ >+ -g0 ${CFLAGS} -o ${to} ${jar} >+ if ! ${gcj} ${JAVA_PKG_NATIVE_CACHE_FLAGS} \ >+ -g0 ${CFLAGS} -o ${D}${to} ${D}${jar} ; then >+ ewarn "${to} build failed -> skipping" >+ fi >+ fi >+ done >+} >+ >+# ------------------------------------------------------------------------------ >+# @internal-function java-pkg_reg-cachejar_ >+# >+# Register native library >+# ------------------------------------------------------------------------------ >+java-pkg_reg-cachejar_() { >+ java-pkg_native_init_ || return 0 >+ [ -z "${JAVA_PKG_CLASSPATH}" ] && return 0 >+ >+ # Create new database? >+ if [ ! -e "${JAVA_PKG_NATIVE_CLASSMAP}" ] ; then >+ einfo "Create new database ..." >+ [ -d "$(dirname ${JAVA_PKG_NATIVE_CLASSMAP})" ] \ >+ || mkdir -p "$(dirname ${JAVA_PKG_NATIVE_CLASSMAP})" >+ ${gcj_dbtool} -n ${JAVA_PKG_NATIVE_CLASSMAP} >+ fi >+ >+ einfo "Register native library in database (${JAVA_PKG_NATIVE_CLASSMAP}) ..." >+ >+ local jar to >+ for jar in ${JAVA_PKG_CLASSPATH//:/ } ; do >+ to="$(dirname ${jar})/lib$(basename ${jar}).so" >+ if [[ ( -f "${jar}" ) && ( ".jar" == "${jar: -4:4}" ) && ( -f "${to}" ) ]] ; then >+ einfo "library: ${to}" >+ ${gcj_dbtool} -a ${JAVA_PKG_NATIVE_CLASSMAP} ${jar} ${to} \ >+ || die "failed to register jar file" >+ fi >+ done >+} >+ >+# ------------------------------------------------------------------------------ > # @internal-function java-pkg_die > # > # Enhanced die for Java packages, which displays some information that may be
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 21477
:
181443
|
181445
|
181446
|
181448
|
181454
|
181460
|
181462
|
181724
|
181730
|
181732
|
181733
|
181734
|
181736
|
181737
|
181770
|
181782
|
181783
|
181784
|
181786
|
181788
|
181792
|
181801
|
181802
|
181826