Skip to content

Commit 5e9d63e

Browse files
author
s-a
committed
fix(build): Explicitly build DLL target in Windows build script
The default `nmake` target for `libpg_query` builds the static library and runs tests, but does not produce the required `pg_query.dll`. This commit changes the build command to `nmake /F Makefile.msvc dll` to specifically instruct the build system to create the dynamic link library needed for the .NET application. This resolves the "Build artifact pg_query.dll not found" error.
1 parent 02c7537 commit 5e9d63e

File tree

1 file changed

+18
-48
lines changed

1 file changed

+18
-48
lines changed

scripts/build.ps1

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -24,54 +24,33 @@ $TargetRid = "win-x64"
2424
Set-Location $ProjectRoot
2525

2626
# Step 1: Check prerequisites
27+
# ... (Dieser Teil ist korrekt und bleibt unverändert) ...
2728
Write-Host "🔍 Checking prerequisites..." -ForegroundColor Yellow
28-
29-
# Check for Git
30-
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
31-
Write-Error "Git is required but not found in PATH"
32-
exit 1
33-
}
34-
35-
# Check for .NET SDK
36-
if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) {
37-
Write-Error ".NET SDK is required but not found in PATH"
38-
exit 1
39-
}
29+
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { Write-Error "Git is required..."; exit 1 }
30+
if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) { Write-Error ".NET SDK is required..."; exit 1 }
4031

