Repository navigation
Expand file tree
/
Copy pathbuild.ps1
More file actions
92 lines (63 loc) · 2.19 KB
/
Copy pathbuild.ps1
File metadata and controls
92 lines (63 loc) · 2.19 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
$ErrorActionPreference = "Stop"
$Root = $PSScriptRoot
$Source = Join-Path $Root "src\clickphp.d"
$BuildDir = Join-Path $Root "build"
$BuildExe = Join-Path $BuildDir "clickphp.exe"
$BuildConfig = Join-Path $BuildDir "clickphp.ini"
$BuildConfigExample = Join-Path $BuildDir "clickphp.ini.example"
$ReleaseDir = Join-Path $Root "release"
$ReleaseExe = Join-Path $ReleaseDir "clickphp.exe"
Write-Host "Building ClickPHP..."
Write-Host ""
New-Item -ItemType Directory -Force -Path $BuildDir | Out-Null
New-Item -ItemType Directory -Force -Path $ReleaseDir | Out-Null
# ------------------------------------------------------------
# Development configuration
# ------------------------------------------------------------
if (-not (Test-Path $BuildConfig)) {
if (-not (Test-Path $BuildConfigExample)) {
throw "Development configuration template not found: $BuildConfigExample"
}
Copy-Item $BuildConfigExample $BuildConfig
Write-Host "Development configuration created:"
Write-Host $BuildConfig
Write-Host ""
Write-Host "Configure your PHP executable and run build.ps1 again."
exit 0
}
# ------------------------------------------------------------
# Compile
# ------------------------------------------------------------
Remove-Item $BuildExe -Force -ErrorAction SilentlyContinue
Push-Location (Join-Path $Root "src")
try {
dmd -O -release -of="$BuildExe" "$Source"
if ($LASTEXITCODE -ne 0) {
throw "DMD compilation failed."
}
Remove-Item "clickphp.obj" -Force -ErrorAction SilentlyContinue
}
finally {
Pop-Location
}
Write-Host "Build complete:"
Write-Host $BuildExe
# ------------------------------------------------------------
# Verify
# ------------------------------------------------------------
Write-Host ""
Write-Host "Testing build..."
Write-Host ""
& $BuildExe --help
if ($LASTEXITCODE -ne 0) {
throw "ClickPHP test failed."
}
Write-Host ""
Write-Host "Build verified successfully."
# ------------------------------------------------------------
# Release
# ------------------------------------------------------------
Copy-Item $BuildExe $ReleaseExe -Force
Write-Host ""
Write-Host "Release executable updated:"
Write-Host $ReleaseExe