diff --git a/scripts/build-repo.ps1 b/scripts/build-repo.ps1 index f3657232..df956876 100755 --- a/scripts/build-repo.ps1 +++ b/scripts/build-repo.ps1 @@ -1,15 +1,15 @@ ο»Ώ<# .SYNOPSIS - Builds a repository + Builds a repo .DESCRIPTION - This PowerShell script builds a Git repository by supporting build systems such as: autogen, cmake, configure, Gradle, Imakefile, Makefile, and Meson. + This PowerShell script builds a Git repository by supporting the build systems: autogen, cmake, configure, Gradle, Imakefile, Makefile, and Meson. .PARAMETER path - Specifies the path to the Git repository (default is current working directory) + Specifies the path to the Git repository (current working directory by default) .EXAMPLE PS> ./build-repo.ps1 C:\Repos\ninja - ⏳ Building πŸ“‚ninja using CMakeLists.txt into πŸ“‚ninja/_Build_Results... + ⏳ Building πŸ“‚ninja by using CMake... ... - βœ… Built πŸ“‚ninja repository in 47 sec. + βœ… Repo πŸ“‚ninja built successfully in 47s. .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -18,10 +18,11 @@ param([string]$path = "$PWD") -function BuildInDir([string]$path) { +function BuildFolder([string]$path) { $dirName = (Get-Item "$path").Name if (Test-Path "$path/CMakeLists.txt" -pathType leaf) { - "⏳ (1/4) Building πŸ“‚$dirName by using CMake into πŸ“‚$dirName/_Build_Results..." + "⏳ (1/4) Building πŸ“‚$dirName by using CMake..." + $global:results = "$path/_Build_Results" if (-not(Test-Path "$path/_Build_Results/" -pathType container)) { & mkdir "$path/_Build_Results/" } @@ -38,9 +39,8 @@ function BuildInDir([string]$path) { "⏳ (4/4) Executing 'ctest -V' to perform tests (optional)..." & ctest -V if ($lastExitCode -ne 0) { throw "Executing 'ctest -V' exited with error code $lastExitCode" } - } elseif (Test-Path "$path/autogen.sh" -pathType leaf) { - "⏳ Building πŸ“‚$dirName by using 'autogen.sh'..." + "⏳ Building πŸ“‚$dirName by executing 'autogen.sh'..." Set-Location "$path/" & ./autogen.sh --force @@ -52,9 +52,8 @@ function BuildInDir([string]$path) { & make -j4 if ($lastExitCode -ne 0) { throw "Executing 'make -j4' exited with error code $lastExitCode" } - } elseif (Test-Path "$path/configure" -pathType leaf) { - "⏳ Building πŸ“‚$dirName by using 'configure'..." + "⏳ Building πŸ“‚$dirName by executing './configure' and 'make'..." Set-Location "$path/" & ./configure @@ -107,7 +106,7 @@ function BuildInDir([string]$path) { if ($lastExitCode -ne 0) { throw "Executing 'make -j4' has failed" } } elseif (Test-Path "$path/compile.sh" -pathType leaf) { - "⏳ Building πŸ“‚$dirName by using 'compile.sh'..." + "⏳ Building πŸ“‚$dirName by executing 'compile.sh'..." Set-Location "$path/" & ./compile.sh @@ -117,15 +116,16 @@ function BuildInDir([string]$path) { if ($lastExitCode -ne 0) { throw "Executing 'make -j4' has failed" } } elseif (Test-Path "$path/attower/src/build/DevBuild/build.bat" -pathType leaf) { - "⏳ Building πŸ“‚$dirName by using build.bat ..." - Set-Location "$path/attower/src/build/DevBuild/" - & ./build.bat build-all-release - if ($lastExitCode -ne 0) { throw "Executing 'build.bat build-all-release' exited with error code $lastExitCode" } + Write-Host "⏳ Building πŸ“‚$dirName by executing 'build.bat'..." + Set-Location "$path/attower/src/build/DevBuild/" + & ./build.bat build-core-release + if ($lastExitCode -ne 0) { throw "Executing 'build.bat' exited with error code $lastExitCode" } + $global:results = "$path\attower\Executables\" } elseif (Test-Path "$path/$dirName" -pathType container) { "⏳ No make rule found, trying subfolder πŸ“‚$($dirName)..." - BuildInDir "$path/$dirName" + BuildFolder "$path/$dirName" } else { Write-Warning "Sorry, no make rule applies to: πŸ“‚$dirName" exit 0 # success @@ -134,18 +134,24 @@ function BuildInDir([string]$path) { try { $stopWatch = [system.diagnostics.stopwatch]::startNew() - - if (-not(Test-Path "$path" -pathType container)) { throw "Can't access directory: $path" } - $previousPath = Get-Location - BuildInDir "$path" + + if (-not(Test-Path "$path" -pathType container)) { throw "The file path '$path' doesn't exist (yet)" } + + $global:results = "" + BuildFolder "$path" Set-Location "$previousPath" $repoDirName = (Get-Item "$path").Name [int]$elapsed = $stopWatch.Elapsed.TotalSeconds - "βœ… Built πŸ“‚$repoDirName repository in $elapsed sec." + if ($global:results -eq "") { + "βœ… Repo πŸ“‚$repoDirName built successfully in $($elapsed)s." + } else { + "βœ… Repo πŸ“‚$repoDirName built successfully in $($elapsed)s, results at: πŸ“‚$($global:results)" + } exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + Set-Location "$previousPath" exit 1 } diff --git a/scripts/cd-repo.ps1 b/scripts/cd-repo.ps1 index 83c9dd7e..6802935a 100755 --- a/scripts/cd-repo.ps1 +++ b/scripts/cd-repo.ps1 @@ -17,7 +17,7 @@ param([string]$folderName = "") try { - if ("$folderName" -eq "") { $folderName = Read-Host "Enter the Git repository's folder name" } + if ("$folderName" -eq "") { $folderName = Read-Host "Enter the folder name of the Git repository" } if (Test-Path "~/Repos" -pathType container) { $path = "~/Repos" } elseif (Test-Path "~/repos" -pathType container) { $path = "~/repos" @@ -33,7 +33,7 @@ try { throw "No Git repositories folder in your home directory or in the root folder yet" } $path += "/" + $folderName - if (-not(Test-Path "$path" -pathType container)) { throw "The path to πŸ“‚$path doesn't exist (yet)" } + if (-not(Test-Path "$path" -pathType container)) { throw "The file path '$path' doesn't exist (yet)" } $path = Resolve-Path "$path" Set-Location "$path"