/[gentoo-x86]/eclass/java-utils-2.eclass
Gentoo

Diff of /eclass/java-utils-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.28 Revision 1.38
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2005, Gentoo Foundation 5# Copyright (c) 2004-2005, Gentoo Foundation
6# 6#
7# Licensed under the GNU General Public License, v2 7# Licensed under the GNU General Public License, v2
8# 8#
9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.38 2006/12/31 19:30:54 betelgeuse Exp $
9 10
10 11
11# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
12# @eclass-begin 13# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 14# @eclass-shortdesc Java Utility eclass
22# Java packages, or java-pkg-opt for packages that have optional Java support. 23# Java packages, or java-pkg-opt for packages that have optional Java support.
23# 24#
24# ----------------------------------------------------------------------------- 25# -----------------------------------------------------------------------------
25 26
26inherit eutils versionator multilib 27inherit eutils versionator multilib
28
29IUSE="elibc_FreeBSD"
27 30
28# ----------------------------------------------------------------------------- 31# -----------------------------------------------------------------------------
29# @section-begin variables 32# @section-begin variables
30# @section-title Variables 33# @section-title Variables
31# 34#
200 203
201 java-pkg_do_write_ 204 java-pkg_do_write_
202} 205}
203 206
204 207
208# ------------------------------------------------------------------------------
209# @internal-function depend-java-query
210#
211# Wrapper for the depend-java-query binary to enable passing USE in env.
212# Using env variables keeps this eclass working with java-config versions that
213# do not handle use flags.
214# ------------------------------------------------------------------------------
215
216depend-java-query() {
217 USE="${USE}" $(which depend-java-query) "${@}"
218}
205 219
206# ------------------------------------------------------------------------------ 220# ------------------------------------------------------------------------------
207# @ebuild-function java-pkg_regjar 221# @ebuild-function java-pkg_regjar
208# 222#
209# Records an already installed jar in the package.env 223# Records an already installed jar in the package.env
242 java-pkg_init_paths_ 256 java-pkg_init_paths_
243 257
244 local jar jar_dir jar_file 258 local jar jar_dir jar_file
245 for jar in "$@"; do 259 for jar in "$@"; do
246 # TODO use java-pkg_check-versioned-jar 260 # TODO use java-pkg_check-versioned-jar
247 if [[ -e "${jar}" ]]; then 261 if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
262 [[ -d "${jar}" || -d "${D}${jar}" ]] \
263 && die "Called ${FUNCNAME} on a directory $*"
248 # nelchael: we should strip ${D} in this case too, here's why: 264 # nelchael: we should strip ${D} in this case too, here's why:
249 # imagine such call: 265 # imagine such call:
250 # java-pkg_regjar ${D}/opt/java/*.jar 266 # java-pkg_regjar ${D}/opt/java/*.jar
251 # such call will fall into this case (-e ${jar}) and will 267 # such call will fall into this case (-e ${jar}) and will
252 # record paths with ${D} in package.env 268 # record paths with ${D} in package.env
253 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}" 269 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
254 elif [[ -e "${D}${jar}" ]]; then
255 java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}"
256 else 270 else
257 die "${jar} does not exist" 271 die "${jar} does not exist"
258 fi 272 fi
259 done 273 done
260 274
261 java-pkg_do_write_ 275 java-pkg_do_write_
262} 276}
263
264 277
265# ------------------------------------------------------------------------------ 278# ------------------------------------------------------------------------------
266# @ebuild-function java-pkg_newjar 279# @ebuild-function java-pkg_newjar
267# 280#
268# Installs a jar with a new name 281# Installs a jar with a new name
287 cp "${original_jar}" "${new_jar_dest}" \ 300 cp "${original_jar}" "${new_jar_dest}" \
288 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 301 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
289 java-pkg_dojar "${new_jar_dest}" 302 java-pkg_dojar "${new_jar_dest}"
290} 303}
291 304
292
293# ------------------------------------------------------------------------------ 305# ------------------------------------------------------------------------------
294# @ebuild-function java-pkg_addcp 306# @ebuild-function java-pkg_addcp
295# 307#
296# Add something to the package's classpath. For jars, you should use dojar, 308# Add something to the package's classpath. For jars, you should use dojar,
297# newjar, or regjar. This is typically used to add directories to the classpath. 309# newjar, or regjar. This is typically used to add directories to the classpath.
301# ------------------------------------------------------------------------------ 313# ------------------------------------------------------------------------------
302java-pkg_addcp() { 314java-pkg_addcp() {
303 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 315 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
304 java-pkg_do_write_ 316 java-pkg_do_write_
305} 317}
306
307 318
308# ------------------------------------------------------------------------------ 319# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 320# @ebuild-function java-pkg_doso
310# 321#
311# Installs any number of JNI libraries 322# Installs any number of JNI libraries
429java-pkg_dohtml() { 440java-pkg_dohtml() {
430 debug-print-function ${FUNCNAME} $* 441 debug-print-function ${FUNCNAME} $*
431 442
432 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 443 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
433 444
434 # TODO-nichoj find out what exactly -f package-list does 445 # from /usr/lib/portage/bin/dohtml -h
446 # -f Set list of allowed extensionless file names.
435 dohtml -f package-list "$@" 447 dohtml -f package-list "$@"
448
436 # this probably shouldn't be here but it provides 449 # this probably shouldn't be here but it provides
437 # a reasonable way to catch # docs for all of the 450 # a reasonable way to catch # docs for all of the
438 # old ebuilds. 451 # old ebuilds.
439 java-pkg_recordjavadoc 452 java-pkg_recordjavadoc
440} 453}
441 454
442# TODO document 455# ------------------------------------------------------------------------------
456# @ebuild-function java-pkg_dojavadoc
457#
458# Installs javadoc documentation. This should be controlled by the doc use flag.
459#
460# @param $1: - The javadoc root directory.
461#
462# @example:
463# java-pkg_dojavadoc docs/api
464#
465# ------------------------------------------------------------------------------
443java-pkg_dojavadoc() { 466java-pkg_dojavadoc() {
444 local dir="$1" 467 local dir="$1"
445 468
446 java-pkg_check-phase install 469 java-pkg_check-phase install
447 470
552 local var_tmp="${T}/launcher_variables_tmp" 575 local var_tmp="${T}/launcher_variables_tmp"
553 local target_dir pre 576 local target_dir pre
554 577
555 # Process the other the rest of the arguments 578 # Process the other the rest of the arguments
556 while [[ -n "${1}" && -n "${2}" ]]; do 579 while [[ -n "${1}" && -n "${2}" ]]; do
557 local var=${1} value=${2} 580 local var="${1}" value="${2}"
558 if [[ "${var:0:2}" == "--" ]]; then 581 if [[ "${var:0:2}" == "--" ]]; then
559 local var=${var:2} 582 local var=${var:2}
560 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}" 583 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
561 local gjl_${var}="${value}" 584 local gjl_${var}="${value}"
562 elif [[ "${var}" == "-into" ]]; then 585 elif [[ "${var}" == "-into" ]]; then
763# The providing packages are recorded as dependencies into package.env DEPEND 786# The providing packages are recorded as dependencies into package.env DEPEND
764# line, unless "--build-only" is passed as the very first argument, for jars 787# line, unless "--build-only" is passed as the very first argument, for jars
765# that have to be present only at build time and are not needed on runtime 788# that have to be present only at build time and are not needed on runtime
766# (junit testing etc). 789# (junit testing etc).
767# 790#
768# Example: Get the classpath for xerces-2, 791# Example: Get the classpath for xerces-2 and xalan,
769# java-pkg_getjars xerces-2 xalan 792# java-pkg_getjars xerces-2,xalan
770# Example Return: 793# Example Return:
771# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 794# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
772# 795#
773# @param $1 - (optional) "--build-only" makes the jar(s) not added into 796# @param $1 - (optional) "--build-only" makes the jar(s) not added into
774# package.env DEPEND line. 797# package.env DEPEND line.
775# @param $@ - list of packages to get jars from 798# @param $2 - list of packages to get jars from
799# (passed to java-config --classpath)
776# ------------------------------------------------------------------------------ 800# ------------------------------------------------------------------------------
777java-pkg_getjars() { 801java-pkg_getjars() {
778 debug-print-function ${FUNCNAME} $* 802 debug-print-function ${FUNCNAME} $*
779 803
780 local build_only=""
781
782 if [[ "${1}" = "--build-only" ]]; then 804 if [[ "${1}" = "--build-only" ]]; then
783 build_only="true" 805 local build_only="true"
784 shift 806 shift
785 fi 807 fi
786 808
787 [[ ${#} -lt 1 ]] && die "At least one argument needed" 809 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --build-only"
788 810
789 # NOTE could probably just pass $@ to java-config --classpath. and return it
790 local classpath pkg 811 local classpath pkgs="${1}"
791 for pkg in ${@//,/ }; do
792 #for pkg in $(echo "$@" | tr ',' ' '); do
793 jars="$(java-config --classpath=${pkg})" 812 jars="$(java-config --classpath=${pkgs})"
794 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed" 813 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
795 debug-print "${pkg}:${jars}" 814 debug-print "${pkgs}:${jars}"
796 815
797 if [[ -z "${classpath}" ]]; then 816 if [[ -z "${classpath}" ]]; then
798 classpath="${jars}" 817 classpath="${jars}"
799 else 818 else
800 classpath="${classpath}:${jars}" 819 classpath="${classpath}:${jars}"
801 fi 820 fi
821
802 # Only record jars that aren't build-only 822 # Only record jars that aren't build-only
803 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 823 if [[ -z "${build_only}" ]]; then
824 oldifs="${IFS}"
825 IFS=","
826 for pkg in ${pkgs}; do
827 java-pkg_record-jar_ "${pkg}"
804 done 828 done
829 IFS="${oldifs}"
830 fi
831
805 echo "${classpath}" 832 echo "${classpath}"
806} 833}
807 834
808# ------------------------------------------------------------------------------ 835# ------------------------------------------------------------------------------
809# @ebuild-function java-pkg_getjar 836# @ebuild-function java-pkg_getjar
1157# @ebuild-function java-pkg_get-target 1184# @ebuild-function java-pkg_get-target
1158# 1185#
1159# Determines what target version should be used, for passing to -target. 1186# Determines what target version should be used, for passing to -target.
1160# If you don't care about lower versions, you can set _WANT_TARGET to the 1187# If you don't care about lower versions, you can set _WANT_TARGET to the
1161# version of your JDK. 1188# version of your JDK.
1162# Remember doing this will mostly like cause things to break.
1163# Doesn't allow it to be lower then the one in depend.
1164# Doesn't allow it to be higher then the active vm.
1165# 1189#
1166# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1190# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1167# ------------------------------------------------------------------------------ 1191# ------------------------------------------------------------------------------
1168java-pkg_get-target() { 1192java-pkg_get-target() {
1169 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1170 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1171 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1172 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1173 echo ${JAVA_PKG_WANT_TARGET}
1174 else
1175 echo ${min}
1176 fi
1177 else
1178 echo ${min}
1179 fi
1180
1181 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1193 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1182} 1194}
1183 1195
1184java-pkg_get-javac() { 1196java-pkg_get-javac() {
1185 debug-print-function ${FUNCNAME} $* 1197 debug-print-function ${FUNCNAME} $*
1186 1198
1255 1267
1256# TODO document 1268# TODO document
1257java-pkg_get-jni-cflags() { 1269java-pkg_get-jni-cflags() {
1258 local flags="-I${JAVA_HOME}/include" 1270 local flags="-I${JAVA_HOME}/include"
1259 1271
1272 local platform="linux"
1273 use elibc_FreeBSD && platform="freebsd"
1274
1260 # TODO do a check that the directories are valid 1275 # TODO do a check that the directories are valid
1261 # TODO figure out how to cope with other things than linux...
1262 flags="${flags} -I${JAVA_HOME}/include/linux" 1276 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1263 1277
1264 echo ${flags} 1278 echo ${flags}
1265} 1279}
1266 1280
1267java-pkg_ensure-gcj() { 1281java-pkg_ensure-gcj() {
1273 die "No GCJ support found!" 1287 die "No GCJ support found!"
1274 fi 1288 fi
1275} 1289}
1276 1290
1277java-pkg_ensure-test() { 1291java-pkg_ensure-test() {
1278 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} && ! use test; then 1292 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \
1293 && hasq test ${IUSE} && ! use test;
1294 then
1279 eerror "You specified FEATURES=test, but USE=test is needed" 1295 eerror "You specified FEATURES=test, but USE=test is needed"
1280 eerror "to pull in the additional dependencies for testing" 1296 eerror "to pull in the additional dependencies for testing"
1281 die "Need USE=test enabled" 1297 die "Need USE=test enabled"
1282 fi 1298 fi
1283} 1299}
1308# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1324# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1309# java-pkg_announce-qa-violation \ 1325# java-pkg_announce-qa-violation \
1310# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1326# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1311# fi 1327# fi
1312 1328
1313 local antflags 1329 local antflags="-Dnoget=true"
1314 java-pkg_init-compiler_ 1330 java-pkg_init-compiler_
1315 local compiler="${GENTOO_COMPILER}" 1331 local compiler="${GENTOO_COMPILER}"
1316 1332
1317 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1333 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1318 1334
1320 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1336 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1321 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1337 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1322 fi 1338 fi
1323 1339
1324 if [[ ${compiler} != "javac" ]]; then 1340 if [[ ${compiler} != "javac" ]]; then
1325 antflags="-Dbuild.compiler=${build_compiler}" 1341 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1326 # Figure out any extra stuff to put on the classpath for compilers aside 1342 # Figure out any extra stuff to put on the classpath for compilers aside
1327 # from javac 1343 # from javac
1328 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to 1344 # ANT_BUILD_COMPILER_DEPS should be something that could be passed to
1329 # java-config -p 1345 # java-config -p
1330 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})" 1346 local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})"
1420# @return string - Name of the target to create javadocs 1436# @return string - Name of the target to create javadocs
1421# ------------------------------------------------------------------------------ 1437# ------------------------------------------------------------------------------
1422use_doc() { 1438use_doc() {
1423 use doc && echo ${@:-javadoc} 1439 use doc && echo ${@:-javadoc}
1424} 1440}
1441
1425 1442
1426# ------------------------------------------------------------------------------ 1443# ------------------------------------------------------------------------------
1427# @section-end build 1444# @section-end build
1428# ------------------------------------------------------------------------------ 1445# ------------------------------------------------------------------------------
1429 1446
1813# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 1830# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1814# verify that the current VM is sufficient. 1831# verify that the current VM is sufficient.
1815# Setup the environment for the VM being used. 1832# Setup the environment for the VM being used.
1816# ------------------------------------------------------------------------------ 1833# ------------------------------------------------------------------------------
1817java-pkg_switch-vm() { 1834java-pkg_switch-vm() {
1835 debug-print-function ${FUNCNAME} $*
1836
1818 if java-pkg_needs-vm; then 1837 if java-pkg_needs-vm; then
1819 # Use the VM specified by JAVA_PKG_FORCE_VM 1838 # Use the VM specified by JAVA_PKG_FORCE_VM
1820 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 1839 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1821 # If you're forcing the VM, I hope you know what your doing... 1840 # If you're forcing the VM, I hope you know what your doing...
1841 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
1822 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1842 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1823 # if we're allowed to switch the vm... 1843 # if we're allowed to switch the vm...
1824 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1844 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1825 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 1845 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1826 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1846 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1827 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1847 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1828 else 1848 else
1829 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1849 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1830 fi 1850 fi
1831 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 1851 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
1832 eerror "Unable to determine VM for building from dependencies." 1852 eerror "Unable to determine VM for building from dependencies:"
1833 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 1853 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1834 echo "VNEED: ${JAVA_PKG_VNEED}" 1854 echo "VNEED: ${JAVA_PKG_VNEED}"
1855 die "Failed to determine VM for building."
1835 else 1856 else
1836 export GENTOO_VM 1857 export GENTOO_VM
1837 fi 1858 fi
1838 # otherwise just make sure the current VM is sufficient 1859 # otherwise just make sure the current VM is sufficient
1839 else 1860 else

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.38

  ViewVC Help
Powered by ViewVC 1.1.20