java.bbclass: Added function to generate very simple wrapper scripts.
authorRobert Schuster <thebohemian@gmx.net>
Sat, 9 Feb 2008 02:39:20 +0000 (02:39 +0000)
committerRobert Schuster <thebohemian@gmx.net>
Sat, 9 Feb 2008 02:39:20 +0000 (02:39 +0000)
classes/java.bbclass

index 7fa6dc1..41d52fe 100644 (file)
@@ -60,3 +60,63 @@ oe_jarinstall() {
     shift
   done
 }
+
+# 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
+}