/[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.20 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
428# ------------------------------------------------------------------------------ 439# ------------------------------------------------------------------------------
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 # TODO-nichoj find out what exactly -f package-list does 444
445 # from /usr/lib/portage/bin/dohtml -h
446 # -f Set list of allowed extensionless file names.
434 dohtml -f package-list "$@" 447 dohtml -f package-list "$@"
448
435 # this probably shouldn't be here but it provides 449 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 450 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 451 # old ebuilds.
438 java-pkg_recordjavadoc 452 java-pkg_recordjavadoc
439} 453}
440 454
441# 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# ------------------------------------------------------------------------------
442java-pkg_dojavadoc() { 466java-pkg_dojavadoc() {
443 local dir="$1" 467 local dir="$1"
444 468
445 java-pkg_check-phase install 469 java-pkg_check-phase install
446 470
518# @ebuild-function java-pkg_dolauncher 542# @ebuild-function java-pkg_dolauncher
519# 543#
520# Make a wrapper script to lauch/start this package 544# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 545# If necessary, the wrapper will switch to the appropriate VM.
522# 546#
547# Can be called without parameters if the package installs only one jar
548# that has the Main-class attribute set. The wrapper will be named ${PN}.
549#
523# @param $1 - filename of launcher to create 550# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 551# @param $2 - options, as follows:
525# --main the.main.class.too.start 552# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 553# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass to java' 554# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'Extra arguments too pass to the package' 555# --pkg_args 'Extra arguments too pass to the package'
529# --pwd 556# --pwd
530# -into 557# -into
531# -pre 558# -pre
532# ------------------------------------------------------------------------------ 559# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 560java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 561 debug-print-function ${FUNCNAME} $*
535 562
536 java-pkg_check-phase install 563 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 564 java-pkg_init_paths_
541 565
566 if [[ ${#} = 0 ]]; then
567 local name="${PN}"
568 else
542 local name="${1}" 569 local name="${1}"
570 shift
571 fi
572
543 # TODO rename to launcher 573 # TODO rename to launcher
544 local target="${T}/${name}" 574 local target="${T}/${name}"
545 local var_tmp="${T}/launcher_variables_tmp" 575 local var_tmp="${T}/launcher_variables_tmp"
546 local target_dir pre 576 local target_dir pre
547 shift
548 577
549 # Process the other the rest of the arguments 578 # Process the other the rest of the arguments
550 while [[ -n "${1}" && -n "${2}" ]]; do 579 while [[ -n "${1}" && -n "${2}" ]]; do
551 local var=${1} value=${2} 580 local var="${1}" value="${2}"
552 if [[ "${var:0:2}" == "--" ]]; then 581 if [[ "${var:0:2}" == "--" ]]; then
582 local var=${var:2}
553 echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}" 583 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
584 local gjl_${var}="${value}"
554 elif [[ "${var}" == "-into" ]]; then 585 elif [[ "${var}" == "-into" ]]; then
555 target_dir="${value}" 586 target_dir="${value}"
556 elif [[ "${var}" == "-pre" ]]; then 587 elif [[ "${var}" == "-pre" ]]; then
557 pre="${value}" 588 pre="${value}"
558 fi 589 fi
559 shift 2 590 shift 2
560 done 591 done
592
593 # Test if no --jar and --main arguments were given and
594 # in that case check if the package only installs one jar
595 # and use that jar.
596 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
597 local cp="${JAVA_PKG_CLASSPATH}"
598 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
599 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
600 else
601 local msg="Not enough information to create a launcher given."
602 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
603 die "${msg}"
604 fi
605 fi
561 606
562 # Write the actual script 607 # Write the actual script
563 echo "#!/bin/bash" > "${target}" 608 echo "#!/bin/bash" > "${target}"
564 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 609 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
565 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 610 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
566 cat "${var_tmp}" >> "${target}" 611 cat "${var_tmp}" >> "${target}"
612 rm -f "${var_tmp}"
567 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 613 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
568 614
569 if [[ -n "${target_dir}" ]]; then 615 if [[ -n "${target_dir}" ]]; then
570 DESTTREE="${target_dir}" dobin "${target}" 616 DESTTREE="${target_dir}" dobin "${target}"
571 local ret=$? 617 local ret=$?
740# The providing packages are recorded as dependencies into package.env DEPEND 786# The providing packages are recorded as dependencies into package.env DEPEND
741# 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
742# 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
743# (junit testing etc). 789# (junit testing etc).
744# 790#
745# Example: Get the classpath for xerces-2, 791# Example: Get the classpath for xerces-2 and xalan,
746# java-pkg_getjars xerces-2 xalan 792# java-pkg_getjars xerces-2,xalan
747# Example Return: 793# Example Return:
748# /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
749# 795#
750# @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
751# package.env DEPEND line. 797# package.env DEPEND line.
752# @param $@ - list of packages to get jars from 798# @param $2 - list of packages to get jars from
799# (passed to java-config --classpath)
753# ------------------------------------------------------------------------------ 800# ------------------------------------------------------------------------------
754java-pkg_getjars() { 801java-pkg_getjars() {
755 debug-print-function ${FUNCNAME} $* 802 debug-print-function ${FUNCNAME} $*
756 803
757 local build_only=""
758
759 if [[ "${1}" = "--build-only" ]]; then 804 if [[ "${1}" = "--build-only" ]]; then
760 build_only="true" 805 local build_only="true"
761 shift 806 shift
762 fi 807 fi
763 808
764 [[ ${#} -lt 1 ]] && die "At least one argument needed" 809 [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --build-only"
765 810
766 # NOTE could probably just pass $@ to java-config --classpath. and return it
767 local classpath pkg 811 local classpath pkgs="${1}"
768 for pkg in ${@//,/ }; do
769 #for pkg in $(echo "$@" | tr ',' ' '); do
770 jars="$(java-config --classpath=${pkg})" 812 jars="$(java-config --classpath=${pkgs})"
771 [[ -z "${jars}" ]] && die "java-config --classpath=${pkg} failed" 813 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
772 debug-print "${pkg}:${jars}" 814 debug-print "${pkgs}:${jars}"
773 815
774 if [[ -z "${classpath}" ]]; then 816 if [[ -z "${classpath}" ]]; then
775 classpath="${jars}" 817 classpath="${jars}"
776 else 818 else
777 classpath="${classpath}:${jars}" 819 classpath="${classpath}:${jars}"
778 fi 820 fi
821
779 # Only record jars that aren't build-only 822 # Only record jars that aren't build-only
780 [[ -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}"
781 done 828 done
829 IFS="${oldifs}"
830 fi
831
782 echo "${classpath}" 832 echo "${classpath}"
783} 833}
784 834
785# ------------------------------------------------------------------------------ 835# ------------------------------------------------------------------------------
786# @ebuild-function java-pkg_getjar 836# @ebuild-function java-pkg_getjar
1134# @ebuild-function java-pkg_get-target 1184# @ebuild-function java-pkg_get-target
1135# 1185#
1136# Determines what target version should be used, for passing to -target. 1186# Determines what target version should be used, for passing to -target.
1137# 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
1138# version of your JDK. 1188# version of your JDK.
1139# Remember doing this will mostly like cause things to break.
1140# Doesn't allow it to be lower then the one in depend.
1141# Doesn't allow it to be higher then the active vm.
1142# 1189#
1143# @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
1144# ------------------------------------------------------------------------------ 1191# ------------------------------------------------------------------------------
1145java-pkg_get-target() { 1192java-pkg_get-target() {
1146 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1147 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1148 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1149 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1150 echo ${JAVA_PKG_WANT_TARGET}
1151 else
1152 echo ${min}
1153 fi
1154 else
1155 echo ${min}
1156 fi
1157
1158 #echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND}")} 1193 echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
1159} 1194}
1160 1195
1161java-pkg_get-javac() { 1196java-pkg_get-javac() {
1162 debug-print-function ${FUNCNAME} $* 1197 debug-print-function ${FUNCNAME} $*
1163 1198
1164 java-pkg_init-compiler_ 1199
1165 local compiler="${GENTOO_COMPILER}" 1200 local compiler="${GENTOO_COMPILER}"
1166 1201
1167 local compiler_executable 1202 local compiler_executable
1168 if [[ "${compiler}" = "javac" ]]; then 1203 if [[ "${compiler}" = "javac" ]]; then
1169 # nothing fancy needs to be done for javac 1204 # nothing fancy needs to be done for javac
1177 unset JAVAC 1212 unset JAVAC
1178 # try to get value of JAVAC 1213 # try to get value of JAVAC
1179 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1214 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1180 export JAVAC=${old_javac} 1215 export JAVAC=${old_javac}
1181 1216
1182 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1217 if [[ -z ${compiler_executable} ]]; then
1218 echo "JAVAC is empty or undefined in ${compiler_env}"
1219 return 1
1220 fi
1183 1221
1184 # check that it's executable 1222 # check that it's executable
1185 if [[ ! -x ${compiler_executable} ]]; then 1223 if [[ ! -x ${compiler_executable} ]]; then
1186 eerror "Could not find ${compiler_executable}!"
1187 die "${compiler_executable} doesn't exist, or isn't executable" 1224 echo "${compiler_executable} doesn't exist, or isn't executable"
1225 return 1
1188 fi 1226 fi
1189 else 1227 else
1190 eerror "Could not find environment file for ${compiler}" 1228 echo "Could not find environment file for ${compiler}"
1191 die "Could not find ${compiler_env}" 1229 return 1
1192 fi 1230 fi
1193 fi 1231 fi
1194 echo ${compiler_executable} 1232 echo ${compiler_executable}
1195} 1233}
1196 1234
1213 1251
1214 debug-print "want source: ${want_source}" 1252 debug-print "want source: ${want_source}"
1215 debug-print "want target: ${want_target}" 1253 debug-print "want target: ${want_target}"
1216 1254
1217 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1255 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1218 debug-print "could not find valid -source/-target values" 1256 debug-print "could not find valid -source/-target values for javac"
1219 die "Could not find valid -source/-target values" 1257 echo "Could not find valid -source/-target values for javac"
1258 return 1
1220 else 1259 else
1221 if java-pkg_is-vm-version-ge "1.4"; then 1260 if java-pkg_is-vm-version-ge "1.4"; then
1222 echo "${source_str} ${target_str}" 1261 echo "${source_str} ${target_str}"
1223 else 1262 else
1224 echo "${target_str}" 1263 echo "${target_str}"
1228 1267
1229# TODO document 1268# TODO document
1230java-pkg_get-jni-cflags() { 1269java-pkg_get-jni-cflags() {
1231 local flags="-I${JAVA_HOME}/include" 1270 local flags="-I${JAVA_HOME}/include"
1232 1271
1272 local platform="linux"
1273 use elibc_FreeBSD && platform="freebsd"
1274
1233 # TODO do a check that the directories are valid 1275 # TODO do a check that the directories are valid
1234 # TODO figure out how to cope with other things than linux...
1235 flags="${flags} -I${JAVA_HOME}/include/linux" 1276 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1236 1277
1237 echo ${flags} 1278 echo ${flags}
1238} 1279}
1239 1280
1240java-pkg_ensure-gcj() { 1281java-pkg_ensure-gcj() {
1246 die "No GCJ support found!" 1287 die "No GCJ support found!"
1247 fi 1288 fi
1248} 1289}
1249 1290
1250java-pkg_ensure-test() { 1291java-pkg_ensure-test() {
1251 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
1252 eerror "You specified FEATURES=test, but USE=test is needed" 1295 eerror "You specified FEATURES=test, but USE=test is needed"
1253 eerror "to pull in the additional dependencies for testing" 1296 eerror "to pull in the additional dependencies for testing"
1254 die "Need USE=test enabled" 1297 die "Need USE=test enabled"
1255 fi 1298 fi
1256} 1299}
1281# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1324# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1282# java-pkg_announce-qa-violation \ 1325# java-pkg_announce-qa-violation \
1283# "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"
1284# fi 1327# fi
1285 1328
1286 local antflags 1329 local antflags="-Dnoget=true"
1287 java-pkg_init-compiler_ 1330 java-pkg_init-compiler_
1288 local compiler="${GENTOO_COMPILER}" 1331 local compiler="${GENTOO_COMPILER}"
1289 1332
1290 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1333 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1291 1334
1293 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1336 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1294 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1337 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1295 fi 1338 fi
1296 1339
1297 if [[ ${compiler} != "javac" ]]; then 1340 if [[ ${compiler} != "javac" ]]; then
1298 antflags="-Dbuild.compiler=${build_compiler}" 1341 antflags="${antflags} -Dbuild.compiler=${build_compiler}"
1299 # 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
1300 # from javac 1343 # from javac
1301 # 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
1302 # java-config -p 1345 # java-config -p
1303 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})"
1329# @param $@ - Arguments to be passed to the compiler 1372# @param $@ - Arguments to be passed to the compiler
1330# ------------------------------------------------------------------------------ 1373# ------------------------------------------------------------------------------
1331ejavac() { 1374ejavac() {
1332 debug-print-function ${FUNCNAME} $* 1375 debug-print-function ${FUNCNAME} $*
1333 1376
1334 # FIXME using get-javac ends up printing stuff with einfo 1377 java-pkg_init-compiler_
1378
1379 local compiler_executable
1335# local compiler_executable=$(java-pkg_get-javac) 1380 compiler_executable=$(java-pkg_get-javac)
1336 local compiler_executable="javac" 1381 if [[ ${?} != 0 ]]; then
1382 eerror "There was a problem determining compiler: ${compiler_executable}"
1383 die "get-javac failed"
1384 fi
1337 1385
1386 local javac_args
1387 javac_args="$(java-pkg_javac-args)"
1388 if [[ ${?} != 0 ]]; then
1389 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1390 die "java-pkg_javac-args failed"
1391 fi
1392
1338 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1393 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1339 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1394 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1340} 1395}
1341 1396
1342# ------------------------------------------------------------------------------ 1397# ------------------------------------------------------------------------------
1343# @ebuild-function java-pkg_filter-compiler 1398# @ebuild-function java-pkg_filter-compiler
1344# 1399#
1381# @return string - Name of the target to create javadocs 1436# @return string - Name of the target to create javadocs
1382# ------------------------------------------------------------------------------ 1437# ------------------------------------------------------------------------------
1383use_doc() { 1438use_doc() {
1384 use doc && echo ${@:-javadoc} 1439 use doc && echo ${@:-javadoc}
1385} 1440}
1441
1386 1442
1387# ------------------------------------------------------------------------------ 1443# ------------------------------------------------------------------------------
1388# @section-end build 1444# @section-end build
1389# ------------------------------------------------------------------------------ 1445# ------------------------------------------------------------------------------
1390 1446
1576# Writes the package.env out to disk. 1632# Writes the package.env out to disk.
1577# 1633#
1578# ------------------------------------------------------------------------------ 1634# ------------------------------------------------------------------------------
1579# TODO change to do-write, to match everything else 1635# TODO change to do-write, to match everything else
1580java-pkg_do_write_() { 1636java-pkg_do_write_() {
1637 java-pkg_init_paths_
1581 # Create directory for package.env 1638 # Create directory for package.env
1582 dodir "${JAVA_PKG_SHAREPATH}" 1639 dodir "${JAVA_PKG_SHAREPATH}"
1583 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 1640 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1584 # Create package.env 1641 # Create package.env
1585 ( 1642 (
1613 # Strip unnecessary leading and trailing colons 1670 # Strip unnecessary leading and trailing colons
1614 # TODO try to cleanup if possible 1671 # TODO try to cleanup if possible
1615 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 1672 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1616 fi 1673 fi
1617} 1674}
1618
1619 1675
1620# ------------------------------------------------------------------------------ 1676# ------------------------------------------------------------------------------
1621# @internal-function java-pkg_record-jar_ 1677# @internal-function java-pkg_record-jar_
1622# 1678#
1623# Record a dependency to the package.env 1679# Record a dependency to the package.env
1704# ------------------------------------------------------------------------------ 1760# ------------------------------------------------------------------------------
1705java-pkg_setup-vm() { 1761java-pkg_setup-vm() {
1706 debug-print-function ${FUNCNAME} $* 1762 debug-print-function ${FUNCNAME} $*
1707 1763
1708 local vendor="$(java-pkg_get-vm-vendor)" 1764 local vendor="$(java-pkg_get-vm-vendor)"
1709 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 1765 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1710 addpredict "/dev/random" 1766 addpredict "/dev/random"
1711 elif [[ "${vendor}" == "ibm" ]]; then 1767 elif [[ "${vendor}" == "ibm" ]]; then
1712 addpredict "/proc/self/maps" 1768 addpredict "/proc/self/maps"
1713 addpredict "/proc/cpuinfo" 1769 addpredict "/proc/cpuinfo"
1714 export LANG="C" LC_ALL="C" 1770 export LANG="C" LC_ALL="C"
1763# @return - The version of the current VM 1819# @return - The version of the current VM
1764# ------------------------------------------------------------------------------ 1820# ------------------------------------------------------------------------------
1765java-pkg_get-vm-version() { 1821java-pkg_get-vm-version() {
1766 debug-print-function ${FUNCNAME} $* 1822 debug-print-function ${FUNCNAME} $*
1767 1823
1768 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 1824 java-config -g PROVIDES_VERSION
1769} 1825}
1770 1826
1771# ------------------------------------------------------------------------------ 1827# ------------------------------------------------------------------------------
1772# @internal-function java-pkg_switch-vm 1828# @internal-function java-pkg_switch-vm
1773# 1829#
1774# 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
1775# verify that the current VM is sufficient. 1831# verify that the current VM is sufficient.
1776# Setup the environment for the VM being used. 1832# Setup the environment for the VM being used.
1777# ------------------------------------------------------------------------------ 1833# ------------------------------------------------------------------------------
1778java-pkg_switch-vm() { 1834java-pkg_switch-vm() {
1835 debug-print-function ${FUNCNAME} $*
1836
1779 if java-pkg_needs-vm; then 1837 if java-pkg_needs-vm; then
1780 # Use the VM specified by JAVA_PKG_FORCE_VM 1838 # Use the VM specified by JAVA_PKG_FORCE_VM
1781 if [[ -n ${JAVA_PKG_FORCE_VM} ]]; then 1839 if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
1782 # 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}"
1783 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1842 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1784 # if we're allowed to switch the vm... 1843 # if we're allowed to switch the vm...
1785 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1844 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1786 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}"
1787 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1846 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1788 export 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}}")"
1789 else 1848 else
1790 export 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}}")"
1850 fi
1851 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
1852 eerror "Unable to determine VM for building from dependencies:"
1853 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1854 echo "VNEED: ${JAVA_PKG_VNEED}"
1855 die "Failed to determine VM for building."
1856 else
1857 export GENTOO_VM
1791 fi 1858 fi
1792 # otherwise just make sure the current VM is sufficient 1859 # otherwise just make sure the current VM is sufficient
1793 else 1860 else
1794 java-pkg_ensure-vm-version-sufficient 1861 java-pkg_ensure-vm-version-sufficient
1795 fi 1862 fi
1797 1864
1798 java-pkg_setup-vm 1865 java-pkg_setup-vm
1799 1866
1800 export JAVA=$(java-config --java) 1867 export JAVA=$(java-config --java)
1801 export JAVAC=$(java-config --javac) 1868 export JAVAC=$(java-config --javac)
1802 export JAVACFLAGS="$(java-pkg_javac-args)" 1869 JAVACFLAGS="$(java-pkg_javac-args)"
1870 if [[ ${?} != 0 ]]; then
1871 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
1872 die "java-pkg_javac-args failed"
1873 fi
1803 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1874 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1875 export JAVACFLAGS
1804 1876
1805 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1877 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1806 export JDK_HOME=${JAVA_HOME} 1878 export JDK_HOME=${JAVA_HOME}
1807 1879
1808 #TODO If you know a better solution let us know. 1880 #TODO If you know a better solution let us know.
1870 ewarn "Possible problem" 1942 ewarn "Possible problem"
1871 die "Bad class files found" 1943 die "Bad class files found"
1872 fi 1944 fi
1873} 1945}
1874 1946
1875
1876# ------------------------------------------------------------------------------ 1947# ------------------------------------------------------------------------------
1877# @section-end internal 1948# @section-end internal
1878# ------------------------------------------------------------------------------ 1949# ------------------------------------------------------------------------------
1879 1950
1880java-pkg_check-phase() { 1951java-pkg_check-phase() {

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

  ViewVC Help
Powered by ViewVC 1.1.20