Skip to content

Commit

Permalink
Add build script for ARM64X redirection DLLs
Browse files Browse the repository at this point in the history
  • Loading branch information
driver1998 authored and lotem committed Feb 24, 2024
1 parent 2f48397 commit aa964f6
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ release-notes.html
*.7z
RELEASE_CHANGELOG.md
deps/
arm64x_wrapper/*.o
arm64x_wrapper/*.dll
arm64x_wrapper/*.ime
arm64x_wrapper/*.lib
arm64x_wrapper/*.exp
16 changes: 16 additions & 0 deletions arm64x_wrapper/WeaselIME_arm64.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
EXPORTS
ImeConversionList = weaselARM64.ime.ImeConversionList
ImeConfigure = weaselARM64.ime.ImeConfigure
ImeDestroy = weaselARM64.ime.ImeDestroy
ImeEscape = weaselARM64.ime.ImeEscape
ImeInquire = weaselARM64.ime.ImeInquire
ImeProcessKey = weaselARM64.ime.ImeProcessKey
ImeSelect = weaselARM64.ime.ImeSelect
ImeSetActiveContext = weaselARM64.ime.ImeSetActiveContext
ImeToAsciiEx = weaselARM64.ime.ImeToAsciiEx
NotifyIME = weaselARM64.ime.NotifyIME
ImeRegisterWord = weaselARM64.ime.ImeRegisterWord
ImeUnregisterWord = weaselARM64.ime.ImeUnregisterWord
ImeGetRegisterWordStyle = weaselARM64.ime.ImeGetRegisterWordStyle
ImeEnumRegisterWord = weaselARM64.ime.ImeEnumRegisterWord
ImeSetCompositionString = weaselARM64.ime.ImeSetCompositionString
16 changes: 16 additions & 0 deletions arm64x_wrapper/WeaselIME_x64.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
EXPORTS
ImeConversionList = weaselx64.ime.ImeConversionList
ImeConfigure = weaselx64.ime.ImeConfigure
ImeDestroy = weaselx64.ime.ImeDestroy
ImeEscape = weaselx64.ime.ImeEscape
ImeInquire = weaselx64.ime.ImeInquire
ImeProcessKey = weaselx64.ime.ImeProcessKey
ImeSelect = weaselx64.ime.ImeSelect
ImeSetActiveContext = weaselx64.ime.ImeSetActiveContext
ImeToAsciiEx = weaselx64.ime.ImeToAsciiEx
NotifyIME = weaselx64.ime.NotifyIME
ImeRegisterWord = weaselx64.ime.ImeRegisterWord
ImeUnregisterWord = weaselx64.ime.ImeUnregisterWord
ImeGetRegisterWordStyle = weaselx64.ime.ImeGetRegisterWordStyle
ImeEnumRegisterWord = weaselx64.ime.ImeEnumRegisterWord
ImeSetCompositionString = weaselx64.ime.ImeSetCompositionString
5 changes: 5 additions & 0 deletions arm64x_wrapper/WeaselTSF_arm64.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
EXPORTS
DllGetClassObject = weaselARM64.dll.DllGetClassObject
DllCanUnloadNow = weaselARM64.dll.DllCanUnloadNow
DllRegisterServer = weaselARM64.dll.DllRegisterServer
DllUnregisterServer = weaselARM64.dll.DllUnregisterServer
5 changes: 5 additions & 0 deletions arm64x_wrapper/WeaselTSF_x64.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
EXPORTS
DllGetClassObject = weaselx64.dll.DllGetClassObject
DllCanUnloadNow = weaselx64.dll.DllCanUnloadNow
DllRegisterServer = weaselx64.dll.DllRegisterServer
DllUnregisterServer = weaselx64.dll.DllUnregisterServer
50 changes: 50 additions & 0 deletions arm64x_wrapper/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

@echo off
setlocal

call :find_toolchain
if errorlevel 1 exit /b 1

REM Build dummy object files
cl.exe /c /Fo:dummy.o dummy.c || exit /b 1
cl.exe /c /arm64EC /Fo:dummy_x64.o dummy.c || exit /b 1

REM Build weasel.dll wrapper
link.exe /lib /machine:x64 /def:WeaselTSF_x64.def /out:WeaselTSF_x64.lib /ignore:4104
link.exe /lib /machine:arm64 /def:WeaselTSF_arm64.def /out:WeaselTSF_arm64.lib /ignore:4104
link.exe /dll /noentry /machine:arm64x /defArm64Native:WeaselTSF_arm64.def /def:WeaselTSF_x64.def ^
/out:weaselARM64X.dll dummy.o dummy_x64.o WeaselTSF_x64.lib WeaselTSF_arm64.lib /ignore:4104

REM Build weasel.ime wrapper
link.exe /lib /machine:x64 /def:WeaselIME_x64.def /out:WeaselIME_x64.lib /ignore:4104
link.exe /lib /machine:arm64 /def:WeaselIME_arm64.def /out:WeaselIME_arm64.lib /ignore:4104
link.exe /dll /noentry /machine:arm64x /defArm64Native:WeaselIME_arm64.def /def:WeaselIME_x64.def ^
/out:weaselARM64X.ime dummy.o dummy_x64.o WeaselIME_x64.lib WeaselIME_arm64.lib /ignore:4104

endlocal
exit /b

:find_toolchain
set VSWHERE="%PROGRAMFILES%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist %VSWHERE% (
set VSWHERE="%PROGRAMFILES(X86)%\Microsoft Visual Studio\Installer\vswhere.exe"
)
if not exist %VSWHERE% (
echo vswhere not found, could not find a working MSVC install.
exit /b 1
)

for /f "usebackq tokens=*" %%i in (`%VSWHERE% -latest -requires Microsoft.VisualStudio.Component.VC.Tools.ARM64EC -property installationPath`) do (
set ARM64EC_TOOLCHAIN=%%i
)

if exist "%ARM64EC_TOOLCHAIN%\Common7\Tools\vsdevcmd.bat" (
call "%ARM64EC_TOOLCHAIN%\Common7\Tools\vsdevcmd.bat" -arch=arm64 -host_arch=x86
echo.
) else (
echo ARM64EC capable toolchain not found
exit /b 1
)

exit /b

1 change: 1 addition & 0 deletions arm64x_wrapper/dummy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This file is left blank on purpose to invoke the ARM64EC compiler and build ARM64EC thunks.
12 changes: 12 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ if errorlevel 1 goto error
msbuild.exe weasel.sln %build_option% /p:Configuration=%build_config% /p:Platform="Win32" /fl1
if errorlevel 1 goto error

if %build_arm64% == 1 (
pushd arm64x_wrapper
call build.bat
if errorlevel 1 goto error
popd

copy arm64x_wrapper\weaselARM64X.dll output
if errorlevel 1 goto error
copy arm64x_wrapper\weaselARM64X.ime output
if errorlevel 1 goto error
)

if %build_installer% == 1 (
"%ProgramFiles(x86)%"\NSIS\Bin\makensis.exe ^
/DWEASEL_VERSION=%WEASEL_VERSION% ^
Expand Down

0 comments on commit aa964f6

Please sign in to comment.