diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml
index d4b9316ef1a2..89c13959e8cb 100644
--- a/.github/workflows/win.yml
+++ b/.github/workflows/win.yml
@@ -60,7 +60,7 @@ jobs:
run: .\etc\win-ci\build-iconv.ps1 -BuildTree deps\iconv -Version 1.17
- name: Build libffi
if: steps.cache-libs.outputs.cache-hit != 'true'
- run: .\etc\win-ci\build-ffi.ps1 -BuildTree deps\ffi -Version 3.3
+ run: .\etc\win-ci\build-ffi.ps1 -BuildTree deps\ffi -Version 3.4.6
- name: Build zlib
if: steps.cache-libs.outputs.cache-hit != 'true'
run: .\etc\win-ci\build-z.ps1 -BuildTree deps\z -Version 1.3.1
@@ -148,7 +148,7 @@ jobs:
run: .\etc\win-ci\build-iconv.ps1 -BuildTree deps\iconv -Version 1.17 -Dynamic
- name: Build libffi
if: steps.cache-dlls.outputs.cache-hit != 'true'
- run: .\etc\win-ci\build-ffi.ps1 -BuildTree deps\ffi -Version 3.3 -Dynamic
+ run: .\etc\win-ci\build-ffi.ps1 -BuildTree deps\ffi -Version 3.4.6 -Dynamic
- name: Build zlib
if: steps.cache-dlls.outputs.cache-hit != 'true'
run: .\etc\win-ci\build-z.ps1 -BuildTree deps\z -Version 1.3.1 -Dynamic
diff --git a/etc/win-ci/build-ffi.ps1 b/etc/win-ci/build-ffi.ps1
index 4340630bea64..eb5ec1e5403c 100644
--- a/etc/win-ci/build-ffi.ps1
+++ b/etc/win-ci/build-ffi.ps1
@@ -7,40 +7,17 @@ param(
. "$(Split-Path -Parent $MyInvocation.MyCommand.Path)\setup.ps1"
[void](New-Item -Name (Split-Path -Parent $BuildTree) -ItemType Directory -Force)
-Setup-Git -Path $BuildTree -Url https://github.com/winlibs/libffi.git -Ref libffi-$Version
+Setup-Git -Path $BuildTree -Url https://github.com/crystal-lang/libffi.git -Ref v$Version
Run-InDirectory $BuildTree {
+ $args = "-DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF"
if ($Dynamic) {
- Replace-Text win32\vs16_x64\libffi\libffi.vcxproj 'StaticLibrary' 'DynamicLibrary'
+ $args = "-DBUILD_SHARED_LIBS=ON $args"
+ } else {
+ $args = "-DBUILD_SHARED_LIBS=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded $args"
}
-
- echo '
-
- $(MsbuildThisFileDirectory)\Override.props
-
- ' > 'Directory.Build.props'
-
- echo "
-
- false
-
-
-
- $(if ($Dynamic) {
- 'FFI_BUILDING_DLL;%(PreprocessorDefinitions)'
- } else {
- 'MultiThreaded'
- })
- None
- false
-
-
- false
-
-
- " > 'Override.props'
-
- MSBuild.exe /p:PlatformToolset=v143 /p:Platform=x64 /p:Configuration=Release win32\vs16_x64\libffi-msvc.sln -target:libffi:Rebuild
+ & $cmake . $args.split(' ')
+ & $cmake --build . --config Release
if (-not $?) {
Write-Host "Error: Failed to build libffi" -ForegroundColor Red
Exit 1
@@ -48,8 +25,8 @@ Run-InDirectory $BuildTree {
}
if ($Dynamic) {
- mv -Force $BuildTree\win32\vs16_x64\x64\Release\libffi.lib libs\ffi-dynamic.lib
- mv -Force $BuildTree\win32\vs16_x64\x64\Release\libffi.dll dlls\
+ mv -Force $BuildTree\Release\libffi.lib libs\ffi-dynamic.lib
+ mv -Force $BuildTree\Release\libffi.dll dlls\
} else {
- mv -Force $BuildTree\win32\vs16_x64\x64\Release\libffi.lib libs\ffi.lib
+ mv -Force $BuildTree\Release\libffi.lib libs\ffi.lib
}