PowerShell/Scripts/build-repo.ps1

47 lines
1.4 KiB
PowerShell
Raw Normal View History

2021-04-14 17:50:35 +02:00
#!/usr/bin/pwsh
<#
.SYNTAX build-repo.ps1 [<repo-dir>]
.DESCRIPTION builds the current/given Git repository
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($RepoDir = "$PWD")
try {
2021-04-14 19:23:34 +02:00
if (test-path "$RepoDir/CMakeLists.txt") {
2021-04-14 17:50:35 +02:00
"Building $RepoDir using CMakeLists.txt..."
2021-04-14 19:23:34 +02:00
if (-not(test-path "$RepoDir/CMakeBuild") {
& mkdir "$RepoDir/CMakeBuild/"
}
set-location "$RepoDir/CMakeBuild/"
2021-04-14 17:50:35 +02:00
2021-04-14 19:01:47 +02:00
& cmake ..
if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" }
& make -j4
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
} elseif (test-path "$RepoDir/Makefile") {
2021-04-14 17:50:35 +02:00
"Building $RepoDir using Makefile..."
2021-04-14 19:23:34 +02:00
set-location "$RepoDir/"
2021-04-14 19:01:47 +02:00
& make -j4
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
2021-04-14 19:23:34 +02:00
} elseif (test-path "$RepoDir/attower/src/build/DevBuild/build-all-release.bat") {
"Building $RepoDir using build-all-release.bat..."
set-location "$RepoDir/attower/src/build/DevBuild/"
& build-all-release.bat
if ($lastExitCode -ne "0") { throw "Script 'build-all-release.bat' returned error(s)" }
2021-04-14 17:50:35 +02:00
} else {
write-warning "Sorry, no clue how to build $RepoDir"
2021-04-14 19:01:47 +02:00
exit 0
2021-04-14 17:50:35 +02:00
}
write-host -foregroundColor green "OK - built Git repository $RepoDir"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}