-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
91 lines (76 loc) · 2.61 KB
/
build.ps1
File metadata and controls
91 lines (76 loc) · 2.61 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# HyperDbg 统一工程构建脚本
$ErrorActionPreference = "Stop"
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path
$BUILD_DIR = Join-Path $SCRIPT_DIR "build"
$CONFIG = "Release"
$WDK_PATH = "E:\Program Files\Windows Kits\10"
$EWDK_BUILD_ENV = "E:\BuildEnv\SetupBuildEnv.cmd"
Write-Host "=== HyperDbg 统一工程构建脚本 ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "脚本目录: $SCRIPT_DIR" -ForegroundColor Green
Write-Host ""
# 设置WDK环境变量
$env:WDKContentRoot = $WDK_PATH
Write-Host "设置WDKContentRoot: $env:WDKContentRoot" -ForegroundColor Green
Write-Host ""
# 检查EWDK构建环境脚本是否存在
if (-not (Test-Path $EWDK_BUILD_ENV)) {
Write-Host "错误: 未找到EWDK构建环境脚本: $EWDK_BUILD_ENV" -ForegroundColor Red
Read-Host "按任意键退出"
exit 1
}
Write-Host "使用EWDK构建环境: $EWDK_BUILD_ENV" -ForegroundColor Green
Write-Host ""
# 清理并创建构建目录
if (Test-Path $BUILD_DIR) {
Write-Host "清理构建目录: $BUILD_DIR" -ForegroundColor Yellow
Remove-Item -Path $BUILD_DIR -Recurse -Force
}
Write-Host "创建构建目录: $BUILD_DIR" -ForegroundColor Yellow
New-Item -ItemType Directory -Path $BUILD_DIR | Out-Null
# 生成项目
Write-Host "=== 生成项目 ===" -ForegroundColor Cyan
Push-Location $BUILD_DIR
try {
cmd /c "`"$EWDK_BUILD_ENV`" && cmake `"$SCRIPT_DIR`""
if ($LASTEXITCODE -ne 0) {
throw "生成项目失败"
}
} catch {
Write-Host "=== 生成项目失败 ===" -ForegroundColor Red
Pop-Location
Read-Host "按任意键退出"
exit 1
}
Write-Host ""
Write-Host "=== 编译项目 ===" -ForegroundColor Cyan
try {
cmd /c "`"$EWDK_BUILD_ENV`" && cmake --build . --config $CONFIG"
if ($LASTEXITCODE -ne 0) {
throw "编译失败"
}
} catch {
Write-Host "=== 编译失败 ===" -ForegroundColor Red
Pop-Location
Read-Host "按任意键退出"
exit 1
}
Pop-Location
Write-Host ""
Write-Host "=== 构建完成 ===" -ForegroundColor Green
Write-Host ""
Write-Host "输出目录: $BUILD_DIR\$CONFIG" -ForegroundColor Yellow
Write-Host ""
# 显示生成的文件
$sysFiles = Get-ChildItem -Path "$BUILD_DIR\$CONFIG\*.sys" -ErrorAction SilentlyContinue
$pdbFiles = Get-ChildItem -Path "$BUILD_DIR\$CONFIG\*.pdb" -ErrorAction SilentlyContinue
if ($sysFiles) {
Write-Host "生成的驱动文件:" -ForegroundColor Yellow
$sysFiles | ForEach-Object { Write-Host " $($_.Name)" }
}
if ($pdbFiles) {
Write-Host "生成的符号文件:" -ForegroundColor Yellow
$pdbFiles | ForEach-Object { Write-Host " $($_.Name)" }
}
Write-Host ""
Read-Host "按任意键退出"