Skip to content
Open
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
25 changes: 20 additions & 5 deletions .github/ci-scripts/download_firebird_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ $assetNamePattern = "*-windows-x64.zip"

New-Item -Path $outputFolder -ItemType "Directory"

# Try with certificate check first, fallback to skipping if it fails
try {
$release = Invoke-RestMethod -Uri $repoApiUrl
$release = Invoke-RestMethod -Uri $repoApiUrl -SslProtocol Tls12
} catch {
Write-Error "Error get releases: $_"
exit
Write-Host "First attempt failed: $_"
Write-Host "Retrying with -SkipCertificateCheck..."
try {
$release = Invoke-RestMethod -Uri $repoApiUrl -SslProtocol Tls12 -SkipCertificateCheck
} catch {
Write-Error "Error get releases: $_"
exit
}
}

$asset = $release.assets | Where-Object { $_.name -like $assetNamePattern } | Select-Object -First 1
Expand All @@ -23,10 +30,18 @@ $outputPath = Join-Path $outputFolder $asset.name

Write-Host "Download $($asset.name)..."
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputPath
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputPath -SslProtocol Tls12
Write-Host "File successfully written: $outputPath"
} catch {
Write-Error "Error download file: $_"
Write-Host "Download with cert check failed: $_"
Write-Host "Retrying with -SkipCertificateCheck..."
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputPath -SslProtocol Tls12 -SkipCertificateCheck
Write-Host "File successfully written: $outputPath"
} catch {
Write-Error "Error download file: $_"
exit
}
}

Expand-Archive -Path $outputPath -DestinationPath $outputFolder -Force
Expand Down
72 changes: 48 additions & 24 deletions .github/workflows/testing_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,57 @@ jobs:
sudo mkdir -p /usr/local/lib
sudo ln -s /Library/Frameworks/Firebird.framework/Versions/A/Libraries/libfbclient.dylib /usr/local/lib/libfbclient.dylib

- name: Locating fbclient.lib Dir on Windows
- name: Locate and expose fbclient lib and dll (Windows)
if: matrix.plataform == 'windows'
shell: powershell
shell: pwsh
run: |
function Search-Common-Folders() {
param (
[string]$FileName
)
$WinSysDir = [Environment]::SystemDirectory
$CommonDirs = @(
"C:\Program Files\Firebird",
"C:\Firebird",
"${WinSysDir}"
)
Foreach ($folder in $CommonDirs) {
echo "# Finding relevant files in FirebirdSQL install:"
$found = Get-ChildItem -File -Recurse -Path $folder -Include $FileName -ea 0
Foreach ($source in $found) {
echo " - $source"
Copy-Item -Path $source
}
}
# Search common install locations for fbclient .lib/.dll (recursively)
$common = @(
"C:\Program Files\Firebird",
"C:\Firebird",
"$env:WINDIR\System32",
"$env:ProgramFiles(x86)\Firebird"
)

$foundLib = $null
foreach ($folder in $common) {
if (-not (Test-Path $folder)) { continue }
$foundLib = Get-ChildItem -Path $folder -Include "fbclient.lib","fbclient_ms.lib" -File -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
if ($foundLib) { break }
}

$foundDll = $null
foreach ($folder in $common) {
if (-not (Test-Path $folder)) { continue }
$foundDll = Get-ChildItem -Path $folder -Include "fbclient.dll" -File -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
if ($foundDll) { break }
}

if (-not $foundLib) {
Write-Error "fbclient .lib not found. Ensure Firebird is installed on the runner or the installer script places fbclient.lib in a known location."
exit 1
}

$libDir = Split-Path $foundLib.FullName -Parent
Write-Host "Found fbclient lib at: $($foundLib.FullName)"
echo "FBCLIENT_LIB_DIR=$libDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

# Prepend the found lib folder to LIB so MSVC linker finds the .lib import
$newLib = if ($env:LIB) { "$libDir;$env:LIB" } else { "$libDir" }
echo "LIB=$newLib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Added $libDir to LIB"

if ($foundDll) {
$dllDir = Split-Path $foundDll.FullName -Parent
Write-Host "Found fbclient dll at: $($foundDll.FullName)"
# Prepend dll dir to PATH for runtime resolution during tests
$newPath = if ($env:PATH) { "$dllDir;$env:PATH" } else { "$dllDir" }
echo "PATH=$newPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Added $dllDir to PATH"

# Optional: copy DLL to workspace to help runtime resolution if needed
Copy-Item -Path $foundDll.FullName -Destination $PWD -Force
}
Search-Common-Folders -FileName "fbclient.dll"
Search-Common-Folders -FileName "fbclient.lib"
Search-Common-Folders -FileName "fbclient_ms.lib"
Search-Common-Folders -FileName "isql.exe"

- name: Create a alias to test.fdb on fb v2
if: matrix.firebird == 'v2'
Expand Down
31 changes: 31 additions & 0 deletions rsfbclient-native/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ fn search_on_environment_var() -> bool {

if let Ok(user_specified_dir) = std::env::var("FBCLIENT_LIB_DIR") {
println!("cargo:rustc-link-search={}", user_specified_dir);

#[cfg(all(feature = "linking", target_os = "windows"))]
search_libname_on_windows(&user_specified_dir);

return false;
}
true
Expand Down Expand Up @@ -108,4 +112,31 @@ fn search_for_file(filename: &str) -> Option<std::path::PathBuf> {
None
}

#[cfg(all(feature = "linking", target_os = "windows"))]
fn search_libname_on_windows(dir: &str) {
let dir = std::path::Path::new(dir);
if dir.join("fbclient_ms.lib").exists() {
println!("cargo:rustc-link-lib=dylib=fbclient_ms");
} else if dir.join("fbclient.lib").exists() {
println!("cargo:rustc-link-lib=dylib=fbclient");
} else {
let pattern = format!("{}\\\\*.lib", dir.display());
let found = glob(&pattern).expect("Failed to read glob pattern");
for entry in found {
if let Ok(path) = entry {
if let Some(stem) = path.file_stem() {
if let Some(name) = stem.to_str() {
println!("cargo:rustc-link-lib=dylib={}", name);
return;
}
}
}
}
println!(
"cargo:warning=No .lib file found in FBCLIENT_LIB_DIR ({})",
dir.display()
);
}
}

// end of code
Loading