diff options
| author | Henning Heinold <heinold@inf.fu-berlin.de> | 2011-11-12 20:58:34 +0100 |
|---|---|---|
| committer | Henning Heinold <heinold@inf.fu-berlin.de> | 2011-11-26 23:41:44 +0100 |
| commit | 57e069cde6617f00ca8834a82c6f360af43d5067 (patch) | |
| tree | 48cbe15e96d217c45acfa64b0c13aad8c6424980 /classes/java.bbclass | |
| download | meta-java-57e069cde6617f00ca8834a82c6f360af43d5067.tar.gz | |
meta-java: initial commit
* taken over mostly stuff from oe classic
* cleaned up recipes
* added license checksums
* bump icedtea6-native to 1.8.11
* use jamvm from git as native
Diffstat (limited to 'classes/java.bbclass')
| -rw-r--r-- | classes/java.bbclass | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/classes/java.bbclass b/classes/java.bbclass new file mode 100644 index 0000000..6a45065 --- /dev/null +++ b/classes/java.bbclass | |||
| @@ -0,0 +1,184 @@ | |||
| 1 | # Defines the commonly used target directories and provides a convenience | ||
| 2 | # function to install jar files. | ||
| 3 | # | ||
| 4 | # All the default directory locations herein resemble locations chosen in | ||
| 5 | # the Debian distribution. | ||
| 6 | |||
| 7 | # Jar location on target | ||
| 8 | datadir_java ?= ${datadir}/java | ||
| 9 | |||
| 10 | # JNI library location on target | ||
| 11 | libdir_jni ?= ${libdir}/jni | ||
| 12 | |||
| 13 | # JVM bundle location on target | ||
| 14 | libdir_jvm ?= ${libdir}/jvm | ||
| 15 | |||
| 16 | STAGING_DATADIR_JAVA ?= ${STAGING_DATADIR}/java | ||
| 17 | STAGING_LIBDIR_JNI ?= ${STAGING_LIBDIR}/jni | ||
| 18 | STAGING_LIBDIR_JVM ?= ${STAGING_LIBDIR}/jvm | ||
| 19 | |||
| 20 | STAGING_DATADIR_JAVA_NATIVE ?= ${STAGING_DATADIR_NATIVE}/java | ||
| 21 | STAGING_LIBDIR_JNI_NATIVE ?= ${STAGING_LIBDIR_NATIVE}/jni | ||
| 22 | STAGING_LIBDIR_JVM_NATIVE ?= ${STAGING_LIBDIR_NATIVE}/jvm | ||
| 23 | |||
| 24 | oe_jarinstall() { | ||
| 25 | # Purpose: Install a jar file and create all the given symlinks to it. | ||
| 26 | # Example: | ||
| 27 | # oe_jarinstall foo-1.3.jar foo.jar | ||
| 28 | # Installs foo-1.3.jar and creates symlink foo.jar. | ||
| 29 | # | ||
| 30 | # oe_jarinstall -r foo-1.3.jar foo_1_3.jar foo.jar | ||
| 31 | # Installs foo_1_3.jar as foo-1.3.jar and creates a symlink to this. | ||
| 32 | # | ||
| 33 | dir=${D}${datadir_java} | ||
| 34 | destname="" | ||
| 35 | while [ "$#" -gt 0 ]; do | ||
| 36 | case "$1" in | ||
| 37 | -r) | ||
| 38 | shift | ||
| 39 | destname=$1 | ||
| 40 | ;; | ||
| 41 | -*) | ||
| 42 | oefatal "oe_jarinstall: unknown option: $1" | ||
| 43 | ;; | ||
| 44 | *) | ||
| 45 | break; | ||
| 46 | ;; | ||
| 47 | esac | ||
| 48 | shift | ||
| 49 | done | ||
| 50 | |||
| 51 | jarname=$1 | ||
| 52 | destname=${destname:-`basename $jarname`} | ||
| 53 | shift | ||
| 54 | |||
| 55 | install -d $dir | ||
| 56 | install -m 0644 $jarname $dir/$destname | ||
| 57 | |||
| 58 | # Creates symlinks out of the remaining arguments. | ||
| 59 | while [ "$#" -gt 0 ]; do | ||
| 60 | if [ -e $dir/$1 -o -h $dir/$1 ]; then | ||
| 61 | oewarn "file was in the way. removing:" $dir/$1 | ||
| 62 | rm $dir/$1 | ||
| 63 | fi | ||
| 64 | ln -s $destname $dir/$1 | ||
| 65 | shift | ||
| 66 | done | ||
| 67 | } | ||
| 68 | |||
| 69 | oe_makeclasspath() { | ||
| 70 | # Purpose: Generate a classpath variable from the given Jar file names | ||
| 71 | # where the ".jar" has been omitted. The string is stored in the script | ||
| 72 | # variable whose name is given in the first argument to this function. | ||
| 73 | # | ||
| 74 | # oe_makeclasspath cp foo baz bar | ||
| 75 | # Stores ${datadir_java}/foo.jar:${datadir_java}/baz.jar:${datadir_java}/bar.jar | ||
| 76 | # in variable "cp". | ||
| 77 | # | ||
| 78 | # oe_makeclasspath bootcp -s foo baz bar | ||
| 79 | # Stores ${STAGING_DATADIR_JAVA}/foo.jar:${STAGING_DATADIR_JAVA}/baz.jar:${STAGING_DATADIR_JAVA}/bar.jar | ||
| 80 | # in variable "bootcp". | ||
| 81 | # | ||
| 82 | # Provide the -s at the beginning otherwise strange things happen. | ||
| 83 | # If -s is given the function checks whether the requested jar file exists | ||
| 84 | # and exits with an error message if it cannot be found. | ||
| 85 | # | ||
| 86 | # Note: In order to encourage usage of the DEPENDS variable, the function | ||
| 87 | # can accept recipe names. If a recipe has no corresponding Jar file it | ||
| 88 | # is ignored. Be careful with recipes where the recipe name is different | ||
| 89 | # from the the Jar file name! | ||
| 90 | dir=${datadir_java} | ||
| 91 | classpath= | ||
| 92 | delimiter= | ||
| 93 | retval=$1 | ||
| 94 | |||
| 95 | shift | ||
| 96 | |||
| 97 | while [ "$#" -gt 0 ]; do | ||
| 98 | case "$1" in | ||
| 99 | -s) | ||
| 100 | # take jar files from native staging if this is a -native recipe | ||
| 101 | if [ ${PACKAGE_ARCH} = ${BUILD_ARCH} ]; then | ||
| 102 | dir=${STAGING_DATADIR_JAVA_NATIVE} | ||
| 103 | else | ||
| 104 | dir=${STAGING_DATADIR_JAVA} | ||
| 105 | fi | ||
| 106 | ;; | ||
| 107 | -*) | ||
| 108 | oefatal "oe_makeclasspath: unknown option: $1" | ||
| 109 | ;; | ||
| 110 | *) | ||
| 111 | file=$dir/$1.jar | ||
| 112 | |||
| 113 | if [ -e $file ]; then | ||
| 114 | classpath=$classpath$delimiter$file | ||
| 115 | delimiter=":" | ||
| 116 | fi | ||
| 117 | |||
| 118 | ;; | ||
| 119 | esac | ||
| 120 | shift | ||
| 121 | done | ||
| 122 | |||
| 123 | eval $retval="$classpath" | ||
| 124 | } | ||
| 125 | |||
| 126 | # Creates a simple wrapper script for your Java program. | ||
| 127 | # The script is written to ${PN} by default. | ||
| 128 | # | ||
| 129 | # Parameters are as follows: | ||
| 130 | # [options] <output file> <main class> [jar files ...] | ||
| 131 | # | ||
| 132 | # Options are | ||
| 133 | # -o <name> where name is the output file name | ||
| 134 | # | ||
| 135 | # It can only take jar files from ${datadir_java}! | ||
| 136 | oe_java_simple_wrapper() { | ||
| 137 | delimiter= | ||
| 138 | mainclass= | ||
| 139 | classpath= | ||
| 140 | output=${PN} | ||
| 141 | |||
| 142 | while [ "$#" -gt 0 ]; do | ||
| 143 | case "$1" in | ||
| 144 | -o) | ||
| 145 | shift | ||
| 146 | output=$1 | ||
| 147 | ;; | ||
| 148 | -*) | ||
| 149 | oefatal "oe_java_simple_wrapper: unknown option: $1" | ||
| 150 | ;; | ||
| 151 | *) | ||
| 152 | if [ $mainclass ] | ||
| 153 | then | ||
| 154 | classpath=$classpath$delimiter${datadir_java}/$1 | ||
| 155 | delimiter=":" | ||
| 156 | else | ||
| 157 | mainclass=$1 | ||
| 158 | fi | ||
| 159 | ;; | ||
| 160 | esac | ||
| 161 | shift | ||
| 162 | done | ||
| 163 | |||
| 164 | oenote "Creating simple Java wrapper script" | ||
| 165 | oenote "Output File: $output" | ||
| 166 | oenote "Main Class: $mainclass" | ||
| 167 | oenote "Classpath: $classpath" | ||
| 168 | |||
| 169 | echo "#!/bin/sh" > $output | ||
| 170 | echo "# This file is autogenerated by the oe_java_simple_wrapper function of OpenEmbedded" >> $output | ||
| 171 | echo >> $output | ||
| 172 | echo "# You can provide additional VM arguments by setting the VMARGS environment variable." >> $output | ||
| 173 | echo "CLASSPATH_ARG=\"-cp $classpath\"" >> $output | ||
| 174 | echo >> $output | ||
| 175 | echo "MAIN_CLASS=$mainclass" >> $output | ||
| 176 | echo >> $output | ||
| 177 | echo "# Allows overriding the VM by setting the JAVA environment variable." >> $output | ||
| 178 | echo "if [ x\${JAVA} = x ]" >> $output | ||
| 179 | echo "then" >> $output | ||
| 180 | echo " JAVA=java" >> $output | ||
| 181 | echo "fi" >> $output | ||
| 182 | echo >> $output | ||
| 183 | echo "exec \${JAVA} \${VMARGS} \${CLASSPATH_ARG} \${MAIN_CLASS} \${@}" >> $output | ||
| 184 | } | ||
