build-deps - move some code to powershell

This commit is contained in:
Andrej730
2025-12-24 17:12:17 +05:00
parent 8e639b00e3
commit 633c3bc7eb
2 changed files with 116 additions and 70 deletions
+98 -2
View File
@@ -18,7 +18,7 @@ function mark {
if (Test-Path -Path $marker_filepath) {
return
}
echo "Marking installation in '$installation_dir' with '$ENV:MARKER_FILE'."
cecho.cmd 0 13 "Marking installation in '$installation_dir' with '$ENV:MARKER_FILE'."
New-Item -Path $marker_filepath -ItemType File | Out-Null
}
@@ -76,7 +76,7 @@ function mark_based_on_artifacts {
if (Test-Path -Path $marker_filepath) {
return
}
echo "Found artifact '$artifact' for dependency '$dependency_name' $env:BUILD_CFG."
cecho.cmd 0 13 "Found artifact '$artifact' for dependency '$dependency_name' $env:BUILD_CFG."
& mark $installation_dir
}
@@ -125,6 +125,102 @@ function setup_build_cfg {
}
}
function extract_file {
param(
[Parameter(Mandatory = $true)]
[string]$dependency_name,
[Parameter(Mandatory = $true)]
[string]$filename,
[Parameter(Mandatory = $true)]
[string]$destination_dir,
[Parameter(Mandatory = $true)]
[string]$dir_after_extraction
)
if (Test-Path -Path "$dir_after_extraction") {
cecho.cmd 0 13 "$dependency_name already extracted into '$dir_after_extraction'. Skipping."
exit 0
}
cecho.cmd 0 13 "Extracting $dependency_name into '$destination_dir' from '$filename'."
7za x "$filename" -o"$destination_dir"
exit 0
}
function download_file {
param(
[Parameter(Mandatory = $true)]
[string]$dependency_name,
[Parameter(Mandatory = $true)]
[string]$url,
[Parameter(Mandatory = $true)]
[string]$destination_dir,
[Parameter(Mandatory = $true)]
[string]$filename
)
mkdir "$destination_dir" -Force | Out-Null
pushd "$destination_dir"
if (Test-Path -Path "$filename") {
cecho.cmd 0 13 "$dependency_name already downloaded. Skipping."
exit 0
}
cecho.cmd 0 13 "Downloading $dependency_name into '$destination_dir'"
Invoke-WebRequest $url -OutFile $filename
exit 0
}
# Required env variables:
# - DEPS_DIR
function git_clone_and_checkout_revision {
param(
[Parameter(Mandatory = $true)]
[string]$dependency_name,
[Parameter(Mandatory = $true)]
[string]$git_url,
[Parameter(Mandatory = $true)]
[string]$dest_dir,
[Parameter(Mandatory = $false)]
[string]$revision
)
if (Test-Path -Path "$dest_dir") {
cecho.cmd 0 13 "Cloning $dependency_name is already cloned."
exit 0
}
cecho.cmd 0 13 "Cloning $dependency_name into '$dest_dir'."
pushd "$env:DEPS_DIR"
git clone $git_url $dest_dir
popd
pushd "$dest_dir"
git fetch
cecho.cmd 0 13 "Checking out $dependency_name revision $revision."
git reset --hard
git checkout $revision
popd
exit 0
}
function install_cmake_project {
param(
[Parameter(Mandatory = $true)]
[string]$dependency_name,
[Parameter(Mandatory = $true)]
[string]$build_dir,
[Parameter(Mandatory = $true)]
[string]$configuration
)
pushd "$build_dir"
cecho.cmd 0 13 "Installing $dependency_name ($configuration). Please be patient, this may take a while."
$command = "cmake --install . --config $configuration"
cecho.cmd 0 13 "$command"
Invoke-Expression $command
popd
exit 0
}
function main {
& setup_build_cfg
# Dispatch command.