Skip to content

Commit fb5475d

Browse files
committed
feat: 构建脚本
1 parent 177d185 commit fb5475d

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

build.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[CmdletBinding()]
2+
param(
3+
[Parameter()]
4+
[string]$Deploy
5+
)
6+
7+
$ErrorActionPreference = 'Stop'
8+
Set-StrictMode -Version Latest
9+
10+
$root = $PSScriptRoot
11+
$target = Join-Path $root 'target'
12+
$artifacts = @(
13+
@{
14+
Name = 'winhttp.dll'
15+
Package = 'applechu'
16+
Triple = 'i686-pc-windows-msvc'
17+
},
18+
@{
19+
Name = 'winmm.dll'
20+
Package = 'applechu-amdaemon'
21+
Triple = 'x86_64-pc-windows-msvc'
22+
}
23+
)
24+
25+
Push-Location $root
26+
try {
27+
foreach ($artifact in $artifacts) {
28+
Write-Host "正在构建 $($artifact.Name)..."
29+
& cargo build --release --package $artifact.Package --target $artifact.Triple
30+
if ($LASTEXITCODE -ne 0) {
31+
throw "$($artifact.Name) 构建失败,退出代码:$LASTEXITCODE"
32+
}
33+
34+
$source = Join-Path $target "$($artifact.Triple)\release\$($artifact.Name)"
35+
$destination = Join-Path $target $artifact.Name
36+
Copy-Item -LiteralPath $source -Destination $destination -Force
37+
Write-Host "已复制到 $destination"
38+
}
39+
40+
if ($Deploy) {
41+
$deployDirectory = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Deploy)
42+
New-Item -ItemType Directory -Path $deployDirectory -Force | Out-Null
43+
44+
foreach ($artifact in $artifacts) {
45+
$source = Join-Path $target $artifact.Name
46+
Copy-Item -LiteralPath $source -Destination $deployDirectory -Force
47+
}
48+
49+
Write-Host "已部署到 $deployDirectory"
50+
}
51+
}
52+
finally {
53+
Pop-Location
54+
}

0 commit comments

Comments
 (0)