Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use our own libffi repository on Windows CI #14998

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: .\etc\win-ci\build-iconv.ps1 -BuildTree deps\iconv
- 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
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
run: .\etc\win-ci\build-iconv.ps1 -BuildTree deps\iconv -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
Expand Down
43 changes: 10 additions & 33 deletions etc/win-ci/build-ffi.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,26 @@ 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 '<Project>
<PropertyGroup>
<ForceImportAfterCppTargets>$(MsbuildThisFileDirectory)\Override.props</ForceImportAfterCppTargets>
</PropertyGroup>
</Project>' > 'Directory.Build.props'

echo "<Project>
<PropertyGroup>
<WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
$(if ($Dynamic) {
'<PreprocessorDefinitions>FFI_BUILDING_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>'
} else {
'<RuntimeLibrary>MultiThreaded</RuntimeLibrary>'
})
<DebugInformationFormat>None</DebugInformationFormat>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
</Project>" > '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
}
}

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
}
Loading