From 22037ecb798fda43f57fa4518b0c7c2609fa7466 Mon Sep 17 00:00:00 2001 From: Tue Ton <49886739+chirontt@users.noreply.github.com> Date: Sun, 11 Feb 2024 13:35:21 -0500 Subject: [PATCH] Add swt.win32.aarch64 fragment and compile natives for Windows on Arm64 This adds the org.eclipse.swt.win32.aarch64 fragment and contains changes to the build.bat file, to support compiling the SWT natives for the Windows on Arm64 (WoA) platform. On a WoA box, run the following commands to produce the SWT natives (swt*.dll) for WoA: cd binaries\org.eclipse.swt.win32.win32.aarch64 mvn clean process-resources -Dnative=win32.win32.aarch64 and the swt*.dll files for WoA will be created in the current directory. Cross-compiling between the x64 and Arm64 platforms, where either of them can be host or target, is also possible, after setting up the TARGET_ARCH environment variable with correct target architecture value, and with the SWT_JAVA_HOME property pointing to an available JDK of the target architecture. For example, to cross-compile on an x64 host and produce SWT natives for Arm64 target, run the following commands: set TARGET_ARCH=arm64 cd binaries\org.eclipse.swt.win32.win32.aarch64 mvn clean process-resources -Dnative=win32.win32.aarch64 -DSWT_JAVA_HOME=\path\to\arm64_jdk and the swt*.dll files for WoA will be created in the current directory. Note the above SWT_JAVA_HOME property in the command line which points to an available Arm64 JDK of the target architecture. Similarly, to cross-compile on an Arm64 host and produce SWT natives for x64 target, run the following commands: set TARGET_ARCH=x64 cd binaries\org.eclipse.swt.win32.win32.x86_64 mvn clean process-resources -Dnative=win32.win32.x86_64 -DSWT_JAVA_HOME=\path\to\x64_jdk and the swt*.dll files for x64 will be created in the current directory. Note that for cross-compiling between x64 and Arm64 to work, install the MSVC compiler version 2022, with mandatory build tools for both platforms included in the installation. Once the SWT natives for Arm64 are generated, the SWT binaries module's files can be produced with the following build commands in current directory: mvn clean verify -DskipTests=true and the module's jar/zip files will be produced in the target directory: org.eclipse.swt.win32.win32.aarch64-.jar org.eclipse.swt.win32.win32.aarch64--sources.jar swt--win32-win32-aarch64.zip Also add the WebView2Loader.dll version 1.0.1150.38 (matching the swt.win32.x86_64 fragment), obtained from the NuGet package microsoft.web.webview2 https://nuget.info/packages/Microsoft.Web.WebView2/1.0.1150.38 located in the sub-folder build/native/arm64 --- Jenkinsfile | 14 +- .../.project | 117 ++++ .../.settings/.api_filters | 603 ++++++++++++++++++ .../META-INF/MANIFEST.MF | 34 + .../WebView2Loader.dll | 3 + .../build.properties | 41 ++ .../fragment.properties | 12 + binaries/pom.xml | 1 + .../Eclipse SWT PI/win32/library/build.bat | 40 +- .../META-INF/p2.inf | 5 + pom.xml | 5 + 11 files changed, 868 insertions(+), 7 deletions(-) create mode 100644 binaries/org.eclipse.swt.win32.win32.aarch64/.project create mode 100644 binaries/org.eclipse.swt.win32.win32.aarch64/.settings/.api_filters create mode 100644 binaries/org.eclipse.swt.win32.win32.aarch64/META-INF/MANIFEST.MF create mode 100644 binaries/org.eclipse.swt.win32.win32.aarch64/WebView2Loader.dll create mode 100644 binaries/org.eclipse.swt.win32.win32.aarch64/build.properties create mode 100644 binaries/org.eclipse.swt.win32.win32.aarch64/fragment.properties diff --git a/Jenkinsfile b/Jenkinsfile index dbc15d6d3bb..949e72d21f7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,6 +51,18 @@ spec: /** Returns the download URL of the JDK against whoose C headers (in the 'include/' folder) and native libaries the SWT natives are compiled.*/ def getNativeJdkUrl(String os, String arch){ // To update the used JDK version update the URL template below + if('win32'.equals(os) && 'aarch64'.equals(arch)) { + // Temporary workaround until there are official Temurin GA releases for Windows on ARM that can be consumed through JustJ + dir("${WORKSPACE}/repackage-win32.aarch64-jdk") { + sh """ + curl -L 'https://github.com/adoptium/temurin17-binaries/releases/download/jdk17u-2024-02-07-14-14-beta/OpenJDK17U-jdk_aarch64_windows_hotspot_2024-02-07-14-14.zip' > jdk.zip + unzip -q jdk.zip jdk-17.0.11+1/include/** jdk-17.0.11+1/lib/** + cd jdk-17.0.11+1 + tar -czf ../jdk.tar.gz include/ lib/ + """ + } + return "file://${WORKSPACE}/repackage-win32.aarch64-jdk/jdk.tar.gz" + } return "https://download.eclipse.org/justj/jres/17/downloads/20230428_1804/org.eclipse.justj.openjdk.hotspot.jre.minimal.stripped-17.0.7-${os}-${arch}.tar.gz" } @@ -177,7 +189,7 @@ pipeline { axes { axis { name 'PLATFORM' - values 'cocoa.macosx.aarch64' , 'cocoa.macosx.x86_64', 'gtk.linux.aarch64', 'gtk.linux.ppc64le', 'gtk.linux.x86_64', 'win32.win32.x86_64' + values 'cocoa.macosx.aarch64' , 'cocoa.macosx.x86_64', 'gtk.linux.aarch64', 'gtk.linux.ppc64le', 'gtk.linux.x86_64', 'win32.win32.aarch64', 'win32.win32.x86_64' } } stages { diff --git a/binaries/org.eclipse.swt.win32.win32.aarch64/.project b/binaries/org.eclipse.swt.win32.win32.aarch64/.project new file mode 100644 index 00000000000..b90f3ddaf24 --- /dev/null +++ b/binaries/org.eclipse.swt.win32.win32.aarch64/.project @@ -0,0 +1,117 @@ + + + org.eclipse.swt.win32.win32.aarch64 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + org.eclipse.pde.api.tools.apiAnalysisNature + + + + .classpath + 1 + PARENT-1-PROJECT_LOC/.classpath_win32 + + + .settings/.api_filters + 1 + PROJECT_LOC/.settings/.api_filters + + + .settings + 2 + PARENT-1-PROJECT_LOC/.settings + + + Eclipse SWT + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT + + + Eclipse SWT Accessibility + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20Accessibility + + + Eclipse SWT AWT + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20AWT + + + Eclipse SWT Browser + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20Browser + + + Eclipse SWT Custom Widgets + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20Custom%20Widgets + + + Eclipse SWT Drag and Drop + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20Drag%20and%20Drop + + + Eclipse SWT OLE Win32 + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20OLE%20Win32 + + + Eclipse SWT OpenGL + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20OpenGL + + + Eclipse SWT PI + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20PI + + + Eclipse SWT Printing + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20Printing + + + Eclipse SWT Program + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20Program + + + Eclipse SWT WebKit + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20WebKit + + + + + SWT_HOST_PLUGIN + $%7BPARENT-2-PROJECT_LOC%7D/bundles/org.eclipse.swt + + + diff --git a/binaries/org.eclipse.swt.win32.win32.aarch64/.settings/.api_filters b/binaries/org.eclipse.swt.win32.win32.aarch64/.settings/.api_filters new file mode 100644 index 00000000000..a33ae19da25 --- /dev/null +++ b/binaries/org.eclipse.swt.win32.win32.aarch64/.settings/.api_filters @@ -0,0 +1,603 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/binaries/org.eclipse.swt.win32.win32.aarch64/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.win32.win32.aarch64/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..163eced13bb --- /dev/null +++ b/binaries/org.eclipse.swt.win32.win32.aarch64/META-INF/MANIFEST.MF @@ -0,0 +1,34 @@ +Manifest-Version: 1.0 +Fragment-Host: org.eclipse.swt;bundle-version="[3.125.100,4.0.0)" +Bundle-Name: %fragmentName +Bundle-Vendor: %providerName +Bundle-SymbolicName: org.eclipse.swt.win32.win32.aarch64; singleton:=true +Bundle-Version: 3.126.0.qualifier +Bundle-ManifestVersion: 2 +Bundle-Localization: fragment +Export-Package: + org.eclipse.swt, + org.eclipse.swt.accessibility, + org.eclipse.swt.awt, + org.eclipse.swt.browser, + org.eclipse.swt.custom, + org.eclipse.swt.dnd, + org.eclipse.swt.events, + org.eclipse.swt.graphics, + org.eclipse.swt.layout, + org.eclipse.swt.opengl, + org.eclipse.swt.printing, + org.eclipse.swt.program, + org.eclipse.swt.widgets, + org.eclipse.swt.internal; x-friends:="org.eclipse.ui", + org.eclipse.swt.internal.image; x-internal:=true, + org.eclipse.swt.ole.win32, + org.eclipse.swt.internal.gdip; x-internal:=true, + org.eclipse.swt.internal.ole.win32; x-internal:=true, + org.eclipse.swt.internal.win32; x-internal:=true, + org.eclipse.swt.internal.opengl.win32; x-internal:=true +Eclipse-PlatformFilter: (& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=aarch64)) +SWT-WS: win32 +SWT-OS: win32 +SWT-Arch: aarch64 +Automatic-Module-Name: org.eclipse.swt.win32.win32.aarch64 diff --git a/binaries/org.eclipse.swt.win32.win32.aarch64/WebView2Loader.dll b/binaries/org.eclipse.swt.win32.win32.aarch64/WebView2Loader.dll new file mode 100644 index 00000000000..e36ef5cec20 --- /dev/null +++ b/binaries/org.eclipse.swt.win32.win32.aarch64/WebView2Loader.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dac2c67e5a21ba0a40a1a3ecdc9b7723708f10f5ecab26f2ddb729c2e27396ca +size 127912 diff --git a/binaries/org.eclipse.swt.win32.win32.aarch64/build.properties b/binaries/org.eclipse.swt.win32.win32.aarch64/build.properties new file mode 100644 index 00000000000..a229d438259 --- /dev/null +++ b/binaries/org.eclipse.swt.win32.win32.aarch64/build.properties @@ -0,0 +1,41 @@ +############################################################################### +# Copyright (c) 2023, 2024 Tue Ton 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: +# Tue Ton - initial API and implementation +# Hannes Wellmann - Leverage Tycho pomless +############################################################################### +custom = true +bin.includes = .,*.dll,fragment.properties +bin.excludes = library/ +source.. = \ + ../legal_files/win32.win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT/common,\ + ../../bundles/org.eclipse.swt/Eclipse SWT PI/common,\ + ../../bundles/org.eclipse.swt/Eclipse SWT PI/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/common,\ + ../../bundles/org.eclipse.swt/Eclipse SWT AWT/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT AWT/common,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Printing/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Printing/common,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Program/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Program/common,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Browser/common,\ + ../../bundles/org.eclipse.swt/Eclipse SWT Browser/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32,\ + ../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/common +output.. = bin/ + +pom.model.property.os=win32 +pom.model.property.ws=win32 +pom.model.property.arch=aarch64 diff --git a/binaries/org.eclipse.swt.win32.win32.aarch64/fragment.properties b/binaries/org.eclipse.swt.win32.win32.aarch64/fragment.properties new file mode 100644 index 00000000000..d4274553418 --- /dev/null +++ b/binaries/org.eclipse.swt.win32.win32.aarch64/fragment.properties @@ -0,0 +1,12 @@ +############################################################################### +# Copyright (c) 2023, 2024 Tue Ton 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: +# Tue Ton - initial API and implementation +############################################################################### +fragmentName = Standard Widget Toolkit for Windows on aarch64 +providerName = Eclipse.org diff --git a/binaries/pom.xml b/binaries/pom.xml index d85276be719..3c90d81a1ce 100644 --- a/binaries/pom.xml +++ b/binaries/pom.xml @@ -38,6 +38,7 @@ org.eclipse.swt.gtk.linux.aarch64 org.eclipse.swt.gtk.linux.ppc64le org.eclipse.swt.gtk.linux.x86_64 + org.eclipse.swt.win32.win32.aarch64 org.eclipse.swt.win32.win32.x86_64 diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat index 0fb28068c28..a70696f1f31 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat @@ -13,7 +13,6 @@ @rem *************************************************************************** @rem The original build.bat source is located in /org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat. It is copied during various build(s). -@rem Typically it's not ran directly, instead it is reached by build.xml's build_libraries target found in eclipse.platform.swt\bundles\org.eclipse.swt.win32.win32.x86* @echo off echo @@ -51,15 +50,44 @@ IF NOT EXIST "%MSVC_HOME%" ( @rem Check for a usable JDK IF "%SWT_JAVA_HOME%"=="" CALL :ECHO "'SWT_JAVA_HOME' was not provided" IF NOT EXIST "%SWT_JAVA_HOME%" ( - CALL :ECHO "WARNING: x64 Java JDK not found. Please set SWT_JAVA_HOME to the JDK directory containing the intended JDK native headers." + CALL :ECHO "WARNING: 64-bit Java JDK not found. Please set SWT_JAVA_HOME to the JDK directory containing the intended JDK native headers." ) -@rem ----------------------- -set PROCESSOR_ARCHITECTURE=AMD64 -IF "x.%OUTPUT_DIR%"=="x." set OUTPUT_DIR=..\..\..\org.eclipse.swt.win32.win32.x86_64 +@REM Compose host architecture string for MSVC +IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( + SET HOST_ARCH=x64 +) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( + SET HOST_ARCH=arm64 +) ELSE ( + CALL :ECHO "ERROR: Unknown host architecture: %PROCESSOR_ARCHITECTURE%." + EXIT /B 1 +) + +@REM %TARGET_ARCH% may be specified by the caller for cross-compiling. +@REM If not, build for builder machine's architecture +IF "%TARGET_ARCH%"=="" ( + SET TARGET_ARCH=%HOST_ARCH% +) + +@REM Compose build argument for MSVC +IF "%TARGET_ARCH%"=="%HOST_ARCH%" ( + SET BUILD_ARCH=%TARGET_ARCH% +) ELSE ( + SET BUILD_ARCH=%HOST_ARCH%_%TARGET_ARCH% +) + +@REM Select build's output directory (if not specified) based on target arch +IF "%TARGET_ARCH%"=="x64" ( + IF "x.%OUTPUT_DIR%"=="x." SET OUTPUT_DIR=..\..\..\org.eclipse.swt.win32.win32.x86_64 +) ELSE IF "%TARGET_ARCH%"=="arm64" ( + IF "x.%OUTPUT_DIR%"=="x." SET OUTPUT_DIR=..\..\..\org.eclipse.swt.win32.win32.aarch64 +) ELSE ( + CALL :ECHO "ERROR: Unknown target architecture: %TARGET_ARCH%." + EXIT /B 1 +) set CFLAGS=-DJNI64 -call "%MSVC_HOME%\VC\Auxiliary\Build\vcvarsall.bat" x64 +call "%MSVC_HOME%\VC\Auxiliary\Build\vcvarsall.bat" %BUILD_ARCH% @rem if call to vcvarsall.bat (which sets up environment) silently fails, then provide advice to user. WHERE cl diff --git a/local-build/org.eclipse.swt.fragments.localbuild/META-INF/p2.inf b/local-build/org.eclipse.swt.fragments.localbuild/META-INF/p2.inf index 078e5e94e51..60341a0650a 100644 --- a/local-build/org.eclipse.swt.fragments.localbuild/META-INF/p2.inf +++ b/local-build/org.eclipse.swt.fragments.localbuild/META-INF/p2.inf @@ -28,3 +28,8 @@ requires.6.namespace = org.eclipse.equinox.p2.iu requires.6.name = org.eclipse.swt.cocoa.macosx.aarch64 requires.6.range = 0.0.0 requires.6.filter = (&(osgi.os=macosx)(osgi.ws=cocoa)(osgi.arch=aarch64)) + +requires.7.namespace = org.eclipse.equinox.p2.iu +requires.7.name = org.eclipse.swt.win32.win32.aarch64 +requires.7.range = 0.0.0 +requires.7.filter = (&(osgi.os=win32)(osgi.ws=win32)(osgi.arch=aarch64)) diff --git a/pom.xml b/pom.xml index a8fd8340a1a..8e8d601ce56 100644 --- a/pom.xml +++ b/pom.xml @@ -172,6 +172,11 @@ win32 x86_64 + + win32 + win32 + aarch64 +