Wed Oct 11 13:29:18 2023 UTC ()
Add swt version 4.21

SWT is the software component that delivers native widget functionality
for the Eclipse platform in an operating system independent manner.

This package provides SWT without requiring a full download and build of
Eclipse.


(bouyer)
diff -r0 -r1.1 pkgsrc/x11/swt/DESCR
diff -r0 -r1.1 pkgsrc/x11/swt/Makefile
diff -r0 -r1.1 pkgsrc/x11/swt/PLIST
diff -r0 -r1.1 pkgsrc/x11/swt/distinfo
diff -r0 -r1.1 pkgsrc/x11/swt/files/build.xml
diff -r0 -r1.1 pkgsrc/x11/swt/files/swt_functional_gtk_3_20.css
diff -r0 -r1.1 pkgsrc/x11/swt/files/swt_theming_fixes_gtk_3_20.css
diff -r0 -r1.1 pkgsrc/x11/swt/files/swt_theming_fixes_gtk_3_24_5.css
diff -r0 -r1.1 pkgsrc/x11/swt/patches/patch-build.sh
diff -r0 -r1.1 pkgsrc/x11/swt/patches/patch-make_netbsd.mak
diff -r0 -r1.1 pkgsrc/x11/swt/patches/patch-org_eclipse_swt_browser_WebKit.java
diff -r0 -r1.1 pkgsrc/x11/swt/patches/patch-org_eclipse_swt_internal_Library.java
diff -r0 -r1.1 pkgsrc/x11/swt/patches/patch-org_eclipse_swt_internal_gtk_OS.java
diff -r0 -r1.1 pkgsrc/x11/swt/patches/patch-org_eclipse_swt_widgets_Shell.java
diff -r0 -r1.1 pkgsrc/x11/swt/patches/patch-os.c

File Added: pkgsrc/x11/swt/DESCR
SWT is the software component that delivers native widget functionality
for the Eclipse platform in an operating system independent manner.

This package provides SWT without requiring a full download and build of
Eclipse.

File Added: pkgsrc/x11/swt/Makefile
# $NetBSD: Makefile,v 1.1 2023/10/11 13:29:17 bouyer Exp $

VERSION=	4.21
PKGNAME=	swt-${VERSION}
DISTNAME=	swt-${VERSION}-gtk-linux-x86_64
CATEGORIES=	graphics java x11
MASTER_SITES=   http://archive.eclipse.org/eclipse/downloads/drops4/R-${VERSION}-202109060500/
EXTRACT_SUFX=	.zip

MAINTAINER=	pkgsrc-users@NetBSD.org
HOMEPAGE=	https://www.eclipse.org/swt/
COMMENT=	Standard Widget Toolkit for Java
LICENSE=	epl-v2.0

USE_TOOLS+=	gmake pkg-config
USE_JAVA=	yes

USE_LANGUAGES=	c c++11

SWT_VERSION=    4946r21

MAKE_FILE=	make_netbsd.mak
MAKE_ENV+=	SWT_VERSION=${SWT_VERSION} MAKE_CAIRO=make_cairo
PLIST_SUBST+=	SWT_VERSION=${SWT_VERSION}

SUBST_CLASSES+=			fix-rpaths
SUBST_FILES.fix-rpaths=		make_netbsd.mak
SUBST_MESSAGE.fix-rpaths=	Fixing pkg-config rpath
SUBST_SED.fix-rpaths=		-e 's,--libs-only-L,--libs,g'
SUBST_STAGE.fix-rpaths=		pre-configure

post-extract:
	@${MKDIR} ${WRKSRC}
	(cd ${WRKSRC} && ${UNZIP_CMD} -qo ../*.zip)
	${CP} ${FILESDIR}/build.xml ${WRKSRC}/build.xml
	${CP} ${WRKSRC}/make_linux.mak ${WRKSRC}/make_netbsd.mak
	${CP} ${FILESDIR}/*.css ${WRKSRC}/org/eclipse/swt/internal/gtk/

do-build:
	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ./build.sh

do-install:
	@${MKDIR} ${DESTDIR}${PREFIX}/lib/java/
	${INSTALL_LIB} ${WRKSRC}/libswt-*.so ${DESTDIR}${PREFIX}/lib/
	${INSTALL_DATA} ${WRKDIR}/swt.jar ${DESTDIR}${PREFIX}/lib/java/

.include "../../graphics/glu/buildlink3.mk"
.include "../../graphics/gdk-pixbuf2/buildlink3.mk"
.include "../../graphics/cairo/buildlink3.mk"
.include "../../x11/gtk3/buildlink3.mk"
.include "../../x11/libXtst/buildlink3.mk"
.include "../../mk/java-vm.mk"
.include "../../mk/bsd.pkg.mk"

File Added: pkgsrc/x11/swt/PLIST
@comment $NetBSD: PLIST,v 1.1 2023/10/11 13:29:17 bouyer Exp $

lib/libswt-atk-gtk-${SWT_VERSION}.so
lib/libswt-awt-gtk-${SWT_VERSION}.so
lib/libswt-cairo-gtk-${SWT_VERSION}.so
lib/libswt-glx-gtk-${SWT_VERSION}.so
lib/libswt-gtk-${SWT_VERSION}.so
lib/libswt-pi3-gtk-${SWT_VERSION}.so
lib/libswt-webkit-gtk-${SWT_VERSION}.so
lib/java/swt.jar

File Added: pkgsrc/x11/swt/distinfo
$NetBSD: distinfo,v 1.1 2023/10/11 13:29:17 bouyer Exp $

BLAKE2s (swt-4.21-gtk-linux-x86_64.zip) = cd33abf5c5239282e212fb63e5adaff8e4c17bdbe0c4a22735ff968bae8b1d02
SHA512 (swt-4.21-gtk-linux-x86_64.zip) = b9a4eeecb48803e255e7d986579a9fc3a3465ceb91c3f525a764a8cf99fe250bf9e17565acb5aa8f8f65a153a70f67d2f523d3dc187751770271c6a0832698b7
Size (swt-4.21-gtk-linux-x86_64.zip) = 3851041 bytes
SHA1 (patch-build.sh) = 1ed9ce4c5dc931388b4d7ed3cbc387d1e37115a3
SHA1 (patch-make_netbsd.mak) = 12a33149add387f77ce1b85ed405641f2ab9216e
SHA1 (patch-org_eclipse_swt_browser_WebKit.java) = da39a3ee5e6b4b0d3255bfef95601890afd80709
SHA1 (patch-org_eclipse_swt_internal_Library.java) = 8930e4fdf5544c4f6bb8ed90460c428e483b0b65
SHA1 (patch-org_eclipse_swt_internal_gtk_OS.java) = 86242aa719673791616657e06e0b05d0d120f2dc
SHA1 (patch-org_eclipse_swt_widgets_Shell.java) = c5db524b36425cfecab456573214a789f7943e99
SHA1 (patch-os.c) = abc312d7abd27254ba8b914d7f47b116fe211b7a

File Added: pkgsrc/x11/swt/files/build.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2009 IBM Corporation and others.
    All rights reserved. This program and the accompanying materials
    are made available under the terms of the Eclipse Public License v1.0
    which accompanies this distribution, and is available at
    http://www.eclipse.org/legal/epl-v10.html
   
    Contributors:
        IBM Corporation - initial API and implementation
 -->
<project name="org.eclipse.swt.gtk.netbsd.x86_64" default="build.jar" basedir=".">

	<target name="init">
		<property name="ws" value="gtk"/>
		<property name="os" value="netbsd"/>
		<property name="destination" value="${basedir}"/>
                <property name="javac.verbose" value="false"/>
                <property name="javac.debug" value="off"/>
		<property name="input.srcdir" value="${basedir}/org"/>
		<property name="output.jar" value="${basedir}/swt.jar"/>
		<property name="output.classes" value="${basedir}/classes"/>
	</target>

	<target name="all" depends="build.jar"/>

	<target name="build.classes" depends="init">
		<mkdir dir="${output.classes}"/>
		<!-- -source & -target taken from Eclipse 32M4 CVS build -->
		<javac	srcdir="${input.srcdir}" destdir="${output.classes}" 
			debug="${javac.debug}" verbose="${javac.verbose}" 
			source="1.8" target="1.8">
		</javac>
	</target>

	<target name="build.jar" depends="build.nativeLibraries">
		<jar destfile="${output.jar}" index="false">
			<fileset dir="${output.classes}">
				<exclude name="**/*.java"/>
				<exclude name="**/*.o"/>
				<exclude name="**/*.so"/>
			</fileset>
			<fileset dir="${basedir}">
				<include name="**/version.txt"/>
				<include name="**/*.properties"/>
				<include name="**/*.css"/>
			</fileset>
		</jar>
	</target>

	<target name="clean" depends="init">
		<delete dir="${output.classes}"/>
		<delete file="${output.jar}"/>
		<exec  executable="sh" failonerror="true">
			<arg value="build.sh"/>
			<arg value="clean"/>
		</exec>
	</target>

	<target name="build.nativeLibraries" depends="build.classes">
		<exec  executable="sh" failonerror="true">
			<arg value="build.sh"/>
		</exec>
	</target>

</project>

File Added: pkgsrc/x11/swt/files/swt_functional_gtk_3_20.css
@binding-set SWTTreeViewBinding {
	bind "Left" { "expand-collapse-cursor-row" (0,0,0)};
	bind "Right" { "expand-collapse-cursor-row" (0,1,0)};
}

treeview {
	-gtk-key-bindings: SWTTreeViewBinding;
}

scrolledwindow undershoot.top, scrolledwindow undershoot.right,
	scrolledwindow undershoot.bottom, scrolledwindow undershoot.left {
	background-image: none;
}

File Added: pkgsrc/x11/swt/files/swt_theming_fixes_gtk_3_20.css
toolbar {
	padding-top: 2px;
	padding-bottom: 2px;
}

toolbar button {
	padding: 2px;
}

toolbar button.popup {
	padding: 0px;
}

toolbar toolbutton button {
	padding: 0px 0px 0px 0px;
}

entry {
	min-height: 26px;
}

tab {
	padding-left: 6px;
	padding-right: 6px;
}

File Added: pkgsrc/x11/swt/files/swt_theming_fixes_gtk_3_24_5.css
button {
	padding: 4px 8px;
}

File Added: pkgsrc/x11/swt/patches/patch-build.sh
$NetBSD: patch-build.sh,v 1.1 2023/10/11 13:29:17 bouyer Exp $

--- build.sh.orig	2021-09-06 06:22:24 UTC
+++ build.sh
@@ -72,7 +72,7 @@ echo -e "${RED}*** ${@}${NC}"
 
 cd `dirname $0`
 
-MAKE_TYPE=make
+MAKE_TYPE=gmake
 
 export CFLAGS='-O -Wall -fPIC'
 
@@ -86,15 +86,15 @@ case $OS in
 		MAKEFILE=make_win32.mak
 		;;
 	*)
