Improve build-repo.ps1

This commit is contained in:
Markus Fleschutz 2021-05-07 15:37:04 +02:00
parent 96596a7581
commit 23c2be2dd4

View File

@ -7,19 +7,15 @@
param($RepoDir = "$PWD") param($RepoDir = "$PWD")
try { function MakeDir { param($Path)
$StopWatch = [system.diagnostics.stopwatch]::startNew() $DirName = (get-item "$Path").Name
if (test-path "$Path/CMakeLists.txt") {
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } "⏳ Building 📂$DirName using CMakeLists.txt ..."
$RepoDirName = (get-item "$RepoDir").Name if (-not(test-path "$Path/BuildFiles/" -pathType container)) {
& mkdir "$Path/BuildFiles/"
if (test-path "$RepoDir/CMakeLists.txt") {
"⏳ Building 📂$RepoDirName using CMakeLists.txt ..."
if (-not(test-path "$RepoDir/BuildFiles/" -pathType container)) {
& mkdir "$RepoDir/BuildFiles/"
} }
set-location "$RepoDir/BuildFiles/" set-location "$Path/BuildFiles/"
& cmake .. & cmake ..
if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" } if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" }
@ -28,9 +24,9 @@ try {
set-location .. set-location ..
} elseif (test-path "$RepoDirName/configure") { } elseif (test-path "$Path/configure") {
"⏳ Building 📂$RepoDirName using 'configure' ..." "⏳ Building 📂$DirName using 'configure' ..."
set-location "$RepoDir/" set-location "$Path/"
& ./configure & ./configure
if ($lastExitCode -ne "0") { throw "Executing 'configure' has failed" } if ($lastExitCode -ne "0") { throw "Executing 'configure' has failed" }
@ -38,9 +34,9 @@ try {
& make -j4 & make -j4
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
} elseif (test-path "$RepoDir/autogen.sh") { } elseif (test-path "$Path/autogen.sh") {
"⏳ Building 📂$RepoDirName using 'autogen.sh' ..." "⏳ Building 📂$DirName using 'autogen.sh' ..."
set-location "$RepoDir/" set-location "$Path/"
& ./autogen.sh & ./autogen.sh
if ($lastExitCode -ne "0") { throw "Script 'autogen.sh' has failed" } if ($lastExitCode -ne "0") { throw "Script 'autogen.sh' has failed" }
@ -48,8 +44,8 @@ try {
& make -j4 & make -j4
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
} elseif (test-path "$RepoDir/Imakefile") { } elseif (test-path "$Path/Imakefile") {
"⏳ Building 📂$RepoDirName using Imakefile ..." "⏳ Building 📂$DirName using Imakefile ..."
set-location "$RepoDir/" set-location "$RepoDir/"
& xmkmf & xmkmf
@ -58,24 +54,36 @@ try {
& make -j4 & make -j4
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
} elseif (test-path "$RepoDir/Makefile") { } elseif (test-path "$Path/Makefile") {
"⏳ Building 📂$RepoDirName using Makefile..." "⏳ Building 📂$DirName using Makefile..."
set-location "$RepoDir/" set-location "$Path"
& make -j4 & make -j4
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
} elseif (test-path "$RepoDir/attower/src/build/DevBuild/build.bat") { } elseif (test-path "$Path/attower/src/build/DevBuild/build.bat") {
"⏳ Building 📂$RepoDirName using build.bat ..." "⏳ Building 📂$DirName using build.bat ..."
set-location "$RepoDir/attower/src/build/DevBuild/" set-location "$Path/attower/src/build/DevBuild/"
& ./build.bat build-all-release & ./build.bat build-all-release
if ($lastExitCode -ne "0") { throw "Script 'build.bat' returned error(s)" } if ($lastExitCode -ne "0") { throw "Script 'build.bat' returned error(s)" }
} elseif (test-path "$Path/$DirName" -pathType container) {
"⏳ No make rule found, but trying the subdirectory 📂$DirName ..."
MakeDir "$Path/$DirName"
} else { } else {
write-warning "Sorry, no rule found to build 📂$RepoDirName" write-warning "Sorry, no make rule found in 📂$DirName"
exit 0 exit 0
} }
}
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
$RepoDirName = (get-item "$RepoDir").Name
MakeDir "$RepoDir"
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ built Git repository 📂$RepoDirName in $Elapsed sec." "✔️ built Git repository 📂$RepoDirName in $Elapsed sec."