-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdelphi-build.yml
146 lines (109 loc) · 4.51 KB
/
delphi-build.yml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
parameters:
delphiVersion: ''
project: ''
appType: 'CONSOLE' # CONSOLE (default) or GUI
platform: 'x86'
searchPath: ''
unitScopes: 'System;System.Win;Vcl;WinApi'
fixPack: 'true'
preBuild: []
preBuildInline: ''
postBuild: []
postBuildInline: ''
steps:
- ${{ parameters.preBuild }}
- powershell: |
function CreateDir
{
param([string]$path)
if (-Not(Test-Path $path)) { New-Item $path -ItemType directory | Out-Null }
}
function Delete
{
param([string]$item)
if (Test-Path $item) { Remove-Item $item | Out-Null }
}
$dVer = '${{ parameters.delphiVersion }}'
$project = '${{ parameters.project }}'
$appType = '${{ parameters.appType }}'
$platform = '${{ parameters.platform }}'
$uses = '${{ parameters.searchPath }}'
$unitScopes = '${{ parameters.unitScopes }}'
$fixPack = '${{ parameters.fixPack }}'
$verbose = '${{ parameters.verbose }}'
# Human meaningful into useful
$bits = if($platform -eq 'x64') {'64'} else {'32'}
$verMap = @{ '2'=90; '3'=100; '4'=120; '5'=130; '6'=140; '7'=150;
'2005'=170; '2006'=180; '2007'=185; '2009'=200; '2010'=210;
'xe'=220; 'xe2'=230; 'xe3'=240; 'xe4'=250; 'xe5'=260; 'xe6'=270; 'xe7'=280; 'xe8'=290;
'10'=300; '10.1'=310; '10.2'=320; '10.3'=330; '10.4'=340 }
if ($verMap.ContainsKey($dVer)) { $d = $verMap[$dVer] }
else { Write-Host "##vso[task.logissue type=error]Delphi $dVer is not supported"
exit }
$dXE = 220
# Useful references
$cd = Get-Location
$bin = Join-Path $cd '\.bin'
$results = Join-Path $cd '\.results'
CreateDir('.bin')
CreateDir('.results')
$dprName = $(Split-Path -Leaf $project)
$dprPath = $(Split-Path -Path $project)
$cfg = $dprName + '.cfg'
$dpr = $dprName + '.dpr'
$exe = Join-Path $bin $($dprName + '.exe')
$dr = Join-Path 'c:\dcc' $dVer
$db = Join-Path $dr 'bin'
$dl = Join-Path $dr 'lib'
if (-Not(Test-Path $db)) {
Write-Host "##vso[task.complete result=Skipped;]Delphi $dVer not available on this machine."
exit }
# If an IDE FixPack compiler is found, use that instead.
$dcc = $db + '\dcc' + $bits + '.exe'
if($fixPack -eq 'true') {
Write-Host 'Checking for IDE FixPack compilers'
$dccSpeed = $db + '\dcc' + $bits + 'speed.exe'
$fastDcc = $db + '\fastdcc' + $bits + '.exe'
if (Test-Path $dccSpeed) { $dcc = $dccSpeed }
elseif (Test-Path $fastDcc) { $dcc = $fastDcc } }
# Setup lib and search path
if ($d -eq $dXE) { $dl = $dl + '\win32\release' }
elseif ($d -gt $dXE) { $dl = $dl + '\win' + $bits + '\release' }
$uses = $dl + ';' + $uses
Set-Location $dprPath
try {
# Remove any previous build and config
Delete($exe)
Delete($cfg)
Delete($('dcc' + $bits + '.cfg'))
New-Item $cfg -ItemType file | Out-Null
Add-Content $cfg $('-D' + $appType)
Add-Content $cfg $('-E' + $bin)
Add-Content $cfg $('-N' + $bin)
Add-Content $cfg $('-U' + $uses)
if ($d -gt $dXE) { Add-Content $cfg $('-NS' + $unitScopes) }
${{ parameters.preBuildInline }}
Write-Host $('Config [' + $cfg + ']:')
type $cfg
Copy-Item $cfg $("dcc$bits.cfg")
# Invoke the compiler
$cmd = $dcc + ' ' + $dpr
$out = 'dccoutput.txt'
if ($appType -eq 'CONSOLE') { $cmd = $cmd + ' -CC' }
Write-Host $(':>[' + $cmd + ']')
Invoke-Expression $cmd | Select-String -SimpleMatch -Pattern 'Fatal: ','Error: ','Hint: ','Warning: ' > $out
$hintsOrWarnings = $(Get-Item $out).length > 0
if ($hintsOrWarnings) { Write-Host 'Finished with hints/warnings:'; type $out } else { Write-Host 'Done' }
Delete($out)
}
finally { Set-Location $cd }
# Report outcome
if (Test-Path $exe) {
Move-Item $exe "$(Build.BinariesDirectory)"
if ( $hintsOrWarnings ) { Write-Host '##vso[task.logissue type=warning]Build completed with hints/warnings. :/' }
else { Write-Host '##vso[task.complete result=Succeeded;]Build completed OK. :)' }
${{ parameters.postBuildInline }} }
else { Write-Host '##vso[task.logissue type=error]Build failed. :('
exit 1 }
displayName: 'Delphi ${{ parameters.delphiVersion }} build (${{ parameters.platform }}) of ${{ parameters.project }}'
- ${{ parameters.postBuild }}