Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2018-11-05 16:12:00 +0000
committerEric Williams2018-11-07 16:47:25 +0000
commitdb2d0d1672441f2c6daee36d7acc7e0bf03fe7fe (patch)
tree670cd4aadfbb2c544cf46ffde65fccb13a0f4dd8
parent322aa5c871733bd329bfd88a28e692bae897bfff (diff)
downloadeclipse.platform.swt-db2d0d1672441f2c6daee36d7acc7e0bf03fe7fe.tar.gz
eclipse.platform.swt-db2d0d1672441f2c6daee36d7acc7e0bf03fe7fe.tar.xz
eclipse.platform.swt-db2d0d1672441f2c6daee36d7acc7e0bf03fe7fe.zip
Bug 540801: [GTK4] Build SWT on GTK4
Modify build scripts so bindings can be compiled against GTK4. Change-Id: I7319d7a242f81a589a28070d37038363947a3f8a Signed-off-by: Eric Williams <ericwill@redhat.com>
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh60
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/makefile11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java16
6 files changed, 99 insertions, 11 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh
index f9ab03d7a8..4368630b28 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh
@@ -16,10 +16,19 @@
#*******************************************************************************
HELP="
+Build GTK4 or GTK3 bindings and (optionally) copy them to binary repository.
Paramaters (specified in this order):
clean - delete *.o and *.so files from current folder. If this is the only paramater, do nothing else.
But if other paramaters are given and this is the first one, then continue with other actions.
+One of the following 3:
+-gtk3 : Build bindings with GTK3.
+-gtk4 : Build bindings with GTK4.
+-gtk-all : Build bindings with GTK3 as well as GTK4. Note, this flag triggers cleanups before each build
+ because a cleanup is required when building different GTK versions for linking to be done correctly.
+ During active development, if you only want to compile updated files, use -gtk3/-gtk4 flags instead,
+ however do not forget to do a cleanup in between gtk3/gtk4.
+
install - copy *.so libraries to binary repository.
--print-outputdir-and-exit - This simply echos the OUTPUT folder where .so libs are copied to,
@@ -27,13 +36,13 @@ install - copy *.so libraries to binary repository.
-- Examples:
Most commonly used:
-./build.sh install
-This will clean everything in your repository, build and then copy .so files to binary repository.
+./build.sh -gtk-all install
+This will clean everything in your repository, build GTK3 and GTK4, then copy .so files to binary repository.
Also:
./build.sh - only build .so files, do not copy them across. Build according to what GTK_VERSION is set to.
./build.sh clean - clean working directory of *.o and *.so files.
-./build.sh install - build.so files and copy to binary repository
+./build.sh -gtk4 install - build.so files and copy to binary repository
Also note:
Sometimes you might have to cleanup the binary repository manually as old *.so files are not automatically removed
@@ -283,7 +292,7 @@ if [ "x${1}" = "xclean" ]; then
shift
# if there are no more other parameters, exit.
- # don't exit if there are more paramaters. Useful for one-liners like: ./build.sh clean install
+ # don't exit if there are more paramaters. Useful for one-liners like: ./build.sh clean -gtk-all install
if [ "$1" = "" ]; then
exit $?
fi
@@ -293,6 +302,28 @@ fi
# Announce our target
func_echo_plus "Building SWT/GTK+ for Architectures: $SWT_OS $SWT_ARCH"
+func_build_gtk4 () {
+ export GTK_VERSION=4.0
+
+ # Dictate Webkit2 Extension only if pkg-config flags exist
+ pkg-config --exists webkit2gtk-web-extension-4.0
+ if [ $? == 0 ]; then
+ export BUILD_WEBKIT2EXTENSION="yes";
+ else
+ func_echo_error "Warning: Cannot compile Webkit2 Extension because 'pkg-config --exists webkit2gtk-web-extension-4-0' check failed. Please install webkitgtk4-devel.ARCH on your system."
+ fi
+
+ func_echo_plus "Building GTK4 bindings:"
+ ${MAKE_TYPE} -f $MAKEFILE all $MAKE_CAIRO $MAKE_AWT "${@}"
+ RETURN_VALUE=$? #make can return 1 or 2 if it fails. Thus need to cache it in case it's used programmatically somewhere.
+ if [ "$RETURN_VALUE" -eq 0 ]; then
+ func_echo_plus "GTK4 Build succeeded"
+ else
+ func_echo_error "GTK4 Build failed, aborting further actions.."
+ exit $RETURN_VALUE
+ fi
+}
+
func_build_gtk3 () {
export GTK_VERSION=3.0
@@ -315,5 +346,22 @@ func_build_gtk3 () {
fi
}
-func_build_gtk3 "$@"
-
+if [ "$1" = "-gtk-all" ]; then
+ shift
+ func_echo_plus "Note: When building multiple GTK versions, a cleanup is required (and automatically performed) between them."
+ func_clean_up
+ func_build_gtk4 "$@"
+ func_clean_up
+ func_build_gtk3 "$@"
+elif [ "$1" = "-gtk4" ]; then
+ shift
+ func_build_gtk4 "$@"
+elif [ "$1" = "-gtk3" ]; then
+ shift
+ func_build_gtk3 "$@"
+elif [ "${GTK_VERSION}" = "4.0" ]; then
+ func_build_gtk4 "$@"
+elif [ "${GTK_VERSION}" = "3.0" -o "${GTK_VERSION}" = "" ]; then
+ export GTK_VERSION="3.0"
+ func_build_gtk3 "$@"
+fi \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak
index 070cc0c1ce..62f365f104 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak
@@ -27,13 +27,17 @@ endif
include make_common.mak
SWT_VERSION=$(maj_ver)$(min_ver)r$(rev)
-GTK_VERSION=3.0
+GTK_VERSION?=3.0
# Define the various shared libraries to be build.
WS_PREFIX = gtk
SWT_PREFIX = swt
AWT_PREFIX = swt-awt
+ifeq ($(GTK_VERSION), 4.0)
+SWTPI_PREFIX = swt-pi4
+else
SWTPI_PREFIX = swt-pi3
+endif
CAIRO_PREFIX = swt-cairo
ATK_PREFIX = swt-atk
WEBKIT_PREFIX = swt-webkit
@@ -59,7 +63,11 @@ 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+-$(GTK_VERSION) gtk+-unix-print-$(GTK_VERSION)`
+ifeq ($(GTK_VERSION), 4.0)
+GTKLIBS = `pkg-config --libs-only-L gtk+-$(GTK_VERSION) gthread-2.0` $(XLIB64) -L/usr/X11R6/lib -lgtk-4 -lcairo -lgthread-2.0
+else
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
+endif
AWT_LFLAGS = -shared ${SWT_LFLAGS}
AWT_LIBS = -L$(AWT_LIB_PATH) -ljawt
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/makefile b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/makefile
index 63eef0c318..2a4fb15d3c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/makefile
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/makefile
@@ -4,7 +4,16 @@
# Build servers call build.sh directly.
all:
- ./build.sh install
+ ./build.sh -gtk-all install
+
+gtk4:
+ ./build.sh -gtk4 install
+
+gtk4-build-only:
+ ./build.sh -gtk4
+
+gtk3:
+ ./build.sh -gtk3 install
clean:
./build.sh clean
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
index 692f9f83d9..03ef2c62bf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
@@ -75,7 +75,7 @@
// Hard-link code generated from GTK.java to LIB_GTK
#define GTK_LOAD_FUNCTION(var, name) LOAD_FUNCTION_LIB(var, LIB_GTK, name)
-// Hard-link code generated from GTK.java to LIB_GDK
+// Hard-link code generated from GDK.java to LIB_GDK
#define GDK_LOAD_FUNCTION(var, name) LOAD_FUNCTION_LIB(var, LIB_GDK, name)
#ifdef _WIN32
@@ -101,9 +101,12 @@
#ifdef GDK_WINDOWING_X11
-
+#if GTK_CHECK_VERSION(3,94,0)
+// GTK4 does not need gtkx.h
+#else
#include <gdk/gdkx.h>
#include <gtk/gtkx.h>
+#endif
#else
#define NO_GDK_1IS_1X11_1DISPLAY
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index 17f546eece..4e3c65c2d0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -36,8 +36,14 @@
#define LIB_ATK "libatk-1.0-0.dll"
#define LIB_FONTCONFIG "libfontconfig-1.dll"
#else
+#if GTK_CHECK_VERSION(3,94,0)
+#define LIB_GTK "libgtk-4.so.0"
+// Point GDK to GTK for GTK4
+#define LIB_GDK "libgtk-4.so.0"
+#else
#define LIB_GTK "libgtk-3.so.0"
#define LIB_GDK "libgdk-3.so.0"
+#endif
#define LIB_GTHREAD "libgthread-2.0.so.0"
#define LIB_GLIB "libglib-2.0.so.0"
#define LIB_ATK "libatk-1.0.so.0"
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 85105b674c..bdbaabb42d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -73,7 +73,21 @@ public class OS extends C {
/** Initialization; load native libraries */
static {
- Library.loadLibrary("swt-pi3");
+ String propertyName = "SWT_GTK4";
+ String gtk4 = getEnvironmentalVariable (propertyName);
+ if (gtk4 != null && gtk4.equals("0")) {
+ try {
+ Library.loadLibrary("swt-pi3");
+ } catch (Throwable e) {
+ Library.loadLibrary("swt-pi4");
+ }
+ } else {
+ try {
+ Library.loadLibrary("swt-pi4");
+ } catch (Throwable e) {
+ Library.loadLibrary("swt-pi3");
+ }
+ }
cachejvmptr();
}

Back to the top