Add build-repo.ps1

This commit is contained in:
Markus Fleschutz
2021-04-14 17:50:35 +02:00
parent 980a169bfc
commit f9a479b0f9
4 changed files with 35 additions and 2 deletions

31
Scripts/build-repo.ps1 Executable file
View File

@ -0,0 +1,31 @@
#!/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 {
if (test-path CMakeLists.txt) {
"Building $RepoDir using CMakeLists.txt..."
& cmake .
if ($lastExitCode -ne "0") { throw "Can't execute 'cmake .'" }
& make
if ($lastExitCode -ne "0") { throw "Can't execute 'make .'" }
} elseif (test-path Makefile) {
"Building $RepoDir using Makefile..."
& make
if ($lastExitCode -ne "0") { throw "Can't execute 'make .'" }
} else {
write-warning "Sorry, no clue how to build $RepoDir"
}
write-host -foregroundColor green "OK - built Git repository $RepoDir"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}