Skip to content

Commit be6bd28

Browse files
committed
Compile SWT natives for Windows on Arm64 (WoA).
This commit mainly contains changes to the build.bat file, to support compiling the SWT natives for the 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. (Similarly, to recompile the existing SWT x64 natives, run the following commands on an x64 box: cd binaries\org.eclipse.swt.win32.win32.x86_64 mvn clean process-resources -Dnative=win32.win32.x86_64 ) 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. For cross-compiling between x64 and Arm64 to work, install the MSVC compiler version 2022, with mandatory build tools for both platforms.
1 parent 50d7ef7 commit be6bd28

File tree

3 files changed

+108
-6
lines changed

3 files changed

+108
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Manifest-Version: 1.0
2+
Fragment-Host: org.eclipse.swt;bundle-version="[3.125.0,4.0.0)"
3+
Bundle-Name: %fragmentName
4+
Bundle-Vendor: %providerName
5+
Bundle-SymbolicName: org.eclipse.swt.win32.win32.aarch64; singleton:=true
6+
Bundle-Version: 3.125.0.qualifier
7+
Bundle-ManifestVersion: 2
8+
Bundle-Localization: fragment
9+
Export-Package:
10+
org.eclipse.swt,
11+
org.eclipse.swt.accessibility,
12+
org.eclipse.swt.awt,
13+
org.eclipse.swt.browser,
14+
org.eclipse.swt.custom,
15+
org.eclipse.swt.dnd,
16+
org.eclipse.swt.events,
17+
org.eclipse.swt.graphics,
18+
org.eclipse.swt.layout,
19+
org.eclipse.swt.opengl,
20+
org.eclipse.swt.printing,
21+
org.eclipse.swt.program,
22+
org.eclipse.swt.widgets,
23+
org.eclipse.swt.internal; x-friends:="org.eclipse.ui",
24+
org.eclipse.swt.internal.image; x-internal:=true,
25+
org.eclipse.swt.ole.win32,
26+
org.eclipse.swt.internal.gdip; x-internal:=true,
27+
org.eclipse.swt.internal.ole.win32; x-internal:=true,
28+
org.eclipse.swt.internal.win32; x-internal:=true,
29+
org.eclipse.swt.internal.opengl.win32; x-internal:=true
30+
Eclipse-PlatformFilter: (& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=aarch64))
31+
SWT-WS: win32
32+
SWT-OS: win32
33+
SWT-Arch: aarch64
34+
Automatic-Module-Name: org.eclipse.swt.win32.win32.aarch64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
###############################################################################
2+
# Copyright (c) 2023, 2024 Tue Ton and others.
3+
# All rights reserved. This program and the accompanying materials
4+
# are made available under the terms of the Eclipse Public License v1.0
5+
# which accompanies this distribution, and is available at
6+
# http://www.eclipse.org/legal/epl-v10.html
7+
#
8+
# Contributors:
9+
# Tue Ton - initial API and implementation
10+
# Hannes Wellmann - Leverage Tycho pomless
11+
###############################################################################
12+
custom = true
13+
bin.includes = .,*.dll,about_files/,about.html,fragment.properties
14+
bin.excludes = library/
15+
source.. = \
16+
../../bundles/org.eclipse.swt/Eclipse SWT/win32,\
17+
../../bundles/org.eclipse.swt/Eclipse SWT/common,\
18+
../../bundles/org.eclipse.swt/Eclipse SWT PI/common,\
19+
../../bundles/org.eclipse.swt/Eclipse SWT PI/win32,\
20+
../../bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32,\
21+
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32,\
22+
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/common,\
23+
../../bundles/org.eclipse.swt/Eclipse SWT AWT/win32,\
24+
../../bundles/org.eclipse.swt/Eclipse SWT AWT/common,\
25+
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32,\
26+
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common,\
27+
../../bundles/org.eclipse.swt/Eclipse SWT Printing/win32,\
28+
../../bundles/org.eclipse.swt/Eclipse SWT Printing/common,\
29+
../../bundles/org.eclipse.swt/Eclipse SWT Program/win32,\
30+
../../bundles/org.eclipse.swt/Eclipse SWT Program/common,\
31+
../../bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common,\
32+
../../bundles/org.eclipse.swt/Eclipse SWT Browser/common,\
33+
../../bundles/org.eclipse.swt/Eclipse SWT Browser/win32,\
34+
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32,\
35+
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/common
36+
src.includes = about.html,about_files/
37+
38+
pom.model.property.os=win32
39+
pom.model.property.ws=win32
40+
pom.model.property.arch=aarch64

bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/build.bat

+34-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
@rem ***************************************************************************
1414

1515
@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).
16-
@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*
1716

1817
@echo off
1918
echo
@@ -51,15 +50,44 @@ IF NOT EXIST "%MSVC_HOME%" (
5150
@rem Check for a usable JDK
5251
IF "%SWT_JAVA_HOME%"=="" CALL :ECHO "'SWT_JAVA_HOME' was not provided"
5352
IF NOT EXIST "%SWT_JAVA_HOME%" (
54-
CALL :ECHO "WARNING: x64 Java JDK not found. Please set SWT_JAVA_HOME to the JDK directory containing the intended JDK native headers."
53+
CALL :ECHO "WARNING: 64-bit Java JDK not found. Please set SWT_JAVA_HOME to the JDK directory containing the intended JDK native headers."
5554
)
5655

57-
@rem -----------------------
58-
set PROCESSOR_ARCHITECTURE=AMD64
59-
IF "x.%OUTPUT_DIR%"=="x." set OUTPUT_DIR=..\..\..\org.eclipse.swt.win32.win32.x86_64
56+
@REM Compose host architecture string for MSVC
57+
IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
58+
SET HOST_ARCH=x64
59+
) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
60+
SET HOST_ARCH=arm64
61+
) ELSE (
62+
CALL :ECHO "ERROR: Unknown host architecture: %PROCESSOR_ARCHITECTURE%."
63+
EXIT /B 1
64+
)
65+
66+
@REM %TARGET_ARCH% may be specified by the caller for cross-compiling.
67+
@REM If not, build for builder machine's architecture
68+
IF "%TARGET_ARCH%"=="" (
69+
SET TARGET_ARCH=%HOST_ARCH%
70+
)
71+
72+
@REM Compose build argument for MSVC
73+
IF "%TARGET_ARCH%"=="%HOST_ARCH%" (
74+
SET BUILD_ARCH=%TARGET_ARCH%
75+
) ELSE (
76+
SET BUILD_ARCH=%HOST_ARCH%_%TARGET_ARCH%
77+
)
78+
79+
@REM Select build's output directory (if not specified) based on target arch
80+
IF "%TARGET_ARCH%"=="x64" (
81+
IF "x.%OUTPUT_DIR%"=="x." SET OUTPUT_DIR=..\..\..\org.eclipse.swt.win32.win32.x86_64
82+
) ELSE IF "%TARGET_ARCH%"=="arm64" (
83+
IF "x.%OUTPUT_DIR%"=="x." SET OUTPUT_DIR=..\..\..\org.eclipse.swt.win32.win32.aarch64
84+
) ELSE (
85+
CALL :ECHO "ERROR: Unknown target architecture: %TARGET_ARCH%."
86+
EXIT /B 1
87+
)
6088

6189
set CFLAGS=-DJNI64
62-
call "%MSVC_HOME%\VC\Auxiliary\Build\vcvarsall.bat" x64
90+
call "%MSVC_HOME%\VC\Auxiliary\Build\vcvarsall.bat" %BUILD_ARCH%
6391

6492
@rem if call to vcvarsall.bat (which sets up environment) silently fails, then provide advice to user.
6593
WHERE cl

0 commit comments

Comments
 (0)