File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments