forked from sofintel/sofintel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstage-windows-cef-runtime.ps1
More file actions
68 lines (56 loc) · 2.48 KB
/
Copy pathstage-windows-cef-runtime.ps1
File metadata and controls
68 lines (56 loc) · 2.48 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
param(
[string]$TargetDirectory = (Join-Path (Split-Path -Parent $PSScriptRoot) "target\debug")
)
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
function Resolve-CefRuntimeSource {
param(
[Parameter(Mandatory = $true)]
[string]$ResolvedTargetDirectory
)
$candidates = Get-ChildItem -Path (Join-Path $ResolvedTargetDirectory "build") -Directory -Filter "cef-dll-sys-*" -ErrorAction SilentlyContinue |
ForEach-Object {
$runtimePath = Join-Path $_.FullName "out\cef_windows_x86_64"
if (Test-Path (Join-Path $runtimePath "libcef.dll")) {
[pscustomobject]@{
RuntimePath = $runtimePath
LastWriteTime = (Get-Item (Join-Path $runtimePath "libcef.dll")).LastWriteTime
}
}
} |
Sort-Object LastWriteTime -Descending
return $candidates | Select-Object -First 1 -ExpandProperty RuntimePath
}
function Sync-CefRuntimeContents {
param(
[Parameter(Mandatory = $true)]
[string]$SourceDirectory,
[Parameter(Mandatory = $true)]
[string]$DestinationDirectory
)
if (Test-Path $DestinationDirectory) {
Remove-Item -LiteralPath $DestinationDirectory -Recurse -Force
}
New-Item -ItemType Directory -Path $DestinationDirectory -Force | Out-Null
$directoriesToCopy = @("locales")
$filePatternsToCopy = @("*.bin", "*.dat", "*.dll", "*.json", "*.pak")
foreach ($directoryName in $directoriesToCopy) {
$sourcePath = Join-Path $SourceDirectory $directoryName
if (Test-Path $sourcePath) {
Copy-Item -LiteralPath $sourcePath -Destination (Join-Path $DestinationDirectory $directoryName) -Recurse -Force
}
}
foreach ($pattern in $filePatternsToCopy) {
Get-ChildItem -LiteralPath $SourceDirectory -Filter $pattern -File -ErrorAction SilentlyContinue | ForEach-Object {
Copy-Item -LiteralPath $_.FullName -Destination (Join-Path $DestinationDirectory $_.Name) -Force
}
}
}
$targetDirectory = (Resolve-Path $TargetDirectory).Path
$cefSource = Resolve-CefRuntimeSource -ResolvedTargetDirectory $targetDirectory
if (-not $cefSource) {
throw "Unable to locate built CEF runtime under '$targetDirectory\build'."
}
$cefRuntimeDirectory = Join-Path $targetDirectory "cef_runtime"
Sync-CefRuntimeContents -SourceDirectory $cefSource -DestinationDirectory $cefRuntimeDirectory
Write-Output $cefRuntimeDirectory