Skip to content

Commit

Permalink
Build GTK 4 binaries
Browse files Browse the repository at this point in the history
Currently the GTK4 binaries are not build as part of the build, this has
several drawbacks:

1) If anything is adjusted for GTK4 part it might break without notice
2) We have no GTK4 binaries by default

This enables *compilation* of the gtk4 parts to see at laest everything
can be compiled.
  • Loading branch information
laeubi committed Oct 9, 2024
1 parent 8feeb23 commit a1a119b
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install Linux requirements
run: |
sudo apt-get update -qq
sudo apt-get install -qq -y libgtk-3-dev freeglut3-dev webkit2gtk-driver
sudo apt-get install -qq -y libgtk-3-dev libgtk-4-dev freeglut3-dev webkit2gtk-driver
if: ${{ matrix.config.native == 'gtk.linux.x86_64'}}
- name: Pull large static Windows binaries
run: |
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def runOnNativeBuildAgent(String platform, Closure body) {
def final nativeBuildStageName = 'Build SWT-native binaries'
if (platform == 'gtk.linux.x86_64') {
podTemplate(inheritFrom: 'centos-latest' /* inhert general configuration */, containers: [
containerTemplate(name: 'swtbuild', image: 'eclipse/platformreleng-centos-swt-build:8',
containerTemplate(name: 'swtbuild', image: 'eclipse/platformreleng-debian-swtnativebuild:12',
resourceRequestCpu:'1000m', resourceRequestMemory:'512Mi',
resourceLimitCpu:'2000m', resourceLimitMemory:'4096Mi',
alwaysPullImage: true, command: 'cat', ttyEnabled: true)
Expand Down
2 changes: 0 additions & 2 deletions binaries/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,10 @@
</exec>
</then>
<else>
<property name="gtk_version" value="3.0" />
<exec dir="${build_dir}" executable="sh" failonerror="true">
<arg line="build.sh"/>
<env key="SWT_JAVA_HOME" value="${SWT_JAVA_HOME}"/>
<env key="OUTPUT_DIR" value="${project.basedir}"/>
<env key="GTK_VERSION" value="${gtk_version}"/>
<env key="MODEL" value="${arch}"/>
<arg line="install clean"/>
</exec>
Expand Down
31 changes: 19 additions & 12 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,9 @@ func_echo_plus "Building SWT/GTK+ for Architectures: $SWT_OS $SWT_ARCH"

func_build_gtk4 () {
export GTK_VERSION=4.0

func_echo_plus "Building GTK4 bindings:"
pkg-config --libs gtk+4.0
rpm -qi gtk4-devel
${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
Expand All @@ -268,8 +269,9 @@ func_build_gtk4 () {

func_build_gtk3 () {
export GTK_VERSION=3.0

func_echo_plus "Building GTK3 bindings:"
pkg-config --libs gtk+3.0
rpm -qi gtk3-devel
${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
Expand All @@ -280,22 +282,27 @@ func_build_gtk3 () {
fi
}

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
if [ "$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"
elif [ "${GTK_VERSION}" = "3.0" ]; then
func_build_gtk3 "$@"
else
func_echo_plus "==== Building GTK3 + GTK 4 ===="
func_echo_plus "See below for installed GTK versions:"
dpkg --get-selections | grep libgtk
apt list --installed libgtk*
rpm -qa|grep gtk
func_build_gtk3 "$@"
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 "$@"
fi
1 change: 1 addition & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*
* Contributors:
* Syntevo - initial API and implementation
* DUMMY CHANGE
*******************************************************************************/

#ifndef INC_gtk3_H
Expand Down
158 changes: 143 additions & 15 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,15 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1file_1dialog_1get_1default_1filter)
{
jlong rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1get_1default_1filter_FUNC);
rc = (jlong)gtk_file_dialog_get_default_filter((GtkFileDialog *)arg0);
/*
rc = (jlong)gtk_file_dialog_get_default_filter(arg0);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_get_default_filter)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong))fp)(arg0);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1get_1default_1filter_FUNC);
return rc;
}
Expand All @@ -674,7 +682,15 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1file_1dialog_1new)
{
jlong rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1new_FUNC);
/*
rc = (jlong)gtk_file_dialog_new();
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_new)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)())fp)();
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1new_FUNC);
return rc;
}
Expand All @@ -685,7 +701,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1open)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2, jlong arg3, jlong arg4)
{
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1open_FUNC);
gtk_file_dialog_open((GtkFileDialog *)arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
/*
gtk_file_dialog_open(arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_open)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, GtkWindow *, GCancellable *, GAsyncReadyCallback, gpointer))fp)(arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1open_FUNC);
}
#endif
Expand All @@ -698,7 +722,15 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1file_1dialog_1open_1finish)
jlong rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1open_1finish_FUNC);
if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
rc = (jlong)gtk_file_dialog_open_finish((GtkFileDialog *)arg0, (GAsyncResult *)arg1, (GError **)lparg2);
/*
rc = (jlong)gtk_file_dialog_open_finish(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_open_finish)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, GAsyncResult *, GError **))fp)(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
}
}
fail:
if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1open_1finish_FUNC);
Expand All @@ -711,7 +743,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1open_1multiple)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2, jlong arg3, jlong arg4)
{
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1open_1multiple_FUNC);
gtk_file_dialog_open_multiple((GtkFileDialog *)arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
/*
gtk_file_dialog_open_multiple(arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_open_multiple)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, GtkWindow *, GCancellable *, GAsyncReadyCallback, gpointer))fp)(arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1open_1multiple_FUNC);
}
#endif
Expand All @@ -724,7 +764,15 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1file_1dialog_1open_1multiple_1finish)
jlong rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1open_1multiple_1finish_FUNC);
if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
rc = (jlong)gtk_file_dialog_open_multiple_finish((GtkFileDialog *)arg0, (GAsyncResult *)arg1, (GError **)lparg2);
/*
rc = (jlong)gtk_file_dialog_open_multiple_finish(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_open_multiple_finish)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, GAsyncResult *, GError **))fp)(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
}
}
fail:
if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1open_1multiple_1finish_FUNC);
Expand All @@ -737,7 +785,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1save)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2, jlong arg3, jlong arg4)
{
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1save_FUNC);
gtk_file_dialog_save((GtkFileDialog *)arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
/*
gtk_file_dialog_save(arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_save)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, GtkWindow *, GCancellable *, GAsyncReadyCallback, gpointer))fp)(arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1save_FUNC);
}
#endif
Expand All @@ -750,7 +806,15 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1file_1dialog_1save_1finish)
jlong rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1save_1finish_FUNC);
if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
rc = (jlong)gtk_file_dialog_save_finish((GtkFileDialog *)arg0, (GAsyncResult *)arg1, (GError **)lparg2);
/*
rc = (jlong)gtk_file_dialog_save_finish(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_save_finish)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, GAsyncResult *, GError **))fp)(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
}
}
fail:
if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1save_1finish_FUNC);
Expand All @@ -763,7 +827,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1select_1folder)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2, jlong arg3, jlong arg4)
{
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1select_1folder_FUNC);
gtk_file_dialog_select_folder((GtkFileDialog *)arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
/*
gtk_file_dialog_select_folder(arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_select_folder)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, GtkWindow *, GCancellable *, GAsyncReadyCallback, gpointer))fp)(arg0, (GtkWindow *)arg1, (GCancellable *)arg2, (GAsyncReadyCallback)arg3, (gpointer)arg4);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1select_1folder_FUNC);
}
#endif
Expand All @@ -776,7 +848,15 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1file_1dialog_1select_1folder_1finish)
jlong rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1select_1folder_1finish_FUNC);
if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
rc = (jlong)gtk_file_dialog_select_folder_finish((GtkFileDialog *)arg0, (GAsyncResult *)arg1, (GError **)lparg2);
/*
rc = (jlong)gtk_file_dialog_select_folder_finish(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_select_folder_finish)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, GAsyncResult *, GError **))fp)(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
}
}
fail:
if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1select_1folder_1finish_FUNC);
Expand All @@ -789,7 +869,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1set_1default_1filter)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
{
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1set_1default_1filter_FUNC);
gtk_file_dialog_set_default_filter((GtkFileDialog *)arg0, (GtkFileFilter *)arg1);
/*
gtk_file_dialog_set_default_filter(arg0, (GtkFileFilter *)arg1);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_set_default_filter)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, GtkFileFilter *))fp)(arg0, (GtkFileFilter *)arg1);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1set_1default_1filter_FUNC);
}
#endif
Expand All @@ -799,7 +887,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1set_1filters)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
{
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1set_1filters_FUNC);
gtk_file_dialog_set_filters((GtkFileDialog *)arg0, (GListModel *)arg1);
/*
gtk_file_dialog_set_filters(arg0, (GListModel *)arg1);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_set_filters)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, GListModel *))fp)(arg0, (GListModel *)arg1);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1set_1filters_FUNC);
}
#endif
Expand All @@ -809,7 +905,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1set_1initial_1file)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
{
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1set_1initial_1file_FUNC);
gtk_file_dialog_set_initial_file((GtkFileDialog *)arg0, (GFile *)arg1);
/*
gtk_file_dialog_set_initial_file(arg0, (GFile *)arg1);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_set_initial_file)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, GFile *))fp)(arg0, (GFile *)arg1);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1set_1initial_1file_FUNC);
}
#endif
Expand All @@ -819,7 +923,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1set_1initial_1folder)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
{
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1set_1initial_1folder_FUNC);
gtk_file_dialog_set_initial_folder((GtkFileDialog *)arg0, (GFile *)arg1);
/*
gtk_file_dialog_set_initial_folder(arg0, (GFile *)arg1);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_set_initial_folder)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, GFile *))fp)(arg0, (GFile *)arg1);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1set_1initial_1folder_FUNC);
}
#endif
Expand All @@ -831,7 +943,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1set_1initial_1name)
jbyte *lparg1=NULL;
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1set_1initial_1name_FUNC);
if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
gtk_file_dialog_set_initial_name((GtkFileDialog *)arg0, (char *)lparg1);
/*
gtk_file_dialog_set_initial_name(arg0, (char *)lparg1);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_set_initial_name)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, char *))fp)(arg0, (char *)lparg1);
}
}
fail:
if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1set_1initial_1name_FUNC);
Expand All @@ -845,7 +965,15 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1set_1title)
jbyte *lparg1=NULL;
GTK4_NATIVE_ENTER(env, that, gtk_1file_1dialog_1set_1title_FUNC);
if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
gtk_file_dialog_set_title((GtkFileDialog *)arg0, (char *)lparg1);
/*
gtk_file_dialog_set_title(arg0, (char *)lparg1);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_file_dialog_set_title)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, char *))fp)(arg0, (char *)lparg1);
}
}
fail:
if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1file_1dialog_1set_1title_FUNC);
Expand Down
3 changes: 3 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@

#include <gtk/gtk.h>

// Hard-link code generated from GTK4.java to LIB_GTK
#define GTK4_LOAD_FUNCTION(var, name) LOAD_FUNCTION_LIB(var, LIB_GTK, name)

#endif /* INC_gtk4_H */
Loading

0 comments on commit a1a119b

Please sign in to comment.