From a03aff72c67f16ff44317053cec8084bbe07b028 Mon Sep 17 00:00:00 2001 From: Tue Ton Date: Tue, 27 Sep 2022 14:20:40 -0400 Subject: [PATCH 1/2] Add support for Windows on Arm64 (WoA) build New environment triplet win32/win32/aarch64 is added. Changes are made to the 'org.eclipse.swt' bundle to support successful compile of the new SWT native libraries (*.dll) for Arm64. --- .../org.eclipse.swt/.classpath_win32_aarch64 | 29 +++++++++++++++++++ .../Eclipse SWT PI/win32/library/build.bat | 26 ++++++++++------- .../Eclipse SWT PI/win32/library/os_custom.c | 6 ++-- bundles/org.eclipse.swt/buildSWT.xml | 13 +++++++-- pom.xml | 5 ++++ 5 files changed, 62 insertions(+), 17 deletions(-) create mode 100644 bundles/org.eclipse.swt/.classpath_win32_aarch64 diff --git a/bundles/org.eclipse.swt/.classpath_win32_aarch64 b/bundles/org.eclipse.swt/.classpath_win32_aarch64 new file mode 100644 index 00000000000..c92267de36e --- /dev/null +++ b/bundles/org.eclipse.swt/.classpath_win32_aarch64 @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 6b0ce1f2621..fcfea1341ce 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,7 @@ @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.binaries\bundles\org.eclipse.swt.win32.win32.x86* +@rem Typically it's not run directly, instead it is reached by build.xml's build_libraries target found in eclipse.platform.swt.binaries\bundles\org.eclipse.swt.win32.win32.* @echo off echo @@ -36,7 +36,7 @@ IF "%MSVC_HOME%"=="" CALL :ECHO "'MSVC_HOME' was not provided, auto-searching fo IF "%MSVC_HOME%"=="" CALL :FindVisualStudio "%SWT_BUILDDIR%\Microsoft\Visual Studio\$MSVC_VERSION$" @rem Bug 574007: Path used on Azure build machines IF "%MSVC_HOME%"=="" CALL :FindVisualStudio "%ProgramFiles(x86)%\Microsoft Visual Studio\$MSVC_VERSION$\BuildTools" -@rem Bug 578519: Common installation paths; VisualStudio is installed in x64 ProgramFiles since VS2022 +@rem Bug 578519: Common installation paths; VisualStudio is installed in 64-bit ProgramFiles since VS2022 IF "%MSVC_HOME%"=="" CALL :FindVisualStudio "%ProgramFiles%\Microsoft Visual Studio\$MSVC_VERSION$\$MSVC_EDITION$" @rem Bug 578519: Common installation paths; VisualStudio is installed in x86 ProgramFiles before VS2022 IF "%MSVC_HOME%"=="" CALL :FindVisualStudio "%ProgramFiles(x86)%\Microsoft Visual Studio\$MSVC_VERSION$\$MSVC_EDITION$" @@ -59,25 +59,28 @@ IF "%SWT_JAVA_HOME%"=="" CALL :TryToUseJdk "%SWT_BUILDDIR%\Java\Oracle\jdk1.8.0- @rem Note that first found JDK wins, so sort them by order of preference. IF "%SWT_JAVA_HOME%"=="" CALL :TryToUseJdk "%ProgramFiles%\Java\jdk*" IF "%SWT_JAVA_HOME%"=="" CALL :TryToUseJdk "%ProgramFiles%\AdoptOpenJDK\jdk*" +IF "%SWT_JAVA_HOME%"=="" CALL :TryToUseJdk "%JAVA_HOME%" @rem Report IF NOT EXIST "%SWT_JAVA_HOME%" ( - CALL :ECHO "WARNING: x64 Java JDK not found. Please set SWT_JAVA_HOME to your JDK directory." + CALL :ECHO "WARNING: 64-bit Java JDK not found. Please set SWT_JAVA_HOME to your JDK directory." CALL :ECHO " Refer steps for SWT Windows native setup: https://www.eclipse.org/swt/swt_win_native.php" ) ELSE ( - CALL :ECHO "SWT_JAVA_HOME x64: %SWT_JAVA_HOME%" + CALL :ECHO "SWT_JAVA_HOME 64-bit: %SWT_JAVA_HOME%" ) -@rem ----------------------- -IF NOT "x.%1"=="x.x86_64" ( - CALL :ECHO "ERROR: 32-bit builds are no longer supported." +IF "x.%1"=="x.x86_64" ( + set BUILD_ARCH=x64 + IF "x.%OUTPUT_DIR%"=="x." set OUTPUT_DIR=..\..\..\org.eclipse.swt.win32.win32.x86_64 +) ELSE IF "x.%1"=="x.aarch64" ( + set BUILD_ARCH=arm64 + IF "x.%OUTPUT_DIR%"=="x." set OUTPUT_DIR=..\..\..\org.eclipse.swt.win32.win32.aarch64 +) ELSE ( + CALL :ECHO "ERROR: %1 builds are no longer supported." EXIT /B 1 ) -set PROCESSOR_ARCHITECTURE=AMD64 -IF "x.%OUTPUT_DIR%"=="x." set OUTPUT_DIR=..\..\..\org.eclipse.swt.win32.win32.x86_64 - set CFLAGS=-DJNI64 -call "%MSVC_HOME%\VC\Auxiliary\Build\vcvarsall.bat" x64 +call "%MSVC_HOME%\VC\Auxiliary\Build\vcvarsall.bat" %BUILD_ARCH% shift @rem if call to vcvarsall.bat (which sets up environment) silently fails, then provide advice to user. @@ -117,6 +120,7 @@ GOTO :EOF CALL :FindVisualStudio3 "%~1" "%~2" "Community" CALL :FindVisualStudio3 "%~1" "%~2" "Enterprise" CALL :FindVisualStudio3 "%~1" "%~2" "Professional" + CALL :FindVisualStudio3 "%~1" "%~2" "Preview" ) ELSE ( CALL :FindVisualStudio3 "%~1" "%~2" "%MSVC_EDITION%" ) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c index c2e30bc87a4..78c3f1549bc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c @@ -63,7 +63,7 @@ BOOL Validate_AllowDarkModeForWindow(const BYTE* functionPtr) * an ATOM value of 0xA91E which is unlikely to change */ -#ifdef _M_X64 +#if defined(_M_X64) || defined(_M_ARM64) /* Win10 builds from 20236 */ if ((functionPtr[0x52] == 0xBA) && // mov edx, (*(const DWORD*)(functionPtr + 0x53) == 0xA91E)) // 0A91Eh @@ -111,7 +111,7 @@ TYPE_AllowDarkModeForWindow Locate_AllowDarkModeForWindow() BOOL Validate_AllowDarkModeForWindowWithTelemetryId(const BYTE* functionPtr) { -#ifdef _M_X64 +#if defined(_M_X64) || defined(_M_ARM64) /* This function is rather long, but it uses an ATOM value of 0xA91E which is unlikely to change */ /* Win10 builds from 21301 */ @@ -198,7 +198,7 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(AllowDarkModeForWindow) BOOL Validate_SetPreferredAppMode(const BYTE* functionPtr) { -#ifdef _M_X64 +#if defined(_M_X64) || defined(_M_ARM64) /* * This function is very simple, so validate entire body. * The only thing we don't know is the variable address. diff --git a/bundles/org.eclipse.swt/buildSWT.xml b/bundles/org.eclipse.swt/buildSWT.xml index 0453a792c2e..fbf78421ae1 100644 --- a/bundles/org.eclipse.swt/buildSWT.xml +++ b/bundles/org.eclipse.swt/buildSWT.xml @@ -77,6 +77,10 @@ + + + + @@ -86,15 +90,15 @@ Checking ${fragment} - + - + Matched files ${toString:match} - + @@ -255,6 +259,9 @@ + + + diff --git a/pom.xml b/pom.xml index 3f517aaad43..4ee31df282a 100644 --- a/pom.xml +++ b/pom.xml @@ -168,6 +168,11 @@ ${tycho.version} + + win32 + win32 + aarch64 + win32 win32 From 94d36db847e161bd981ae2cd047881924a6be1c1 Mon Sep 17 00:00:00 2001 From: Tue Ton Date: Wed, 28 Sep 2022 23:44:09 -0400 Subject: [PATCH 2/2] Revert custom dark mode code to default in WoA rather than sharing the custom code with the x64 platform, pending custom implementation need be added later for Arm64 platform. --- .../Eclipse SWT PI/win32/library/os_custom.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c index 78c3f1549bc..3a4f7eb7052 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_custom.c @@ -63,7 +63,7 @@ BOOL Validate_AllowDarkModeForWindow(const BYTE* functionPtr) * an ATOM value of 0xA91E which is unlikely to change */ -#if defined(_M_X64) || defined(_M_ARM64) +#ifdef _M_X64 /* Win10 builds from 20236 */ if ((functionPtr[0x52] == 0xBA) && // mov edx, (*(const DWORD*)(functionPtr + 0x53) == 0xA91E)) // 0A91Eh @@ -78,6 +78,10 @@ BOOL Validate_AllowDarkModeForWindow(const BYTE* functionPtr) return TRUE; } + return FALSE; +#elif defined(_M_ARM64) + /* Not implemented yet */ + functionPtr; /* to prevent: warning C4100: 'functionPtr': unreferenced formal parameter */ return FALSE; #else #error Unsupported processor type @@ -111,7 +115,7 @@ TYPE_AllowDarkModeForWindow Locate_AllowDarkModeForWindow() BOOL Validate_AllowDarkModeForWindowWithTelemetryId(const BYTE* functionPtr) { -#if defined(_M_X64) || defined(_M_ARM64) +#ifdef _M_X64 /* This function is rather long, but it uses an ATOM value of 0xA91E which is unlikely to change */ /* Win10 builds from 21301 */ @@ -121,6 +125,10 @@ BOOL Validate_AllowDarkModeForWindowWithTelemetryId(const BYTE* functionPtr) return TRUE; } + return FALSE; +#elif defined(_M_ARM64) + /* Not implemented yet */ + functionPtr; /* to prevent: warning C4100: 'functionPtr': unreferenced formal parameter */ return FALSE; #else #error Unsupported processor type @@ -198,7 +206,7 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(AllowDarkModeForWindow) BOOL Validate_SetPreferredAppMode(const BYTE* functionPtr) { -#if defined(_M_X64) || defined(_M_ARM64) +#ifdef _M_X64 /* * This function is very simple, so validate entire body. * The only thing we don't know is the variable address. @@ -212,6 +220,10 @@ BOOL Validate_SetPreferredAppMode(const BYTE* functionPtr) (functionPtr[0x00] == 0x8B) && (functionPtr[0x01] == 0x05) && // mov eax,dword ptr [uxtheme!g_preferredAppMode] (functionPtr[0x06] == 0x87) && (functionPtr[0x07] == 0x0D) && // xchg ecx,dword ptr [uxtheme!g_preferredAppMode] (functionPtr[0x0C] == 0xC3); // ret +#elif defined(_M_ARM64) + /* Not implemented yet */ + functionPtr; /* to prevent: warning C4100: 'functionPtr': unreferenced formal parameter */ + return FALSE; #else #error Unsupported processor type #endif