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

View File

@ -1,5 +1,6 @@
Script,Description
add-firewall-rules.ps1, adds firewall rules to the given executables (needs admin rights)
build-repo.ps1, builds the current/given Git repository
check-cpu-temp.ps1, checks the CPU temperature
check-dns-resolution.ps1, checks the DNS resolution with frequently used domain names
check-drive-space.ps1, checks the given drive for free space left

1 Script Description
2 add-firewall-rules.ps1 adds firewall rules to the given executables (needs admin rights)
3 build-repo.ps1 builds the current/given Git repository
4 check-cpu-temp.ps1 checks the CPU temperature
5 check-dns-resolution.ps1 checks the DNS resolution with frequently used domain names
6 check-drive-space.ps1 checks the given drive for free space left

View File

@ -120,6 +120,7 @@ Mega Collection of PowerShell Scripts
📝 PowerShell Scripts for Git
------------------------------
* [build-repo.ps1](Scripts/build-repo.ps1) - builds the current/given Git repository
* [cherry-picker.ps1](Scripts/cherry-picker.ps1) - cherry-picks a Git commit into multiple branches
* [clean-repo.ps1](Scripts/clean-repo.ps1) - cleans the current/given Git repository from untracked files (including submodules)
* [clone-repos.ps1](Scripts/clone-repos.ps1) - clones well-known Git repositories

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
}

View File

@ -9,7 +9,7 @@
param($ParentDir = "$PWD")
try {
"Fetching updates for Git repositories under $ParentDir ..."
"Fetching updates for Git repositories under $($ParentDir)..."
$StartTime = get-date
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
@ -20,7 +20,7 @@ try {
[int]$Count = 0
get-childItem $ParentDir -attributes Directory | foreach-object {
"Fetching Git repository $($_.FullName) ..."
"Fetching updates for $($_.FullName)..."
set-location $_.FullName
& git fetch --all --recurse-submodules