Files
CC-Framework.BriskGameServer/Tools/Sync-BriskPackage.ps1

70 lines
2.3 KiB
PowerShell

param(
[string]$ProjectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
)
$ErrorActionPreference = "Stop"
function Assert-PathExists {
param(
[string]$Path,
[string]$Description
)
if (-not (Test-Path -LiteralPath $Path)) {
throw "$Description not found: $Path"
}
}
function Reset-Directory {
param([string]$Path)
if (Test-Path -LiteralPath $Path) {
Remove-Item -LiteralPath $Path -Recurse -Force
}
New-Item -ItemType Directory -Path $Path | Out-Null
}
function Copy-DirectoryContents {
param(
[string]$Source,
[string]$Destination
)
Assert-PathExists -Path $Source -Description "Source directory"
Reset-Directory -Path $Destination
Get-ChildItem -LiteralPath $Source -Force | ForEach-Object {
Copy-Item -LiteralPath $_.FullName -Destination $Destination -Recurse -Force
}
}
$packageRoot = Join-Path $ProjectRoot "PackageSource/com.foldcc.cc-framework.brisk-game-server"
$runtimeSource = Join-Path $ProjectRoot "Assets/BriskSdk/Runtime"
$samplesSource = Join-Path $ProjectRoot "Assets/BriskSdk/Samples/QuickStart"
$sceneSource = Join-Path $ProjectRoot "Assets/Scenes/BriskQuickStartScene.unity"
$sceneMetaSource = Join-Path $ProjectRoot "Assets/Scenes/BriskQuickStartScene.unity.meta"
Assert-PathExists -Path $packageRoot -Description "Package root"
Assert-PathExists -Path $runtimeSource -Description "Runtime source"
Assert-PathExists -Path $samplesSource -Description "Sample source"
Assert-PathExists -Path $sceneSource -Description "Sample scene"
Assert-PathExists -Path $sceneMetaSource -Description "Sample scene meta"
$runtimeTarget = Join-Path $packageRoot "Runtime"
$samplesTarget = Join-Path $packageRoot "Samples~/QuickStart"
$samplesRootTarget = Join-Path $packageRoot "Samples~"
Copy-DirectoryContents -Source $runtimeSource -Destination $runtimeTarget
if (-not (Test-Path -LiteralPath $samplesRootTarget)) {
New-Item -ItemType Directory -Path $samplesRootTarget | Out-Null
}
Copy-DirectoryContents -Source $samplesSource -Destination $samplesTarget
Copy-Item -LiteralPath $sceneSource -Destination $samplesTarget -Force
Copy-Item -LiteralPath $sceneMetaSource -Destination $samplesTarget -Force
Write-Host "Brisk package source synced."
Write-Host "Package root: $packageRoot"