From 45fb4d59d8d853ec58dbf941f2d0a1ad9a27cc6d Mon Sep 17 00:00:00 2001
From: songliyang <songliyang@kylinos.cn>
Date: Wed, 10 Jul 2024 10:41:00 +0800
Subject: [PATCH] fix eclipse startup failure on loongarch64

---
 .../buildConfigs/equinox-launchers/build.xml  |  1 +
 .../rcp.config/build.properties               |  3 +++
 .../Eclipse SWT PI/gtk/library/build.sh       | 19 +++++++++++++++++--
 .../bundles/org.eclipse.swt/buildFragment.xml |  1 +
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/eclipse.platform.releng.tychoeclipsebuilder/equinox/buildConfigs/equinox-launchers/build.xml b/eclipse.platform.releng.tychoeclipsebuilder/equinox/buildConfigs/equinox-launchers/build.xml
index da6739c62..76a870f80 100644
--- a/eclipse.platform.releng.tychoeclipsebuilder/equinox/buildConfigs/equinox-launchers/build.xml
+++ b/eclipse.platform.releng.tychoeclipsebuilder/equinox/buildConfigs/equinox-launchers/build.xml
@@ -15,6 +15,7 @@
     <property name="archiveRoot" value="launchers" />
     <buildRepos os="win32" ws="win32" arch="x86_64" archiveName="${archiveRoot}-win32.win32.x86_64.${buildId}.zip" />
     <buildRepos os="linux" ws="gtk" arch="x86_64" archiveName="${archiveRoot}-linux.gtk.x86_64.${buildId}.tar.gz" />
+    <buildRepos os="linux" ws="gtk" arch="loongarch64" archiveName="${archiveRoot}-linux.gtk.loongarch64.${buildId}.tar.gz" />
     <buildRepos os="linux" ws="gtk" arch="ppc64le" archiveName="${archiveRoot}-linux.gtk.ppc64le.${buildId}.tar.gz" />
     <buildRepos os="macosx" ws="cocoa" arch="x86_64" archiveName="${archiveRoot}-macosx.cocoa.x86_64.${buildId}.tar.gz" />
   </target>
diff --git a/eclipse.platform.releng.tychoeclipsebuilder/rcp.config/build.properties b/eclipse.platform.releng.tychoeclipsebuilder/rcp.config/build.properties
index 259a9a022..b1bca238e 100644
--- a/eclipse.platform.releng.tychoeclipsebuilder/rcp.config/build.properties
+++ b/eclipse.platform.releng.tychoeclipsebuilder/rcp.config/build.properties
@@ -35,6 +35,9 @@ root.linux.gtk.ppc64le.permissions.755=eclipse
 root.linux.gtk.x86_64=rootfiles/linux.gtk.x86_64,../../rt.equinox.binaries/org.eclipse.equinox.executable/bin/gtk/linux/x86_64
 root.linux.gtk.x86_64.permissions.755=eclipse
 
+root.linux.gtk.loongarch64=rootfiles/linux.gtk.loongarch64,../../rt.equinox.binaries/org.eclipse.equinox.executable/bin/gtk/linux/loongarch64
+root.linux.gtk.loongarch64.permissions.755=eclipse
+
 bin.includes = feature.properties
 
 
diff --git a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh
index c67036574..81764ddd8 100755
--- a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh	
+++ b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh	
@@ -112,6 +112,10 @@ case $MODEL in
 		SWT_ARCH=x86
 		AWT_ARCH=i386
 		;;
+	"loongarch64")
+		SWT_ARCH=loongarch64
+		AWT_ARCH=loongarch64
+		;;
 	*)
 		SWT_ARCH=$MODEL
 		AWT_ARCH=$MODEL
@@ -180,6 +184,17 @@ case $SWT_OS.$SWT_ARCH in
 			export PKG_CONFIG_PATH="/usr/lib64/pkgconfig/"
 		fi
 		;;
+	"linux.loongarch64")
+		if [ "${CC}" = "" ]; then
+			export CC=gcc
+		fi
+		if [ "${JAVA_HOME}" = "" ]; then
+			export JAVA_HOME=`readlink -f /usr/bin/java | sed "s:jre/bin/java::"`
+		fi
+		if [ "${PKG_CONFIG_PATH}" = "" ]; then
+			export PKG_CONFIG_PATH="/usr/lib64/pkgconfig/"
+		fi
+		;;
 	"linux.s390x")
 		if [ "${CC}" = "" ]; then
 			export CC=gcc
@@ -195,7 +210,7 @@ esac
 
 
 # For 64-bit CPUs, we have a switch
-if [ ${MODEL} = 'x86_64' -o ${MODEL} = 'ia64' -o ${MODEL} = 's390x' -o ${MODEL} = 'ppc64le' -o ${MODEL} = 'aarch64' ]; then
+if [ ${MODEL} = 'x86_64' -o ${MODEL} = 'ia64' -o ${MODEL} = 's390x' -o ${MODEL} = 'ppc64le' -o ${MODEL} = 'aarch64' -o ${MODEL} = 'loongarch64' ]; then
 	SWT_PTR_CFLAGS=-DJNI64
 	if [ -d /lib64 ]; then
 		XLIB64=-L/usr/X11R6/lib64
@@ -365,4 +380,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
diff --git a/eclipse.platform.swt/bundles/org.eclipse.swt/buildFragment.xml b/eclipse.platform.swt/bundles/org.eclipse.swt/buildFragment.xml
index b4944c59d..99daf78bb 100644
--- a/eclipse.platform.swt/bundles/org.eclipse.swt/buildFragment.xml
+++ b/eclipse.platform.swt/bundles/org.eclipse.swt/buildFragment.xml
@@ -242,6 +242,7 @@
 				<equals arg1="${swt.arch}" arg2="s390x"/>
 				<equals arg1="${swt.arch}" arg2="sparcv9"/>
 				<equals arg1="${swt.arch}" arg2="aarch64"/>
+				<equals arg1="${swt.arch}" arg2="loongarch64"/>
 			</or>
 		</condition>
 		<echo>Is64=${is64}</echo>
-- 
2.43.0

