java.bbclass: New bbclass for java recipes.
authorRobert Schuster <thebohemian@gmx.net>
Thu, 17 Jan 2008 15:51:03 +0000 (15:51 +0000)
committerRobert Schuster <thebohemian@gmx.net>
Thu, 17 Jan 2008 15:51:03 +0000 (15:51 +0000)
java-library.bbclass: New bbclass for java library (jar) recipes.
swt3.3-gtk: New recipe.
swt3.4-gtk: New recipe.
swt3.4-gtk-hildon: New recipe.

classes/java-library.bbclass [new file with mode: 0644]
classes/java.bbclass [new file with mode: 0644]
packages/swt/.mtn2git_empty [new file with mode: 0644]
packages/swt/files/.mtn2git_empty [new file with mode: 0644]
packages/swt/files/Makefile [new file with mode: 0644]
packages/swt/files/swt-hildon.patch [new file with mode: 0644]
packages/swt/swt-gtk.inc [new file with mode: 0644]
packages/swt/swt3.3-gtk_3.3.1.bb [new file with mode: 0644]
packages/swt/swt3.4-gtk-hildon_3.3+3.4M3.bb [new file with mode: 0644]
packages/swt/swt3.4-gtk_3.3+3.4M3.bb [new file with mode: 0644]

diff --git a/classes/java-library.bbclass b/classes/java-library.bbclass
new file mode 100644 (file)
index 0000000..8aecfef
--- /dev/null
@@ -0,0 +1,37 @@
+# Inherit this bbclass for each java recipe that builds a Java library (jar file[s]).
+#
+# It automatically adds important build dependencies, defines JPN (Java Package Name)
+# a package named ${JPN} whose contents are those of ${datadir}/java (the jar location).
+#
+# The JPN is basically lib${PN}-java but takes care of the fact that ${PN} already
+# starts with "lib" and/or ends with "-java". In case the "lib" prefix is part of
+# your package's normal name (e.g. liberator) the guessing is wrong and you have
+# to set JPN manually!
+
+inherit java
+
+def java_package_name(d):
+  import bb;
+
+  pre=""
+  post=""
+
+  pn = bb.data.getVar('PN', d, 1)
+  if not pn.startswith("lib"):
+    pre='lib'
+
+  if not pn.endswith("-java"):
+    post='-java'
+
+  return pre + pn + post
+
+JPN ?= "${@java_package_name(d)}"
+
+DEPENDS_prepend = "virtual/javac-native fastjar-native "
+
+PACKAGES = "${JPN}"
+
+PACKAGE_ARCH_${JPN} = "all"
+
+FILES_${JPN} = "${datadir_java}"
+
diff --git a/classes/java.bbclass b/classes/java.bbclass
new file mode 100644 (file)
index 0000000..7fa6dc1
--- /dev/null
@@ -0,0 +1,62 @@
+# Defines the commonly used target directories and provides a convenience
+# function to install jar files.
+
+# Jar location on target
+datadir_java ?= ${datadir}/java
+
+# JNI library location on target
+libdir_jni ?= ${libdir}/jni
+
+STAGING_DATADIR_JAVA ?= ${STAGING_DATADIR}/java
+STAGING_LIBDIR_JNI ?= ${STAGING_LIBDIR}/jni
+
+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
+}
diff --git a/packages/swt/.mtn2git_empty b/packages/swt/.mtn2git_empty
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/packages/swt/files/.mtn2git_empty b/packages/swt/files/.mtn2git_empty
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/packages/swt/files/Makefile b/packages/swt/files/Makefile
new file mode 100644 (file)
index 0000000..2eb3557
--- /dev/null
@@ -0,0 +1,78 @@
+JAVA=swt-gtk-$(RELEASE).jar
+LIBRARIES=libswt.so libswt-pi.so libswt-mozilla.so
+CLEANFILES=*.files *.jar *.so* *-stamp
+
+RELEASE=OE_SWT_RELEASE
+SONAME_VERSION=OE_SWT_API_VERSION
+
+GCJ=gcj
+JAR=gjar
+JAVAC=javac -classpath .
+LDCONFIG=/sbin/ldconfig
+LN_S=ln -s
+RM=rm -f
+
+GCJFLAGS=-O2 -fPIC -fjni -shared
+
+LINK=$(GCJ) $(GCJFLAGS) -o $@ -Wl,-soname=lib$*.so.$(SONAME_VERSION)
+
+# Build without Jars
+#all:
+#      $(MAKE) -f make_linux.mak make_swt make_atk make_cairo
+
+# Build with Jars 
+all: $(JAVA) 
+       $(MAKE) -f make_linux.mak make_swt make_atk make_cairo
+
+# all: $(JAVA) $(LIBRARIES)
+#      $(MAKE) -f make_linux.mak make_swt make_atk make_gnome make_mozilla
+
+clean distclean:
+       $(RM) $(CLEANFILES)
+       $(RM) -r swt swt-pi swt-mozilla
+       -$(MAKE) -f make_linux.mak clean
+
+.PHONY: all clean distclean
+
+swt.files:
+       find org -name *.java \
+               -not -path org/eclipse/swt/internal\* \
+               -not -path org/eclipse/swt/browser\* | sort > $@
+
+swt-mozilla.files:
+       find org/eclipse/swt/browser org/eclipse/swt/internal/mozilla \
+               -name *.java | sort > $@
+
+swt-pi.files:
+       find org/eclipse/swt/internal -name *.java \
+               -not -path org/eclipse/swt/internal/mozilla\* | sort > $@
+
+%-stamp: %.files
+       mkdir -p $*
+       for i in `cat $<`; do \
+               if [ -e $*/$${i%java}class ]; then \
+                       echo SKIPPING $$i; \
+               else \
+                       echo $(JAVAC) -d $* $$i; \
+                       $(JAVAC) -d $* $$i || exit $$?; \
+               fi \
+       done
+       touch $@
+
+%.jar: %-stamp
+       $(JAR) -C $* -cf $@ .
+
+lib%.so.$(RELEASE): %.jar
+       $(LINK) $<
+       $(LDCONFIG) -n .
+
+%.so: %.so.$(RELEASE)
+       $(LN_S) -f $< $@
+
+swt-gtk-$(RELEASE).jar: swt.jar swt-pi.jar swt-mozilla.jar
+       mkdir _jar
+       cd _jar && for i in $^; do $(JAR) -xf ../$$i || exit $$?; done
+       $(JAR) -C _jar -cf $@ org
+       rm -rf _jar
+
+.SECONDARY:
diff --git a/packages/swt/files/swt-hildon.patch b/packages/swt/files/swt-hildon.patch
new file mode 100644 (file)
index 0000000..728dd30
--- /dev/null
@@ -0,0 +1,128 @@
+Index: swt-hildon/swt-source/make_linux.mak
+===================================================================
+--- swt-hildon.orig/swt-source/make_linux.mak  2008-01-08 09:35:29.000000000 +0100
++++ swt-hildon/swt-source/make_linux.mak       2008-01-08 11:35:01.000000000 +0100
+@@ -45,8 +45,8 @@
+ CAIROLIBS = `pkg-config --libs-only-L cairo` -lcairo
+ # Do not use pkg-config to get libs because it includes unnecessary dependencies (i.e. pangoxft-1.0)
+-GTKCFLAGS = `pkg-config --cflags gtk+-2.0`
+-GTKLIBS = `pkg-config --libs-only-L gtk+-2.0 gthread-2.0` -lgtk-x11-2.0 -lgthread-2.0 -L/usr/X11R6/lib $(XLIB64) -lXtst
++GTKCFLAGS = `pkg-config --cflags gtk+-2.0 hildon-1`
++GTKLIBS = -lhildon-1 `pkg-config --libs-only-L gtk+-2.0 gthread-2.0` -lgtk-x11-2.0 -lgthread-2.0 -L/usr/X11R6/lib $(XLIB64) -lXtst
+ CDE_LIBS = -L$(CDE_HOME)/lib -R$(CDE_HOME)/lib -lXt -lX11 -lDtSvc
+@@ -74,8 +74,6 @@
+       -Wno-non-virtual-dtor \
+       -fPIC \
+       -I. \
+-      -I$(JAVA_HOME)/include \
+-      -I$(JAVA_HOME)/include/linux \
+       ${SWT_PTR_CFLAGS}
+ MOZILLALIBS = -shared -Wl,--version-script=mozilla_exports -Bsymbolic
+ MOZILLAEXCLUDES = -DNO_XPCOMGlueShutdown -DNO_XPCOMGlueStartup
+@@ -96,8 +94,6 @@
+               -DSWT_VERSION=$(SWT_VERSION) \
+               $(NATIVE_STATS) \
+               -DLINUX -DGTK \
+-              -I$(JAVA_HOME)/include \
+-              -I$(JAVA_HOME)/include/linux \
+               -fPIC \
+               ${SWT_PTR_CFLAGS}
+ LIBS = -shared -fPIC
+Index: swt-hildon/swt-source/os.c
+===================================================================
+--- swt-hildon.orig/swt-source/os.c    2008-01-08 09:35:29.000000000 +0100
++++ swt-hildon/swt-source/os.c 2008-01-08 09:37:00.000000000 +0100
+@@ -17,6 +17,9 @@
+ #include "os_structs.h"
+ #include "os_stats.h"
++#include <hildon/hildon-program.h>
++#include <hildon/hildon-window.h>
++
+ #define OS_NATIVE(func) Java_org_eclipse_swt_internal_gtk_OS_##func
+ #ifndef NO_Call
+@@ -7015,9 +7018,18 @@
+ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1container_1add)
+       (JNIEnv *env, jclass that, jint arg0, jint arg1)
+ {
++  GtkContainer *container = (GtkContainer *) arg0;
++  GtkWidget *widget = (GtkWidget *) arg1;
+       OS_NATIVE_ENTER(env, that, _1gtk_1container_1add_FUNC);
+-      gtk_container_add((GtkContainer *)arg0, (GtkWidget *)arg1);
+-      OS_NATIVE_EXIT(env, that, _1gtk_1container_1add_FUNC);
++  if (GTK_CHECK_TYPE (widget, GTK_TYPE_MENU)
++      && !strcmp(gtk_menu_get_title(GTK_MENU(widget)), "__main_menu__"))
++  {
++    hildon_window_set_menu(HILDON_WINDOW(container), GTK_MENU(widget));
++  }
++  else
++   gtk_container_add((GtkContainer *)arg0, (GtkWidget *)arg1);
++
++   OS_NATIVE_EXIT(env, that, _1gtk_1container_1add_FUNC);
+ }
+ #endif
+@@ -9121,9 +9133,12 @@
+ JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1menu_1bar_1new)
+       (JNIEnv *env, jclass that)
+ {
++  GtkWidget *menu;
+       jint rc = 0;
+       OS_NATIVE_ENTER(env, that, _1gtk_1menu_1bar_1new_FUNC);
+-      rc = (jint)gtk_menu_bar_new();
++      menu = gtk_menu_new();
++  gtk_menu_set_title(menu, "__main_menu__");
++      rc = (jint) menu;
+       OS_NATIVE_EXIT(env, that, _1gtk_1menu_1bar_1new_FUNC);
+       return rc;
+ }
+@@ -15464,8 +15479,22 @@
+       (JNIEnv *env, jclass that, jint arg0)
+ {
+       jint rc = 0;
++  HildonProgram *p;
++  GtkWidget *w;
+       OS_NATIVE_ENTER(env, that, _1gtk_1window_1new_FUNC);
+-      rc = (jint)gtk_window_new((GtkWindowType)arg0);
++/*
++  if (GTK_WINDOW_TOPLEVEL == (GtkWindowType) arg0)
++  {
++*/
++    p = hildon_program_get_instance();
++    w = hildon_window_new();
++    hildon_program_add_window(p, HILDON_WINDOW(w));
++/*
++  }
++  else
++    w = gtk_window_new(GTK_WINDOW_POPUP);
++*/
++      rc = (jint) w;
+       OS_NATIVE_EXIT(env, that, _1gtk_1window_1new_FUNC);
+       return rc;
+ }
+Index: swt-hildon/swt-source/org/eclipse/swt/widgets/Menu.java
+===================================================================
+--- swt-hildon.orig/swt-source/org/eclipse/swt/widgets/Menu.java       2008-01-08 09:34:55.000000000 +0100
++++ swt-hildon/swt-source/org/eclipse/swt/widgets/Menu.java    2008-01-08 09:36:01.000000000 +0100
+@@ -259,9 +259,17 @@
+       if ((style & SWT.BAR) != 0) {
+               handle = OS.gtk_menu_bar_new ();
+               if (handle == 0) error (SWT.ERROR_NO_HANDLES);
++              if (parent instanceof Shell)
++              {
++              int /*long*/ shellHandle = ((Shell) parent).shellHandle;
++              OS.gtk_container_add (shellHandle, handle);
++              }
++              else
++              {
+               int /*long*/ vboxHandle = parent.vboxHandle;
+               OS.gtk_container_add (vboxHandle, handle);
+               OS.gtk_box_set_child_packing (vboxHandle, handle, false, true, 0, OS.GTK_PACK_START);
++              }
+       } else {
+               handle = OS.gtk_menu_new ();
+               if (handle == 0) error (SWT.ERROR_NO_HANDLES);
diff --git a/packages/swt/swt-gtk.inc b/packages/swt/swt-gtk.inc
new file mode 100644 (file)
index 0000000..6afadf1
--- /dev/null
@@ -0,0 +1,58 @@
+DESCRIPTION = "SWT is an open source widget toolkit for Java designed to provide efficient, portable access to the user-interface facilities"
+LICENSE = "CPL MPL LGPL"
+
+inherit java-library
+
+DEPENDS = "cairo gtk+ atk libxtst"
+
+S = "${WORKDIR}/swt-source"
+
+# A number which is used by SWT to mark the shared libraries. It can be found
+# in the version.txt file inside the source directory.
+SWTVERSION = ${@bb.fatal('SWTVERSION is not defined in this swt-gtk recipe!')}
+SWT_API_VERSION = ${@bb.fatal('SWT_API_VERSION is not defined in this swt-gtk recipe!')}
+
+do_unpackpost() {
+  if [ ! -d ${S} ]; then
+    mkdir ${S}
+    cd ${S}
+  fi
+
+  unzip -o ../src.zip
+  cp ../Makefile .
+
+  sed -i -e "s|RELEASE=OE_SWT_RELEASE|RELEASE=${PV}|" Makefile
+  sed -i -e "s|SONAME_VERSION=OE_SWT_API_VERSION|SONAME_VERSION=${SWT_API_VERSION}|" Makefile
+}
+
+do_compile() {
+  oe_runmake NATIVE_STATS="-I${STAGING_INCDIR}/classpath"
+}
+
+addtask unpackpost after do_unpack before do_patch
+
+do_install() {
+  oe_jarinstall swt-pi.jar
+  oe_jarinstall swt.jar
+  oe_jarinstall swt-gtk-${PV}.jar swt-gtk.jar
+
+  install -d ${D}${libdir_jni}
+  oe_libinstall -so libswt-atk-gtk-${SWTVERSION} ${D}/${libdir_jni}
+  oe_libinstall -so libswt-cairo-gtk-${SWTVERSION} ${D}/${libdir_jni}  
+  oe_libinstall -so libswt-pi-gtk-${SWTVERSION} ${D}/${libdir_jni}
+  oe_libinstall -so libswt-gtk-${SWTVERSION} ${D}/${libdir_jni}
+}
+
+do_stage() {
+  oe_jarinstall -s swt-pi.jar
+  oe_jarinstall -s swt.jar
+  oe_jarinstall -s swt-gtk-${PV}.jar swt-gtk.jar
+}
+
+PACKAGES += "lib${PN}-jni"
+
+FILES_lib${PN}-jni = "${libdir_jni}/lib*.so*"
+
+RDEPENDS_${JPN} = "lib${PN}-jni"
+RPROVIDES_${JPN} = "libswt${SWT_API_VERSION}-gtk-java"
+
diff --git a/packages/swt/swt3.3-gtk_3.3.1.bb b/packages/swt/swt3.3-gtk_3.3.1.bb
new file mode 100644 (file)
index 0000000..5b17853
--- /dev/null
@@ -0,0 +1,10 @@
+require swt-gtk.inc
+
+SRC_URI = "http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/eclipse/downloads/drops/R-${PV}-200710231652/swt-${PV}-gtk-linux-x86.zip \
+           file://Makefile"
+
+# A number which is used by SWT to mark the shared libraries.
+SWTVERSION = "3347"
+SWT_API_VERSION = "3.3"
+
+RCONFLICTS = "libswt3.4-gtk-java"
diff --git a/packages/swt/swt3.4-gtk-hildon_3.3+3.4M3.bb b/packages/swt/swt3.4-gtk-hildon_3.3+3.4M3.bb
new file mode 100644 (file)
index 0000000..628dcdd
--- /dev/null
@@ -0,0 +1,7 @@
+require swt3.4-gtk_${PV}.bb
+
+PR = "r1"
+
+DEPENDS += "hildon-1"
+
+SRC_URI += "file://swt-hildon.patch;patch=1;pnum=2"
diff --git a/packages/swt/swt3.4-gtk_3.3+3.4M3.bb b/packages/swt/swt3.4-gtk_3.3+3.4M3.bb
new file mode 100644 (file)
index 0000000..5d411f1
--- /dev/null
@@ -0,0 +1,12 @@
+require swt-gtk.inc
+
+SRC_URI = "http://ftp.wh2.tu-dresden.de/pub/mirrors/eclipse/eclipse/downloads/drops/S-3.4M3-200711012000/swt-3.4M3-gtk-linux-x86.zip \
+           file://Makefile"
+
+# A number which is used by SWT to mark the shared libraries.
+SWTVERSION = "3416"
+SWT_API_VERSION = "3.4"
+
+PROVIDES = "swt3.4-gtk"
+
+RCONFLICTS = "libswt3.3-gtk-java"