tool.ps1 - refer to cecho.cmd directly, use return instead of exit 0

Which is useful when debugging and calling tools.ps1 directly - less thing to modify to make it work.
Also replaced `exit 0` with `return`, so it would be possible to reuse functions inside `tools.ps1`
This commit is contained in:
Andrej730
2026-02-09 12:12:04 +05:00
parent 88a5717295
commit dcac336b98
+16 -18
View File
@@ -2,6 +2,8 @@ Set-PSDebug -Trace 0
Set-StrictMode -Version 3 Set-StrictMode -Version 3
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$cecho = "$PSScriptRoot\cecho.cmd"
# Create marker file to indicate whether Release or Debug build was installed. # Create marker file to indicate whether Release or Debug build was installed.
function mark { function mark {
@@ -18,7 +20,7 @@ function mark {
if (Test-Path -Path $marker_filepath) { if (Test-Path -Path $marker_filepath) {
return return
} }
cecho.cmd 0 13 "Marking installation in '$installation_dir' with '$ENV:MARKER_FILE'." . $cecho 0 13 "Marking installation in '$installation_dir' with '$ENV:MARKER_FILE'."
New-Item -Path $marker_filepath -ItemType File | Out-Null New-Item -Path $marker_filepath -ItemType File | Out-Null
} }
@@ -76,7 +78,7 @@ function mark_based_on_artifacts {
if (Test-Path -Path $marker_filepath) { if (Test-Path -Path $marker_filepath) {
return return
} }
cecho.cmd 0 13 "Found artifact '$artifact' for dependency '$dependency_name' $env:BUILD_CFG." . $cecho 0 13 "Found artifact '$artifact' for dependency '$dependency_name' $env:BUILD_CFG."
& mark $installation_dir & mark $installation_dir
} }
@@ -138,12 +140,11 @@ function extract_file {
[string]$dir_after_extraction [string]$dir_after_extraction
) )
if (Test-Path -Path "$dir_after_extraction") { if (Test-Path -Path "$dir_after_extraction") {
cecho.cmd 0 13 "$dependency_name already extracted into '$dir_after_extraction'. Skipping." . $cecho 0 13 "$dependency_name already extracted into '$dir_after_extraction'. Skipping."
exit 0 return
} }
cecho.cmd 0 13 "Extracting $dependency_name into '$destination_dir' from '$filename'." . $cecho 0 13 "Extracting $dependency_name into '$destination_dir' from '$filename'."
7za x "$filename" -o"$destination_dir" 7za x "$filename" -o"$destination_dir"
exit 0
} }
@@ -161,13 +162,12 @@ function download_file {
mkdir "$destination_dir" -Force | Out-Null mkdir "$destination_dir" -Force | Out-Null
pushd "$destination_dir" pushd "$destination_dir"
if (Test-Path -Path "$filename") { if (Test-Path -Path "$filename") {
cecho.cmd 0 13 "$dependency_name already downloaded. Skipping." . $cecho 0 13 "$dependency_name already downloaded. Skipping."
exit 0 return
} }
cecho.cmd 0 13 "Downloading $dependency_name into '$destination_dir'" . $cecho 0 13 "Downloading $dependency_name into '$destination_dir'"
Invoke-WebRequest $url -OutFile $filename Invoke-WebRequest $url -OutFile $filename
exit 0
} }
@@ -185,21 +185,20 @@ function git_clone_and_checkout_revision {
[string]$revision [string]$revision
) )
if (Test-Path -Path "$dest_dir") { if (Test-Path -Path "$dest_dir") {
cecho.cmd 0 13 "Cloning $dependency_name is already cloned." . $cecho 0 13 "Cloning $dependency_name is already cloned."
exit 0 return
} }
cecho.cmd 0 13 "Cloning $dependency_name into '$dest_dir'." . $cecho 0 13 "Cloning $dependency_name into '$dest_dir'."
pushd "$env:DEPS_DIR" pushd "$env:DEPS_DIR"
git clone $git_url $dest_dir git clone $git_url $dest_dir
popd popd
pushd "$dest_dir" pushd "$dest_dir"
git fetch git fetch
cecho.cmd 0 13 "Checking out $dependency_name revision $revision." . $cecho 0 13 "Checking out $dependency_name revision $revision."
git reset --hard git reset --hard
git checkout $revision git checkout $revision
popd popd
exit 0
} }
function install_cmake_project { function install_cmake_project {
@@ -212,12 +211,11 @@ function install_cmake_project {
[string]$configuration [string]$configuration
) )
pushd "$build_dir" pushd "$build_dir"
cecho.cmd 0 13 "Installing $dependency_name ($configuration). Please be patient, this may take a while." . $cecho 0 13 "Installing $dependency_name ($configuration). Please be patient, this may take a while."
$command = "cmake --install . --config $configuration" $command = "cmake --install . --config $configuration"
cecho.cmd 0 13 "$command" . $cecho 0 13 "$command"
Invoke-Expression $command Invoke-Expression $command
popd popd
exit 0
} }