mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-22 01:48:20 +02:00
Update build-repo.ps1
This commit is contained in:
parent
1e45baca71
commit
b5349dc5ae
@ -1,8 +1,8 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Builds a Git repository
|
Builds a repository
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script supports building with cmake, configure, autogen, Imakefile and Makefile.
|
This PowerShell script builds a repository by supporting: cmake, configure, autogen, Imakefile, and Makefile.
|
||||||
.PARAMETER RepoDir
|
.PARAMETER RepoDir
|
||||||
Specifies the path to the Git repository
|
Specifies the path to the Git repository
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
@ -16,13 +16,13 @@
|
|||||||
param([string]$RepoDir = "$PWD")
|
param([string]$RepoDir = "$PWD")
|
||||||
|
|
||||||
function MakeDir { param($Path)
|
function MakeDir { param($Path)
|
||||||
$DirName = (get-item "$Path").Name
|
$DirName = (Get-Item "$Path").Name
|
||||||
if (test-path "$Path/CMakeLists.txt" -pathType leaf) {
|
if (Test-Path "$Path/CMakeLists.txt" -pathType leaf) {
|
||||||
"🔨 Building 📂$DirName using CMakeLists.txt to subfolder _My_Build/..."
|
"🔨 Building 📂$DirName using CMakeLists.txt into subfolder _My_Build/..."
|
||||||
if (-not(test-path "$Path/_My_Build/" -pathType container)) {
|
if (-not(test-path "$Path/_My_Build/" -pathType container)) {
|
||||||
& mkdir "$Path/_My_Build/"
|
& mkdir "$Path/_My_Build/"
|
||||||
}
|
}
|
||||||
set-location "$Path/_My_Build/"
|
Set-Location "$Path/_My_Build/"
|
||||||
|
|
||||||
& cmake ..
|
& cmake ..
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" }
|
||||||
@ -33,9 +33,9 @@ function MakeDir { param($Path)
|
|||||||
& make test
|
& make test
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/configure" -pathType leaf) {
|
} elseif (Test-Path "$Path/configure" -pathType leaf) {
|
||||||
"🔨 Building 📂$DirName using 'configure'..."
|
"🔨 Building 📂$DirName using 'configure'..."
|
||||||
set-location "$Path/"
|
Set-Location "$Path/"
|
||||||
|
|
||||||
& ./configure
|
& ./configure
|
||||||
#if ($lastExitCode -ne "0") { throw "Script 'configure' exited with error code $lastExitCode" }
|
#if ($lastExitCode -ne "0") { throw "Script 'configure' exited with error code $lastExitCode" }
|
||||||
@ -46,9 +46,9 @@ function MakeDir { param($Path)
|
|||||||
& make test
|
& make test
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/autogen.sh" -pathType leaf) {
|
} elseif (Test-Path "$Path/autogen.sh" -pathType leaf) {
|
||||||
"🔨 Building 📂$DirName using 'autogen.sh'..."
|
"🔨 Building 📂$DirName using 'autogen.sh'..."
|
||||||
set-location "$Path/"
|
Set-Location "$Path/"
|
||||||
|
|
||||||
& ./autogen.sh
|
& ./autogen.sh
|
||||||
if ($lastExitCode -ne "0") { throw "Script 'autogen.sh' exited with error code $lastExitCode" }
|
if ($lastExitCode -ne "0") { throw "Script 'autogen.sh' exited with error code $lastExitCode" }
|
||||||
@ -56,9 +56,9 @@ function MakeDir { param($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 "$Path/build.gradle" -pathType leaf) {
|
} elseif (Test-Path "$Path/build.gradle" -pathType leaf) {
|
||||||
"🔨 Building 📂$DirName using build.gradle..."
|
"🔨 Building 📂$DirName using build.gradle..."
|
||||||
set-location "$Path"
|
Set-Location "$Path"
|
||||||
|
|
||||||
& gradle build
|
& gradle build
|
||||||
if ($lastExitCode -ne "0") { throw "'gradle build' has failed" }
|
if ($lastExitCode -ne "0") { throw "'gradle build' has failed" }
|
||||||
@ -66,9 +66,9 @@ function MakeDir { param($Path)
|
|||||||
& gradle test
|
& gradle test
|
||||||
if ($lastExitCode -ne "0") { throw "'gradle test' has failed" }
|
if ($lastExitCode -ne "0") { throw "'gradle test' has failed" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/Imakefile" -pathType leaf) {
|
} elseif (Test-Path "$Path/Imakefile" -pathType leaf) {
|
||||||
"🔨 Building 📂$DirName using Imakefile..."
|
"🔨 Building 📂$DirName using Imakefile..."
|
||||||
set-location "$RepoDir/"
|
Set-Location "$RepoDir/"
|
||||||
|
|
||||||
& xmkmf
|
& xmkmf
|
||||||
if ($lastExitCode -ne "0") { throw "Executing 'xmkmf' has failed" }
|
if ($lastExitCode -ne "0") { throw "Executing 'xmkmf' has failed" }
|
||||||
@ -76,16 +76,16 @@ function MakeDir { param($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 "$Path/Makefile" -pathType leaf) {
|
} elseif (Test-Path "$Path/Makefile" -pathType leaf) {
|
||||||
"🔨 Building 📂$DirName using Makefile..."
|
"🔨 Building 📂$DirName using Makefile..."
|
||||||
set-location "$Path"
|
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 "$Path/compile.sh" -pathType leaf) {
|
} elseif (Test-Path "$Path/compile.sh" -pathType leaf) {
|
||||||
"🔨 Building 📂$DirName using 'compile.sh'..."
|
"🔨 Building 📂$DirName using 'compile.sh'..."
|
||||||
set-location "$Path/"
|
Set-Location "$Path/"
|
||||||
|
|
||||||
& ./compile.sh
|
& ./compile.sh
|
||||||
if ($lastExitCode -ne "0") { throw "Script 'compile.sh' exited with error code $lastExitCode" }
|
if ($lastExitCode -ne "0") { throw "Script 'compile.sh' exited with error code $lastExitCode" }
|
||||||
@ -93,18 +93,18 @@ function MakeDir { param($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 "$Path/attower/src/build/DevBuild/build.bat" -pathType leaf) {
|
} elseif (Test-Path "$Path/attower/src/build/DevBuild/build.bat" -pathType leaf) {
|
||||||
"🔨 Building 📂$DirName using build.bat ..."
|
"🔨 Building 📂$DirName using build.bat ..."
|
||||||
set-location "$Path/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' exited with error code $lastExitCode" }
|
if ($lastExitCode -ne "0") { throw "Script 'build.bat' exited with error code $lastExitCode" }
|
||||||
|
|
||||||
} elseif (test-path "$Path/$DirName" -pathType container) {
|
} elseif (Test-Path "$Path/$DirName" -pathType container) {
|
||||||
"🔨 No make rule found, trying subfolder 📂$($DirName)..."
|
"🔨 No make rule found, trying subfolder 📂$($DirName)..."
|
||||||
MakeDir "$Path/$DirName"
|
MakeDir "$Path/$DirName"
|
||||||
} else {
|
} else {
|
||||||
write-warning "Sorry, no make rule applies to: 📂$DirName"
|
Write-Warning "Sorry, no make rule applies to: 📂$DirName"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,15 +112,15 @@ function MakeDir { param($Path)
|
|||||||
try {
|
try {
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
||||||
$RepoDirName = (get-item "$RepoDir").Name
|
$RepoDirName = (Get-Item "$RepoDir").Name
|
||||||
|
|
||||||
$PreviousPath = get-location
|
$PreviousPath = Get-Location
|
||||||
MakeDir "$RepoDir"
|
MakeDir "$RepoDir"
|
||||||
set-location "$PreviousPath"
|
Set-Location "$PreviousPath"
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ built Git repository 📂$RepoDirName in $Elapsed sec"
|
"✔️ built 📂$RepoDirName repository in $Elapsed sec"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user