-		SWT_OS=`uname -s | tr -s '[:upper:]' '[:lower:]'`
-		MAKEFILE=make_linux.mak
+		SWT_OS=`uname -s | tr '[:upper:]' '[:lower:]'`
+		MAKEFILE=make_${SWT_OS}.mak
 		;;
 esac
 
 # Determine which CPU type we are building for
 if [ "${MODEL}" = "" ]; then
-	if uname -i > /dev/null 2>&1; then
-		MODEL=`uname -i`
+	if uname -p > /dev/null 2>&1; then
+		MODEL=`uname -p`
 		if [ ${MODEL} = 'unknown' ]; then
 		  MODEL=`uname -m`
 		fi
@@ -103,10 +103,18 @@ if [ "${MODEL}" = "" ]; then
 	fi
 fi
 case $MODEL in
-	"x86_64")
+	"x86_64"|"amd64")
 		SWT_ARCH=x86_64
 		AWT_ARCH=amd64
 		;;
+	powerpc64)
+		SWT_ARCH=ppc64
+		AWT_ARCH=ppc64
+		;;
+	powerpc64le)
+		SWT_ARCH=ppc64le
+		AWT_ARCH=ppc64le
+		;;
 	*)
 		SWT_ARCH=$MODEL
 		AWT_ARCH=$MODEL
