From f3e63efe8bec62e077b27c36a716a42d41728a25 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 22 Jun 2026 01:53:40 +0800 Subject: feat: add Windows build script and ignore build directory --- .gitignore | 1 + build.ps1 | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 build.ps1 diff --git a/.gitignore b/.gitignore index 12ab8d8..336b5e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /models +/build diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..05a77d7 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,79 @@ +# dmvop build script +# Safe to run from anywhere — navigates to script dir and restores on exit. + +$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path +$OrigDir = Get-Location + +# Restore original directory on any exit +trap { Set-Location $OrigDir; break } + +Set-Location $ScriptDir +Write-Host "=== Building dmvop ===" -ForegroundColor Cyan + +$BuildDir = Join-Path (Get-Location) "build" +$ReleaseDir = Join-Path (Get-Location) "target\release" + +cargo build --release +if ($LASTEXITCODE -ne 0) { + Write-Host "Build failed!" -ForegroundColor Red + Set-Location $OrigDir + exit 1 +} + +# Create build directory +if (-not (Test-Path $BuildDir)) { + New-Item -ItemType Directory -Path $BuildDir | Out-Null +} + +Write-Host "=== Copying files ===" -ForegroundColor Cyan + +# 1. dmvop.exe +Copy-Item (Join-Path $ReleaseDir "dmvop.exe") (Join-Path $BuildDir "dmvop.exe") -Force +Write-Host " [OK] dmvop.exe" + +# 2. CUDA backend +$CudaSrc = Join-Path $ReleaseDir "cuda" +$CudaDst = Join-Path $BuildDir "cuda" +if (Test-Path $CudaSrc) { + if (-not (Test-Path $CudaDst)) { New-Item -ItemType Directory -Path $CudaDst | Out-Null } + Copy-Item (Join-Path $CudaSrc "*") $CudaDst -Force + Write-Host " [OK] cuda\" +} + +# 3. CPU backend +$CpuSrc = Join-Path $ReleaseDir "cpu" +$CpuDst = Join-Path $BuildDir "cpu" +if (Test-Path $CpuSrc) { + if (-not (Test-Path $CpuDst)) { New-Item -ItemType Directory -Path $CpuDst | Out-Null } + Copy-Item (Join-Path $CpuSrc "*") $CpuDst -Force + Write-Host " [OK] cpu\" +} + +# 4. dmvop.toml +$TomlSrc = Join-Path (Get-Location) "dmvop.toml" +if (Test-Path $TomlSrc) { + Copy-Item $TomlSrc (Join-Path $BuildDir "dmvop.toml") -Force + Write-Host " [OK] dmvop.toml" +} + +# 5. LICENSE +$LicenseSrc = Join-Path (Get-Location) "LICENSE" +if (Test-Path $LicenseSrc) { + Copy-Item $LicenseSrc (Join-Path $BuildDir "LICENSE") -Force + Write-Host " [OK] LICENSE" +} + +# 6. README.md +$ReadmeSrc = Join-Path (Get-Location) "README.md" +if (Test-Path $ReadmeSrc) { + Copy-Item $ReadmeSrc (Join-Path $BuildDir "README.md") -Force + Write-Host " [OK] README.md" +} + +Write-Host "=== Done! Build output in: $BuildDir ===" -ForegroundColor Green +Write-Host "" +Write-Host "Contents:" -ForegroundColor Cyan +Get-ChildItem $BuildDir -Recurse | ForEach-Object { " $($_.Name)" } + +# Restore original directory +Set-Location $OrigDir -- cgit