mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
Implement alias handling for DLLs and headers
Added functions to copy DLL and header aliases for Enchant2 and other libraries, ensuring they are present in the specified directories.
This commit is contained in:
committed by
GitHub
parent
61da248c41
commit
069c6a3f81
162
.github/workflows/windows-build.yml
vendored
162
.github/workflows/windows-build.yml
vendored
@@ -113,6 +113,40 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Copy-AliasDll([string]$binDir, [string]$targetName, [string[]]$sourcePatterns) {
|
||||||
|
$target = Join-Path $binDir $targetName
|
||||||
|
if (Test-Path $target) { return }
|
||||||
|
|
||||||
|
$src = $null
|
||||||
|
foreach ($pat in $sourcePatterns) {
|
||||||
|
$src = Get-ChildItem -Path $binDir -File -Filter "*.dll" | Where-Object { $_.Name -match $pat } | Select-Object -First 1
|
||||||
|
if ($src) { break }
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($src) {
|
||||||
|
Copy-Item $src.FullName $target -Force
|
||||||
|
Write-Host "DLL Alias: $targetName <= $($src.Name)"
|
||||||
|
} else {
|
||||||
|
Write-Host "DLL alias not created: $targetName (no match in $binDir)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Ensure-HeaderAlias([string]$incRoot, [string]$targetName, [string[]]$relativeCandidates) {
|
||||||
|
$target = Join-Path $incRoot $targetName
|
||||||
|
if (Test-Path $target) { return }
|
||||||
|
|
||||||
|
foreach ($rel in $relativeCandidates) {
|
||||||
|
$src = Join-Path $incRoot $rel
|
||||||
|
if (Test-Path $src) {
|
||||||
|
Copy-Item $src $target -Force
|
||||||
|
Write-Host "Header Alias: $targetName <= $rel"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Header alias not created: $targetName (no candidate found under $incRoot)"
|
||||||
|
}
|
||||||
|
|
||||||
function Ensure-GlibGenmarshalWrapper([string]$gtkBin) {
|
function Ensure-GlibGenmarshalWrapper([string]$gtkBin) {
|
||||||
$wrapperPath = Join-Path $gtkBin "glib-genmarshal"
|
$wrapperPath = Join-Path $gtkBin "glib-genmarshal"
|
||||||
$exePath = Join-Path $gtkBin "glib-genmarshal.exe"
|
$exePath = Join-Path $gtkBin "glib-genmarshal.exe"
|
||||||
@@ -434,6 +468,71 @@ jobs:
|
|||||||
Write-Host "Generated libjpeg.lib from $($dll.Name) => $want"
|
Write-Host "Generated libjpeg.lib from $($dll.Name) => $want"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Ensure-Enchant2([string]$gtkPrefix, [string]$wantArch) {
|
||||||
|
$inc = Join-Path $gtkPrefix "include"
|
||||||
|
$bin = Join-Path $gtkPrefix "bin"
|
||||||
|
$lib = Join-Path $gtkPrefix "lib"
|
||||||
|
|
||||||
|
$hasHeader = (Test-Path (Join-Path $inc "enchant-2\enchant-provider.h")) -or (Test-Path (Join-Path $inc "enchant-provider.h"))
|
||||||
|
$hasDll = (Get-ChildItem -Path $bin -File -Filter "libenchant*.dll" -ErrorAction SilentlyContinue | Select-Object -First 1) -ne $null
|
||||||
|
$hasLib = (Get-ChildItem -Path $lib -File -Filter "libenchant*.lib" -ErrorAction SilentlyContinue | Select-Object -First 1) -ne $null
|
||||||
|
|
||||||
|
if ($hasHeader -and $hasDll -and $hasLib) { return }
|
||||||
|
|
||||||
|
Write-Host "Enchant2 not fully present in GTK prefix; attempting to build via gvsbuild and merge..."
|
||||||
|
|
||||||
|
$gvsDir = "C:\gtk-build\github\gvsbuild"
|
||||||
|
if (-not (Test-Path $gvsDir)) {
|
||||||
|
New-Item -Path "C:\gtk-build\github" -ItemType Directory -Force | Out-Null
|
||||||
|
git clone --depth 1 https://github.com/wingtk/gvsbuild.git $gvsDir
|
||||||
|
}
|
||||||
|
|
||||||
|
Push-Location $gvsDir
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install -r requirements.txt
|
||||||
|
|
||||||
|
$built = $false
|
||||||
|
foreach ($mod in @("enchant", "enchant2")) {
|
||||||
|
try {
|
||||||
|
Write-Host "Trying gvsbuild module: $mod"
|
||||||
|
python .\build.py build -p=$wantArch --vs-ver=16 --msys-dir=C:\tools\msys64 -c=release $mod
|
||||||
|
$built = $true
|
||||||
|
break
|
||||||
|
} catch {
|
||||||
|
Write-Host "Module $mod failed: $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Pop-Location
|
||||||
|
|
||||||
|
if (-not $built) {
|
||||||
|
throw "Could not build Enchant via gvsbuild (tried: enchant, enchant2)."
|
||||||
|
}
|
||||||
|
|
||||||
|
$srcPrefix = "C:\gtk-build\gtk\$wantArch\release"
|
||||||
|
if (-not (Test-Path $srcPrefix)) { throw "Expected gvsbuild prefix not found: $srcPrefix" }
|
||||||
|
|
||||||
|
# Merge headers
|
||||||
|
if (Test-Path (Join-Path $srcPrefix "include\enchant-2")) {
|
||||||
|
New-Item -Path (Join-Path $inc "enchant-2") -ItemType Directory -Force | Out-Null
|
||||||
|
Copy-Item (Join-Path $srcPrefix "include\enchant-2\*") (Join-Path $inc "enchant-2") -Recurse -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# Merge libs/dlls
|
||||||
|
Copy-Item (Join-Path $srcPrefix "bin\libenchant*.dll") $bin -Force -ErrorAction SilentlyContinue
|
||||||
|
Copy-Item (Join-Path $srcPrefix "lib\libenchant*.lib") $lib -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
# Re-evaluate
|
||||||
|
$hasHeader = (Test-Path (Join-Path $inc "enchant-2\enchant-provider.h")) -or (Test-Path (Join-Path $inc "enchant-provider.h"))
|
||||||
|
$hasDll = (Get-ChildItem -Path $bin -File -Filter "libenchant*.dll" -ErrorAction SilentlyContinue | Select-Object -First 1) -ne $null
|
||||||
|
$hasLib = (Get-ChildItem -Path $lib -File -Filter "libenchant*.lib" -ErrorAction SilentlyContinue | Select-Object -First 1) -ne $null
|
||||||
|
|
||||||
|
if (-not ($hasHeader -and $hasDll -and $hasLib)) {
|
||||||
|
throw "Enchant2 still missing after gvsbuild merge. Header/DLL/LIB present? $hasHeader / $hasDll / $hasLib"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Enchant2 merged into GTK prefix."
|
||||||
|
}
|
||||||
|
|
||||||
# ------------------------------------------
|
# ------------------------------------------
|
||||||
# GTK: Prefer prebuilt wingtk/gvsbuild GTK3 bundles.
|
# GTK: Prefer prebuilt wingtk/gvsbuild GTK3 bundles.
|
||||||
# If missing for x86 (win32), build GTK3 via gvsbuild from source.
|
# If missing for x86 (win32), build GTK3 via gvsbuild from source.
|
||||||
@@ -534,6 +633,24 @@ jobs:
|
|||||||
# Ensure libjpeg.lib exists (some bundles ship jpeg.lib / libjpeg-8.lib or only DLL).
|
# Ensure libjpeg.lib exists (some bundles ship jpeg.lib / libjpeg-8.lib or only DLL).
|
||||||
Ensure-LibJpeg $gtkLib $gtkBin $wantPlat
|
Ensure-LibJpeg $gtkLib $gtkBin $wantPlat
|
||||||
|
|
||||||
|
# Ensure Enchant2 (needed by libenchant_win8 project + packaging expectations).
|
||||||
|
Ensure-Enchant2 $normRel $wantArch
|
||||||
|
|
||||||
|
# Header aliases for projects that include flat names (quotes) instead of subdir includes.
|
||||||
|
Ensure-HeaderAlias $gtkInc "enchant-provider.h" @("enchant-2\enchant-provider.h", "enchant\enchant-provider.h")
|
||||||
|
Ensure-HeaderAlias $gtkInc "hb.h" @("harfbuzz\hb.h")
|
||||||
|
Ensure-HeaderAlias $gtkInc "hb-ot.h" @("harfbuzz\hb-ot.h")
|
||||||
|
|
||||||
|
# DLL aliases to satisfy win32\copy\copy.vcxproj (it expects older names).
|
||||||
|
Copy-AliasDll $gtkBin "freetype.dll" @('^freetype\.dll$', '^libfreetype-6\.dll$', '^libfreetype.*\.dll$')
|
||||||
|
Copy-AliasDll $gtkBin "fontconfig.dll" @('^fontconfig\.dll$', '^libfontconfig-1\.dll$', '^libfontconfig.*\.dll$')
|
||||||
|
Copy-AliasDll $gtkBin "gdk-win32-2.0.dll" @('^gdk-3-0\.dll$', '^libgdk-3-0\.dll$', '^gdk-3.*\.dll$')
|
||||||
|
Copy-AliasDll $gtkBin "gtk-win32-2.0.dll" @('^gtk-3-0\.dll$', '^libgtk-3-0\.dll$', '^gtk-3.*\.dll$')
|
||||||
|
Copy-AliasDll $gtkBin "libenchant.dll" @('^libenchant-2\.dll$', '^libenchant-2-2\.dll$', '^libenchant.*\.dll$')
|
||||||
|
Copy-AliasDll $gtkBin "ffi-7.dll" @('^ffi-7\.dll$', '^libffi-7\.dll$', '^libffi-8\.dll$', '^ffi-8\.dll$', '^libffi-.*\.dll$')
|
||||||
|
Copy-AliasDll $gtkBin "libxml2.dll" @('^libxml2\.dll$', '^libxml2-2\.dll$', '^libxml2-2-2\.dll$', '^xml2\.dll$', '^libxml2.*\.dll$')
|
||||||
|
Copy-AliasDll $gtkBin "cairo.dll" @('^cairo\.dll$', '^libcairo-2\.dll$', '^libcairo.*\.dll$')
|
||||||
|
|
||||||
# Compatibility aliases for differing .lib names across bundles.
|
# Compatibility aliases for differing .lib names across bundles.
|
||||||
Copy-AliasLib $gtkLib "gtk-3.0.lib" @(
|
Copy-AliasLib $gtkLib "gtk-3.0.lib" @(
|
||||||
'^gtk-3-0\.lib$',
|
'^gtk-3-0\.lib$',
|
||||||
@@ -618,6 +735,51 @@ jobs:
|
|||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
rem Make MSVC find hb.h and enchant-provider.h (they live in subdirs under include\)
|
||||||
|
set "INCLUDE=%GTKROOT%\include\harfbuzz;%GTKROOT%\include\enchant-2;%GTKROOT%\include\freetype2;%INCLUDE%"
|
||||||
|
|
||||||
|
rem Sanity: these are expected by win32\copy\copy.vcxproj
|
||||||
|
if not exist "%GTKROOT%\bin\freetype.dll" (
|
||||||
|
echo Missing freetype.dll under %GTKROOT%\bin
|
||||||
|
dir "%GTKROOT%\bin"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
if not exist "%GTKROOT%\bin\fontconfig.dll" (
|
||||||
|
echo Missing fontconfig.dll under %GTKROOT%\bin
|
||||||
|
dir "%GTKROOT%\bin"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
if not exist "%GTKROOT%\bin\gdk-win32-2.0.dll" (
|
||||||
|
echo Missing gdk-win32-2.0.dll under %GTKROOT%\bin
|
||||||
|
dir "%GTKROOT%\bin"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
if not exist "%GTKROOT%\bin\gtk-win32-2.0.dll" (
|
||||||
|
echo Missing gtk-win32-2.0.dll under %GTKROOT%\bin
|
||||||
|
dir "%GTKROOT%\bin"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
if not exist "%GTKROOT%\bin\libenchant.dll" (
|
||||||
|
echo Missing libenchant.dll under %GTKROOT%\bin
|
||||||
|
dir "%GTKROOT%\bin"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
if not exist "%GTKROOT%\bin\ffi-7.dll" (
|
||||||
|
echo Missing ffi-7.dll under %GTKROOT%\bin
|
||||||
|
dir "%GTKROOT%\bin"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
if not exist "%GTKROOT%\bin\libxml2.dll" (
|
||||||
|
echo Missing libxml2.dll under %GTKROOT%\bin
|
||||||
|
dir "%GTKROOT%\bin"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
if not exist "%GTKROOT%\bin\cairo.dll" (
|
||||||
|
echo Missing cairo.dll under %GTKROOT%\bin
|
||||||
|
dir "%GTKROOT%\bin"
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
set "PATH=%PERL_BIN%;%GTKROOT%\bin;%PATH%"
|
set "PATH=%PERL_BIN%;%GTKROOT%\bin;%PATH%"
|
||||||
set "LIB=%GTKROOT%\lib;%LIB%"
|
set "LIB=%GTKROOT%\lib;%LIB%"
|
||||||
set "INCLUDE=%GTKROOT%\include;%INCLUDE%"
|
set "INCLUDE=%GTKROOT%\include;%INCLUDE%"
|
||||||
|
|||||||
Reference in New Issue
Block a user