blob: 11a2bf5c0cd0fde9265542af043e5c33b89a34df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# Defines the commonly used target directories and provides a convenience
# function to install jar files.
#
# All the default directory locations herein resemble locations chosen in
# the Debian distribution.
# Jar location on target
datadir_java ?= ${datadir}/java
# JNI library location on target
libdir_jni ?= ${libdir}/jni
# JVM bundle location on target
libdir_jvm ?= ${libdir}/jvm
STAGING_DATADIR_JAVA ?= ${STAGING_DATADIR}/java
STAGING_LIBDIR_JNI ?= ${STAGING_LIBDIR}/jni
STAGING_LIBDIR_JVM ?= ${STAGING_LIBDIR}/jvm
oe_jarinstall() {
# Purpose: Install a jar file and create all the given symlinks to it.
# Example:
# oe_jarinstall foo-1.3.jar foo.jar
# Installs foo-1.3.jar and creates symlink foo.jar.
#
# oe_jarinstall -s foo-1.3.jar foo.jar
# Installs foo-1.3.jar to staging and creates symlink foo.jar.
#
# oe_jarinstall -r foo-1.3.jar foo_1_3.jar foo.jar
# Installs foo_1_3.jar as foo-1.3.jar and creates a symlink to this.
#
dir=${D}${datadir_java}
destname=""
while [ "$#" -gt 0 ]; do
case "$1" in
-s)
dir=${STAGING_DATADIR_JAVA}
;;
-r)
shift
destname=$1
;;
-*)
oefatal "oe_jarinstall: unknown option: $1"
;;
*)
break;
;;
esac
shift
done
jarname=$1
destname=${destname:-`basename $jarname`}
shift
install -d $dir
install -m 0644 $jarname $dir/$destname
# Creates symlinks out of the remaining arguments.
while [ "$#" -gt 0 ]; do
if [ -e $dir/$1 ]; then
oewarn "file was in the way. removing:" $dir/$1
rm $dir/$1
fi
ln -s $destname $dir/$1
shift
done
}
oe_makeclasspath() {
# Purpose: Generate a classpath variable from the given Jar file names
# where the ".jar" has been omitted.
#
# oe_makeclasspath foo baz bar
# Prints ${datadir_java}/foo.jar:${datadir_java}/baz.jar:${datadir_java}/bar.jar
#
# oe_makeclasspath -s foo baz bar
# Prints ${STAGING_DATADIR_JAVA}/foo.jar:${STAGING_DATADIR_JAVA}/baz.jar:${STAGING_DATADIR_JAVA}/bar.jar
#
# Provide the -s at the beginning otherwise strange things happen.
#
dir=${datadir_java}
classpath=
delimiter=
while [ "$#" -gt 0 ]; do
case "$1" in
-s)
dir=${STAGING_DATADIR_JAVA}
;;
-*)
oefatal "oe_makeclasspath: unknown option: $1"
;;
*)
file=$dir/$1.jar
if [ ! -f $file ]; then
oefatal "oe_makeclasspath: Jar file for '$1' not found at $file"
fi
classpath=$classpath$delimiter$file
delimiter=":"
;;
esac
shift
done
echo $classpath
}
# Creates a simple wrapper script for your Java program.
# The script is written to ${PN} by default.
#
# Parameters are as follows:
# [options] <output file> <main class> [jar files ...]
#
# Options are
# -o <name> where name is the output file name
#
# It can only take jar files from ${datadir_java}!
oe_java_simple_wrapper() {
delimiter=
mainclass=
classpath=
output=${PN}
while [ "$#" -gt 0 ]; do
case "$1" in
-o)
shift
output=$1
;;
-*)
oefatal "oe_java_simple_wrapper: unknown option: $1"
;;
*)
if [ $mainclass ]
then
classpath=$classpath$delimiter${datadir_java}/$1
delimiter=":"
else
mainclass=$1
fi
;;
esac
shift
done
oenote "Creating simple Java wrapper script"
oenote "Output File: $output"
oenote "Main Class: $mainclass"
oenote "Classpath: $classpath"
echo "#!/bin/sh" > $output
echo "# This file is autogenerated by the oe_java_simple_wrapper function of OpenEmbedded" >> $output
echo >> $output
echo "# You can provide additional VM arguments by setting the VMARGS environment variable." >> $output
echo "CLASSPATH_ARG=\"-cp $classpath\"" >> $output
echo >> $output
echo "MAIN_CLASS=$mainclass" >> $output
echo >> $output
echo "# Allows overriding the VM by setting the JAVA environment variable." >> $output
echo "if [ x\${JAVA} = x ]" >> $output
echo "then" >> $output
echo " JAVA=java" >> $output
echo "fi" >> $output
echo >> $output
echo "exec \${JAVA} \${VMARGS} \${CLASSPATH_ARG} \${MAIN_CLASS} \${@}" >> $output
}
|