-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathbuild.ps1
More file actions
60 lines (49 loc) · 1.87 KB
/
build.ps1
File metadata and controls
60 lines (49 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
param(
[string]$Preset = ""
)
# Determine preset based on argument or auto-detect
if ($Preset -eq "") {
# Auto-detect architecture
$Arch = $env:PROCESSOR_ARCHITECTURE
if ($Arch -eq "AMD64" -or $Arch -eq "x64") {
$Preset = "windows-x64-release"
}
else {
$Preset = "windows-x86-release"
}
}
Write-Host "Using preset: $Preset"
# Validate preset exists
$presetsContent = Get-Content -Path "CMakePresets.json" -Raw
if ($presetsContent -notmatch "`"name`":\s*`"$Preset`"") {
Write-Error "ERROR: Preset '$Preset' not found in CMakePresets.json"
Write-Host "Available Windows presets: windows-x86-release, windows-x64-release"
exit 1
}
# Install vcpkg if not present
$vcpkgPath = "$env:USERPROFILE\vcpkg"
if (-not (Test-Path $vcpkgPath)) {
Write-Host "vcpkg not found. Installing..."
git clone https://github.com/Microsoft/vcpkg.git $vcpkgPath
& "$vcpkgPath\bootstrap-vcpkg.bat"
}
# Determine build directory from preset
$buildDir = ($presetsContent | Select-String -Pattern "`"name`":\s*`"$Preset`"[\s\S]*?`"binaryDir`":\s*`"`\`${sourceDir}/([^`"]+)`"" |
ForEach-Object { $_.Matches.Groups[1].Value })
# Clean any partial build artifacts
if ($buildDir -and (Test-Path $buildDir)) {
Write-Host "Cleaning previous build artifacts in $buildDir..."
Remove-Item -Path "$buildDir\CMakeCache.txt" -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$buildDir\CMakeFiles" -Recurse -Force -ErrorAction SilentlyContinue
}
$env:VCPKG_ROOT = $vcpkgPath
Write-Host ""
Write-Host "=== Building MySQLOO with preset: $Preset ==="
Write-Host "This may take several minutes on first run as vcpkg builds dependencies from source..."
Write-Host ""
cmake --preset $Preset
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cmake --build --preset $Preset
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Write-Host ""
Write-Host "Build complete!"