forked from Devolutions/MsRdpEx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetours.ps1
61 lines (46 loc) · 2 KB
/
detours.ps1
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
param(
[string] $GitRepo = 'https://github.com/microsoft/Detours',
[string] $GitCommit = '4b8c659' # July 24, 2023
)
$RepoRoot = $PSScriptRoot
$SourcesDir = "$RepoRoot/dependencies/sources"
New-Item -ItemType Directory -Path $SourcesDir -ErrorAction SilentlyContinue | Out-Null
Push-Location
Set-Location $SourcesDir
if (-Not (Test-Path -Path "detours")) {
& 'git' 'clone' $GitRepo 'detours'
}
Set-Location "detours/src"
& 'git' 'checkout' $GitCommit
if (-Not (Test-Path Env:VSCMD_ARG_TGT_ARCH)) {
throw "VSCMD_ARG_TGT_ARCH is not set, use a Visual Studio developer shell"
}
Write-Host "Building Detours for $Env:VSCMD_ARG_TGT_ARCH"
$TargetArchs = @($Env:VSCMD_ARG_TGT_ARCH)
$TargetConfs = @('Release', 'Debug')
foreach ($TargetArch in $TargetArchs) {
$Env:VSCMD_ARG_TGT_ARCH="$TargetArch"
$Env:DETOURS_TARGET_PROCESSOR="$($TargetArch.ToUpper())"
& nmake clean
foreach ($TargetConf in $TargetConfs) {
$Env:DETOURS_CONFIG="$TargetConf"
& nmake
}
}
Set-Location ".."
$PkgDir = "$RepoRoot/dependencies/detours"
New-Item -ItemType Directory -Path $PkgDir -ErrorAction SilentlyContinue | Out-Null
New-Item -ItemType Directory -Path "$PkgDir/lib" -ErrorAction SilentlyContinue | Out-Null
Remove-Item -Path "$PkgDir/include" -Recurse -ErrorAction SilentlyContinue | Out-Null
Copy-Item "include" -Destination "$PkgDir/include" -Exclude @("syelog.h") -Recurse
foreach ($TargetArch in $TargetArchs) {
Remove-Item -Path "$PkgDir/lib/$TargetArch" -Recurse -ErrorAction SilentlyContinue | Out-Null
New-Item -ItemType Directory -Path "$PkgDir/lib/$TargetArch" -ErrorAction SilentlyContinue | Out-Null
foreach ($TargetConf in $TargetConfs) {
$LibDir = "lib." + $TargetArch.ToUpper() + $TargetConf
Write-Host "Copying $LibDir to "$PkgDir/lib/$TargetArch/$TargetConf""
New-Item -ItemType Directory -Path "$PkgDir/lib/$TargetArch/$TargetConf" | Out-Null
Copy-Item "$LibDir/*" -Destination "$PkgDir/lib/$TargetArch/$TargetConf" -Recurse
}
}
Pop-Location