-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ps1
More file actions
72 lines (64 loc) · 2.49 KB
/
Copy pathbuild.ps1
File metadata and controls
72 lines (64 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
[CmdletBinding()]
param(
[Parameter()]
[string]$Deploy
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$root = $PSScriptRoot
$target = Join-Path $root 'target'
$exampleName = 'AppleChu.example.toml'
$fullName = 'AppleChu.full.toml'
$artifacts = @(
@{
Name = 'winhttp.dll'
Package = 'applechu'
Triple = 'i686-pc-windows-msvc'
},
@{
Name = 'winmm.dll'
Package = 'applechu-amdaemon'
Triple = 'x86_64-pc-windows-msvc'
}
)
Push-Location $root
try {
foreach ($artifact in $artifacts) {
Write-Host "正在构建 $($artifact.Name)..."
& cargo build --release --package $artifact.Package --target $artifact.Triple
if ($LASTEXITCODE -ne 0) {
throw "$($artifact.Name) 构建失败,退出代码:$LASTEXITCODE"
}
$source = Join-Path $target "$($artifact.Triple)\release\$($artifact.Name)"
$destination = Join-Path $target $artifact.Name
Copy-Item -LiteralPath $source -Destination $destination -Force
Write-Host "已复制到 $destination"
}
$exampleSource = Join-Path $target "i686-pc-windows-msvc\release\$exampleName"
& cargo run --package applechu-schema --bin verify_pe --target x86_64-pc-windows-msvc -- `
(Join-Path $target 'winhttp.dll') $exampleSource
if ($LASTEXITCODE -ne 0) {
throw "示例配置生成失败,退出代码:$LASTEXITCODE"
}
$exampleDestination = Join-Path $target $exampleName
Copy-Item -LiteralPath $exampleSource -Destination $exampleDestination -Force
Write-Host "已复制到 $exampleDestination"
$fullSource = Join-Path $target "i686-pc-windows-msvc\release\$fullName"
$fullDestination = Join-Path $target $fullName
Copy-Item -LiteralPath $fullSource -Destination $fullDestination -Force
Write-Host "已复制到 $fullDestination"
if ($Deploy) {
$deployDirectory = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Deploy)
New-Item -ItemType Directory -Path $deployDirectory -Force | Out-Null
foreach ($artifact in $artifacts) {
$source = Join-Path $target $artifact.Name
Copy-Item -LiteralPath $source -Destination $deployDirectory -Force
}
Copy-Item -LiteralPath $exampleDestination -Destination $deployDirectory -Force
Copy-Item -LiteralPath $fullDestination -Destination $deployDirectory -Force
Write-Host "已部署到 $deployDirectory"
}
}
finally {
Pop-Location
}