-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake.ps1
78 lines (67 loc) · 2 KB
/
make.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
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
Param(
[Parameter(Position=0, HelpMessage="The action to take (build, test, install, package, clean).")]
[string]
$Command = 'build',
[Parameter(HelpMessage="The build configuration (Release, Debug).")]
[string]
$Config = "Release"
)
$ErrorActionPreference = "Stop"
$target = "lori"
$testPath = "."
$rootDir = Split-Path $script:MyInvocation.MyCommand.Path
$srcDir = Join-Path -Path $rootDir -ChildPath $target
if ($Config -ieq "Release")
{
$configFlag = ""
$buildDir = Join-Path -Path $rootDir -ChildPath "build/release"
}
elseif ($Config -ieq "Debug")
{
$configFlag = "--debug"
$buildDir = Join-Path -Path $rootDir -ChildPath "build/debug"
}
else
{
throw "Invalid -Config path '$Config'; must be one of (Debug, Release)."
}
$ponyArgs = "--path $rootDir"
function BuildTest
{
$testTarget = "$target.exe"
$testFile = Join-Path -Path $buildDir -ChildPath $testTarget
$testTimestamp = [DateTime]::MinValue
if (Test-Path $testFile)
{
$testTimestamp = (Get-ChildItem -Path $testFile).LastWriteTimeUtc
}
:testFiles foreach ($file in (Get-ChildItem -Path $srcDir -Include "*.pony" -Recurse))
{
if ($testTimestamp -lt $file.LastWriteTimeUtc)
{
Write-Host "corral fetch"
$output = (corral fetch)
$output | ForEach-Object { Write-Host $_ }
if ($LastExitCode -ne 0) { throw "Error" }
$testDir = Join-Path -Path $srcDir -ChildPath $testPath
Write-Host "corral run -- ponyc $configFlag $ponyArgs --output `"$buildDir`" `"$testDir`""
$output = (corral run -- ponyc $configFlag $ponyArgs --output "$buildDir" "$testDir")
$output | ForEach-Object { Write-Host $_ }
if ($LastExitCode -ne 0) { throw "Error" }
break testFiles
}
}
Write-Output "$testTarget.exe is built" # force function to return a list of outputs
return $testFile
}
switch ($Command.ToLower())
{
"test"
{
$testFile = (BuildTest)[-1]
Write-Host "$testFile --sequential"
& "$testFile"
if ($LastExitCode -ne 0) { throw "Error" }
break
}
}