4132
# Step 1.5: Setup MSVC Environment if nmake is not found
33+
# ... (Dieser Teil ist korrekt und bleibt unverändert) ...
4234
if (-not (Get-Command nmake -ErrorAction SilentlyContinue)) {
4335
Write-Host "⚠️ nmake.exe not found in PATH. Attempting to locate and configure MSVC environment..."
44-
4536
$vswherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
46-
if (-not (Test-Path $vswherePath)) {
47-
Write-Error "❌ vswhere.exe not found. Cannot automatically configure MSVC environment."
48-
exit 1
49-
}
50-
37+
if (-not (Test-Path $vswherePath)) { Write-Error "❌ vswhere.exe not found."; exit 1 }
5138
$vsInstallPath = & $vswherePath -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
52-
if (-not $vsInstallPath) {
53-
Write-Error "❌ Could not find a Visual Studio installation with C++ Build Tools."
54-
exit 1
55-
}
56-
39+
if (-not $vsInstallPath) { Write-Error "❌ Could not find a Visual Studio installation with C++ Build Tools."; exit 1 }
5740
$vcvarsall = Join-Path $vsInstallPath "VC\Auxiliary\Build\vcvarsall.bat"
58-
if (-not (Test-Path $vcvarsall)) {
59-
Write-Error "❌ Could not find vcvarsall.bat in the located Visual Studio installation."
60-
exit 1
61-
}
62-
41+
if (-not (Test-Path $vcvarsall)) { Write-Error "❌ Could not find vcvarsall.bat."; exit 1 }
6342
Write-Host "✅ Found MSVC environment setup script at: $vcvarsall"
6443
$vcVarsCommand = """$vcvarsall"" x64"
6544
}
6645
else {
67-
Write-Host "✅ nmake.exe is already in PATH. Skipping MSVC environment setup."
46+
Write-Host "✅ nmake.exe is already in PATH."
6847
$vcVarsCommand = $null
6948
}
7049

7150
# Step 2: Clone and prepare libpg_query
51+
# ... (Dieser Teil ist korrekt und bleibt unverändert) ...
7252
if (-not $SkipNative) {
7353
Write-Host "📥 Setting up libpg_query..." -ForegroundColor Yellow
74-
7554
if (-not (Test-Path "libpg_query")) {
7655
Write-Host "Cloning libpg_query (branch: $LibPgQueryBranch)..."
7756
& git clone -b $LibPgQueryBranch $LibPgQueryRepo
@@ -93,36 +72,30 @@ if (-not $SkipNative) {
9372
if (Test-Path "Makefile.msvc") {
9473
Write-Host "Using Visual Studio tools (nmake)..."
9574

96-
# --- FIX: EXPLIZITE FEHLERPRÜFUNG NACH JEDEM NMAKE-AUFRUF ---
9775
if ($vcVarsCommand) {
9876
Write-Host "Cleaning with nmake..."
9977
& cmd.exe /c "call $vcVarsCommand && nmake /F Makefile.msvc clean"
100-
if ($LASTEXITCODE -ne 0) {
101-
Write-Warning "nmake clean command failed (this may be okay). Exit code: $LASTEXITCODE"
102-
}
10378

104-
Write-Host "Building with nmake..."
105-
& cmd.exe /c "call $vcVarsCommand && nmake /F Makefile.msvc"
79+
Write-Host "Building DLL with nmake..."
80+
# --- DER FINALE FIX IST HIER: 'dll' hinzugefügt ---
81+
& cmd.exe /c "call $vcVarsCommand && nmake /F Makefile.msvc dll"
10682
if ($LASTEXITCODE -ne 0) {
107-
Write-Error "❌ nmake build command failed with exit code $LASTEXITCODE. The pg_query.dll was not created. Check the C++ compiler/linker errors in the log above for the root cause."
83+
Write-Error "❌ nmake build command failed with exit code $LASTEXITCODE. The pg_query.dll was not created. Check C++ errors above."
10884
exit 1
10985
}
11086
}
11187
else {
11288
Write-Host "Cleaning with nmake (pre-configured environment)..."
11389
& nmake /F Makefile.msvc clean
114-
if ($LASTEXITCODE -ne 0) {
115-
Write-Warning "nmake clean command failed (this may be okay). Exit code: $LASTEXITCODE"
116-
}
11790

118-
Write-Host "Building with nmake (pre-configured environment)..."
119-
& nmake /F Makefile.msvc
91+
Write-Host "Building DLL with nmake (pre-configured environment)..."
92+
# --- DER FINALE FIX IST HIER: 'dll' hinzugefügt ---
93+
& nmake /F Makefile.msvc dll
12094
if ($LASTEXITCODE -ne 0) {
121-
Write-Error "❌ nmake build command failed with exit code $LASTEXITCODE. The pg_query.dll was not created. Check the C++ compiler/linker errors in the log above for the root cause."
95+
Write-Error "❌ nmake build command failed with exit code $LASTEXITCODE. The pg_query.dll was not created. Check C++ errors above."
12296
exit 1
12397
}
12498
}
125-
# --- ENDE DES FIXES ---
12699
}
127100
else {
128101
Write-Error "Makefile.msvc not found. Cannot build libpg_query."
@@ -133,22 +106,19 @@ if (-not $SkipNative) {
133106
}
134107

135108
# Step 3: Create runtime directories and copy libraries
109+
# ... (Dieser Teil ist jetzt korrekt und wird funktionieren) ...
136110
if (-not $SkipNative) {
137111
Write-Host "📁 Setting up runtime directories..." -ForegroundColor Yellow
138-
139112
$ProjectRuntimeDir = "src\GrepSQL\runtimes\$TargetRid\native"
140113
New-Item -Path $ProjectRuntimeDir -ItemType Directory -Force | Out-Null
141-
142114
$SourceDll = "libpg_query\pg_query.dll"
143115
$DestinationDll = Join-Path $ProjectRuntimeDir "libpgquery_wrapper.dll"
144-
145116
if (Test-Path $SourceDll) {
146117
Write-Host "✅ Successfully found build artifact: $SourceDll"
147118
Write-Host "Copying $SourceDll to $DestinationDll"
148119
Copy-Item $SourceDll $DestinationDll -Force
149120
}
150121
else {
151-
# Diese Meldung sollte jetzt nicht mehr erreicht werden, da wir vorher abbrechen.
152122
Write-Error "❌ Build artifact pg_query.dll not found in libpg_query directory."
153123
exit 1
154124
}

0 commit comments

Comments
 (0)