@@ -148,10 +156,10 @@ esac
 
 
 # For 64-bit CPUs, we have a switch
-if [ ${MODEL} = 'x86_64' -o ${MODEL} = 'ppc64le' -o ${MODEL} = 'aarch64' ]; then
+if [ ${MODEL} = 'x86_64' -o ${MODEL} = 'amd64' -o ${MODEL} = 'powerpc64' -o ${MODEL} = 'powerpc64le' -o ${MODEL} = 'ppc64le' -o ${MODEL} = 'aarch64' ]; then
 	SWT_PTR_CFLAGS=-DJNI64
 	if [ -d /lib64 ]; then
-		XLIB64=-L/usr/X11R6/lib64
+		XLIB64=-L${LOCALBASE}/lib64
 		export XLIB64
 	fi
 	if [ ${MODEL} = 'ppc64le' ]; then
@@ -163,18 +171,20 @@ if [ ${MODEL} = 'x86_64' -o ${MODEL} = 'ppc64le' -o ${
 	export SWT_PTR_CFLAGS
 fi
 
+if [ x${MAKE_CAIRO} = "xmake_cairo" ]; then
 if [ x`pkg-config --exists cairo && echo YES` = "xYES" ]; then
 	func_echo_plus "Cairo found, compiling SWT support for the cairo graphics library."
 	MAKE_CAIRO=make_cairo
 else
 	func_echo_error "Cairo not found: Advanced graphics support using cairo will not be compiled."
 fi
+fi
 
 # Find AWT if available
 if [ ${SWT_OS} = 'win32' ]; then
 	AWT_LIB_EXPR="jawt.dll"
 else
-	AWT_LIB_EXPR="libjawt.*"
+	AWT_LIB_EXPR="libjawt.so"
 fi
 
 if [ -z "${AWT_LIB_PATH}" ]; then
@@ -332,4 +342,4 @@ elif [ "${GTK_VERSION}" = "4.0" ]; then
 elif [ "${GTK_VERSION}" = "3.0" -o "${GTK_VERSION}" = "" ]; then
 	export GTK_VERSION="3.0"
 	func_build_gtk3 "$@"
-fi
\ No newline at end of file
+fi

File Added: pkgsrc/x11/swt/patches/patch-make_netbsd.mak
$NetBSD: patch-make_netbsd.mak,v 1.1 2023/10/11 13:29:17 bouyer Exp $

--- make_netbsd.mak.orig	2023-10-04 14:51:05.055924498 +0200
+++ make_netbsd.mak	2023-10-04 14:51:54.306059503 +0200
@@ -12,7 +12,7 @@
 #     IBM Corporation - initial API and implementation
 #*******************************************************************************
 
-# Makefile for creating SWT libraries for Linux GTK
+# Makefile for creating SWT libraries for NetBSD GTK
 
 # SWT debug flags for various SWT components.
 #SWT_WEBKIT_DEBUG = -DWEBKIT_DEBUG
@@ -66,25 +66,26 @@
 # Do not use pkg-config to get libs because it includes unnecessary dependencies (i.e. pangoxft-1.0)
 ifeq ($(GTK_VERSION), 4.0)
 GTKCFLAGS = `pkg-config --cflags gtk4 gtk4-x11 gtk4-unix-print`
-GTKLIBS = `pkg-config --libs-only-L gtk4 gtk4-x11 gthread-2.0` $(XLIB64) -L/usr/X11R6/lib -lgtk-4 -lcairo -lgthread-2.0
+GTKLIBS = `pkg-config --libs-only-L gtk4 gtk4-x11 gthread-2.0` $(XLIB64) -L$(LOCALBASE)/lib -lgtk-4 -lcairo -lgthread-2.0
 ATKCFLAGS = `pkg-config --cflags atk gtk4 gtk4-unix-print`
 else
 GTKCFLAGS = `pkg-config --cflags gtk+-$(GTK_VERSION) gtk+-unix-print-$(GTK_VERSION)`
-GTKLIBS = `pkg-config --libs-only-L gtk+-$(GTK_VERSION) gthread-2.0` $(XLIB64) -L/usr/X11R6/lib -lgtk-3 -lgdk-3 -lcairo -lgthread-2.0
+GTKLIBS = `pkg-config --libs-only-L gtk+-$(GTK_VERSION) gthread-2.0` $(XLIB64) -L$(LOCALBASE)/lib -lgtk-3 -lgdk-3 -lcairo -lgthread-2.0
 ATKCFLAGS = `pkg-config --cflags atk gtk+-$(GTK_VERSION) gtk+-unix-print-$(GTK_VERSION)`
 endif
 
-AWT_LFLAGS = -shared ${SWT_LFLAGS} 
+AWT_LFLAGS = -shared ${SWT_LFLAGS} ${LDFLAGS}
 AWT_LIBS = -L$(AWT_LIB_PATH) -ljawt
 
 ATKLIBS = `pkg-config --libs-only-L atk` -latk-1.0 
 
-GLXLIBS = -lGL -lGLU -lm
+GLXLIBS = -L$(LOCALBASE)/lib -lGL -lGLU -lm
+GLXCFLAGS = -I$(LOCALBASE)/include
 
 # Uncomment for Native Stats tool
 #NATIVE_STATS = -DNATIVE_STATS
 
-WEBKITLIBS = `pkg-config --libs-only-l gio-2.0`
+WEBKITLIBS = `pkg-config --libs-only-l gio-2.0` $(XLIB64) -L$(LOCALBASE)/lib
 WEBKITCFLAGS = `pkg-config --cflags gio-2.0`
 
 WEBKIT_EXTENSION_CFLAGS=`pkg-config --cflags gtk+-3.0 webkit2gtk-web-extension-4.0`
@@ -120,21 +121,22 @@
 		$(SWT_WEBKIT_DEBUG) \
 		-DLINUX -DGTK \
 		-I$(JAVA_HOME)/include \
-		-I$(JAVA_HOME)/include/linux \
+		-I$(JAVA_HOME)/include/netbsd \
+		-I$(LOCALBASE)/include \
 		${SWT_PTR_CFLAGS}
-LFLAGS = -shared -fPIC ${SWT_LFLAGS}
+LFLAGS = -shared -fPIC ${SWT_LFLAGS} ${LDFLAGS}
 
 # Treat all warnings as errors. If your new code produces a warning, please
 # take time to properly understand and fix/silence it as necessary.
 CFLAGS += -Werror
 
 ifndef NO_STRIP
-	# -s = Remove all symbol table and relocation information from the executable.
-	#      i.e, more efficent code, but removes debug information. Should not be used if you want to debug.
-	#      https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options
-	#      http://stackoverflow.com/questions/14175040/effects-of-removing-all-symbol-table-and-relocation-information-from-an-executab
-	AWT_LFLAGS := $(AWT_LFLAGS) -s
-	LFLAGS := $(LFLAGS) -s
+# -s = Remove all symbol table and relocation information from the executable.
+#      i.e, more efficent code, but removes debug information. Should not be used if you want to debug.
+#      https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options
+#      http://stackoverflow.com/questions/14175040/effects-of-removing-all-symbol-table-and-relocation-information-from-an-executab
+AWT_LFLAGS := $(AWT_LFLAGS) -s
+LFLAGS := $(LFLAGS) -s
 endif
 
 all: make_swt make_atk make_glx make_webkit

File Added: pkgsrc/x11/swt/patches/patch-org_eclipse_swt_browser_WebKit.java

File Added: pkgsrc/x11/swt/patches/patch-org_eclipse_swt_internal_Library.java
$NetBSD: patch-org_eclipse_swt_internal_Library.java,v 1.1 2023/10/11 13:29:17 bouyer Exp $

--- org/eclipse/swt/internal/Library.java.orig	2021-09-06 01:22:24 UTC
+++ org/eclipse/swt/internal/Library.java
@@ -65,12 +65,12 @@ static {
 
 static String arch() {
 	String osArch = System.getProperty("os.arch"); //$NON-NLS-1$
-	if (osArch.equals ("amd64")) return "x86_64"; //$NON-NLS-1$ $NON-NLS-2$
 	return osArch;
 }
 
 static String os() {
 	String osName = System.getProperty("os.name"); //$NON-NLS-1$
+	if (osName.equals ("NetBSD")) return "netbsd"; //$NON-NLS-1$ $NON-NLS-2$
 	if (osName.equals ("Linux")) return "linux"; //$NON-NLS-1$ $NON-NLS-2$
 	if (osName.equals ("Mac OS X")) return "macosx"; //$NON-NLS-1$ $NON-NLS-2$
 	if (osName.startsWith ("Win")) return "win32"; //$NON-NLS-1$ $NON-NLS-2$

File Added: pkgsrc/x11/swt/patches/patch-org_eclipse_swt_internal_gtk_OS.java
$NetBSD: patch-org_eclipse_swt_internal_gtk_OS.java,v 1.1 2023/10/11 13:29:17 bouyer Exp $

--- org/eclipse/swt/internal/gtk/OS.java.orig	2021-09-06 01:22:24 UTC
+++ org/eclipse/swt/internal/gtk/OS.java
@@ -65,8 +65,8 @@ public class OS extends C {
 
 		/* Initialize the OS flags and locale constants */
 		String osName = System.getProperty ("os.name");
-		boolean isLinux = false, isWin32 = false;
-		if (osName.equals ("Linux")) isLinux = true;
+		boolean isLinux = osName.equals ("Linux") || osName.equals ("NetBSD");
+		boolean isWin32 = false;
 		if (osName.startsWith("Windows")) isWin32 = true;
 		IsLinux = isLinux;  IsWin32 = isWin32;
 

File Added: pkgsrc/x11/swt/patches/patch-org_eclipse_swt_widgets_Shell.java
$NetBSD: patch-org_eclipse_swt_widgets_Shell.java,v 1.1 2023/10/11 13:29:17 bouyer Exp $

--- org/eclipse/swt/widgets/Shell.java.orig	2021-09-06 01:22:24 UTC
+++ org/eclipse/swt/widgets/Shell.java
@@ -1507,6 +1507,8 @@ long gtk_button_press_event (long widget, long event) 
 long gtk_configure_event (long widget, long event) {
 	int [] x = new int [1], y = new int [1];
 	GTK3.gtk_window_get_position (shellHandle, x, y);
+	int scale = GTK.gtk_widget_get_scale_factor (shellHandle);
+	x[0] /= scale; y[0] /= scale;
 
 	if (!isVisible ()) {
 		return 0; //We shouldn't handle move/resize events if shell is hidden.
@@ -3351,6 +3353,8 @@ Rectangle getBoundsInPixels () {
 			// TODO: GTK4 GtkWindow no longer has the ability to get position
 		} else {
 			GTK3.gtk_window_get_position (shellHandle, x, y);
+			int scale = GTK.gtk_widget_get_scale_factor (shellHandle);
+			x[0] /= scale; y[0] /= scale;
 		}
 	} else {
 		if (GTK.GTK4) {

File Added: pkgsrc/x11/swt/patches/patch-os.c
$NetBSD: patch-os.c,v 1.1 2023/10/11 13:29:17 bouyer Exp $

--- os.c.orig	2021-09-06 01:22:24 UTC
+++ os.c
@@ -15180,11 +15180,16 @@ JNIEXPORT jlong JNICALL OS_NATIVE(realpath)
 	jlong rc = 0;
 	OS_NATIVE_ENTER(env, that, realpath_FUNC);
 	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
-	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg1) {
+	    if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	} else
+	    lparg1 = malloc(PATH_MAX);
 	rc = (jlong)realpath((const char *)lparg0, (char *)lparg1);
 fail:
 	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
 	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	if (!arg1 && lparg1 && rc == 0)
+	    free(lparg1);
 	OS_NATIVE_EXIT(env, that, realpath_FUNC);
 	return rc;
 }