-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
33 lines (31 loc) · 863 Bytes
/
build.ps1
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
param(
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
[string[]]$files,
[switch]$force
)
if (-not $files.Length) {
$files = Get-ChildItem .\*.cpp
} else {
for ($i = 0; $i -lt $files.Length; $i += 1) {
if (!$files[$i].EndsWith('.cpp')) {
$files[$i] += '.cpp'
}
}
}
foreach ($file in $files) {
$cpptime = (Get-Item $file).LastWriteTimeUtc
$exename = $file -replace '\.cpp$','.exe'
if (Test-Path $exename) {
$exetime = (Get-Item $exename).LastWriteTimeUtc
if ($exetime -gt $cpptime) {
if ($force) {
Write-Output "Building $file even though $exename is newer."
} else {
Write-Output "Skipping $file because $exename is newer."
continue
}
}
}
cl.exe /nologo /EHsc /std:c++20 /O1 /MD /DNDEBUG /GF /GR- /GL $file
Remove-Item ($file -replace '\.cpp$','.obj')
}