summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-24 05:50:52 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-24 05:50:52 +0800
commitb2d385d9717bfdd381436393325bcab389418bc8 (patch)
treefb4796d0f07ff32d6379fa4f794a62ab9c356a15
parent7aa5f292adbd0328e815a034c3300175849c8f36 (diff)
Add timing and suppress output in deployment scripts
-rw-r--r--scripts/dev/deploy.ps128
-rw-r--r--scripts/dev/deploy.sh20
-rw-r--r--scripts/dev/dev_deploy.ps18
3 files changed, 40 insertions, 16 deletions
diff --git a/scripts/dev/deploy.ps1 b/scripts/dev/deploy.ps1
index 3da08bb..beaf6a8 100644
--- a/scripts/dev/deploy.ps1
+++ b/scripts/dev/deploy.ps1
@@ -7,13 +7,20 @@ $scriptDir = Split-Path $scriptPath -Parent
# Run script to hide ignored files
$hideScriptPath = Join-Path $scriptDir "hide_ignored_file.ps1"
if (Test-Path $hideScriptPath) {
- & $hideScriptPath
+ try {
+ & $hideScriptPath
+ } catch {
+ Write-Warning "Run `"hide_ignored_file.ps1`" failed"
+ }
} else {
- Write-Warning "hide_ignored_file.ps1 not found at $hideScriptPath"
+ Write-Warning "Script `"hide_ignored_file.ps1`" not found at $hideScriptPath"
}
Set-Location (Join-Path $scriptDir "..\..")
+# Start timing
+$startTime = Get-Date
+
# Check for ISCC
$isccPath = Get-Command ISCC -ErrorAction SilentlyContinue
if (-not $isccPath) {
@@ -30,7 +37,7 @@ if (-not (Test-Path $coreLibPath)) {
# Test core library
Write-Host "Testing Core Library `".\..\VersionControl\Cargo.toml`""
-cargo test --manifest-path ..\VersionControl\Cargo.toml --workspace --quiet
+cargo test --manifest-path ..\VersionControl\Cargo.toml --workspace --quiet > $null 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Warning "Core library tests failed. Aborting build."
exit 1
@@ -38,7 +45,7 @@ if ($LASTEXITCODE -ne 0) {
# Test workspace
Write-Host "Testing Command Line `".\Cargo.toml`""
-cargo test --workspace --quiet
+cargo test --workspace --quiet > $null 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Warning "Workspace tests failed. Aborting build."
exit 1
@@ -62,17 +69,22 @@ if ($coreGitStatus) {
# Build
$env:FORCE_BUILD=$(Get-Date -Format 'mmss')
-Write-Host "Building `".\Cargo.toml`""
-cargo build --workspace --release --quiet
+Write-Host "Building Command Line `".\Cargo.toml`""
+cargo build --workspace --release --quiet > $null 2>&1
if ($LASTEXITCODE -ne 0) {
# Build failed
} else {
# Build succeeded
# Export
- Write-Host "Deploying `".\.cargo\config.toml`""
- if (cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter release) {
+ Write-Host "Deploying Command Line `".\.cargo\config.toml`""
+ if (cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter release > $null 2>&1) {
Copy-Item -Path templates\compile_info.rs.template -Destination src\data\compile_info.rs -Force
Write-Host "Packing Installer `".\setup\windows\setup_jv_cli.iss`""
ISCC /Q .\scripts\setup\windows\setup_jv_cli.iss
}
}
+
+# Calculate elapsed time and output success message
+$elapsedTime = (Get-Date) - $startTime
+$elapsedSeconds = [math]::Round($elapsedTime.TotalSeconds, 2)
+Write-Host "Success (Finished in ${elapsedSeconds}s)"
diff --git a/scripts/dev/deploy.sh b/scripts/dev/deploy.sh
index 429ea0a..b8e4640 100644
--- a/scripts/dev/deploy.sh
+++ b/scripts/dev/deploy.sh
@@ -2,6 +2,9 @@
# Require : Cargo (Rust)
+# Start timing
+start_time=$(date +%s.%N)
+
# Change to the directory where the script is located
cd "$(dirname "$0")/../../" || exit 1
@@ -14,7 +17,7 @@ fi
# Test core library
echo "Testing Core Library \"../VersionControl/Cargo.toml\""
-cargo test --manifest-path ../VersionControl/Cargo.toml --workspace --quiet
+cargo test --manifest-path ../VersionControl/Cargo.toml --workspace --quiet > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Core library tests failed. Aborting build."
exit 1
@@ -22,7 +25,7 @@ fi
# Test workspace
echo "Testing Command Line \"./Cargo.toml\""
-cargo test --workspace --quiet
+cargo test --workspace --quiet > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Workspace tests failed. Aborting build."
exit 1
@@ -45,13 +48,18 @@ if [ -n "$core_git_status" ]; then
fi
# Build
-echo "Building \"./Cargo.toml\""
-if FORCE_BUILD=$(date +%s) cargo build --workspace --release --quiet; then
+echo "Building Command Line \"./Cargo.toml\""
+if FORCE_BUILD=$(date +%s) cargo build --workspace --release --quiet > /dev/null 2>&1; then
# Build succeeded
# Export
- echo "Deploying \"./.cargo/config.toml\""
- if cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter release; then
+ echo "Deploying Command Line \"./.cargo/config.toml\""
+ if cargo run --manifest-path tools/build_helper/Cargo.toml --quiet --bin exporter release > /dev/null 2>&1; then
# Copy compile_info.rs.template to compile_info.rs after successful export
cp -f templates/compile_info.rs.template src/data/compile_info.rs
fi
fi
+
+# Calculate and display elapsed time
+end_time=$(date +%s.%N)
+elapsed_time=$(echo "$end_time - $start_time" | bc)
+printf "Success (Finished in %.2fs)\n" $elapsed_time
diff --git a/scripts/dev/dev_deploy.ps1 b/scripts/dev/dev_deploy.ps1
index 8e3a8e9..688b8d1 100644
--- a/scripts/dev/dev_deploy.ps1
+++ b/scripts/dev/dev_deploy.ps1
@@ -7,9 +7,13 @@ $scriptDir = Split-Path $scriptPath -Parent
# Run script to hide ignored files
$hideScriptPath = Join-Path $scriptDir "hide_ignored_file.ps1"
if (Test-Path $hideScriptPath) {
- & $hideScriptPath
+ try {
+ & $hideScriptPath
+ } catch {
+ Write-Warning "Run `"hide_ignored_file.ps1`" failed"
+ }
} else {
- Write-Warning "hide_ignored_file.ps1 not found at $hideScriptPath"
+ Write-Warning "Script `"hide_ignored_file.ps1`" not found at $hideScriptPath"
}
Set-Location (Join-Path $scriptDir "..\..")