Files
a301_game_server/gen_proto.ps1
2026-02-26 17:52:48 +09:00

43 lines
1.3 KiB
PowerShell

# proto 코드 생성 스크립트 (PowerShell)
# 사용법: .\gen_proto.ps1
$PROTOC = "C:\Users\SSAFY\AppData\Local\Microsoft\WinGet\Packages\Google.Protobuf_Microsoft.Winget.Source_8wekyb3d8bbwe\bin\protoc.exe"
$GOPATH_BIN = (go env GOPATH) + "\bin"
$env:PATH = "$GOPATH_BIN;$env:PATH"
$ROOT = $PSScriptRoot
# Go 서버 코드 생성
Write-Host "[1/2] Generating Go server code..." -ForegroundColor Cyan
& $PROTOC `
--go_out="$ROOT\proto\gen\pb" `
--go_opt=paths=source_relative `
--proto_path="$ROOT\proto" `
"$ROOT\proto\messages.proto"
if ($LASTEXITCODE -ne 0) {
Write-Host "Go proto generation failed." -ForegroundColor Red
exit 1
}
Write-Host " -> proto/gen/pb/messages.pb.go" -ForegroundColor Green
# Unity C# 코드 생성
Write-Host "[2/2] Generating C# Unity code..." -ForegroundColor Cyan
$unityOutDir = "$ROOT\unity\Assets\Scripts\Proto"
if (!(Test-Path $unityOutDir)) {
New-Item -ItemType Directory -Path $unityOutDir | Out-Null
}
& $PROTOC `
--csharp_out="$unityOutDir" `
--proto_path="$ROOT\proto" `
"$ROOT\proto\messages.proto"
if ($LASTEXITCODE -ne 0) {
Write-Host "C# proto generation failed." -ForegroundColor Red
exit 1
}
Write-Host " -> unity/Assets/Scripts/Proto/Messages.cs" -ForegroundColor Green
Write-Host "`nDone!" -ForegroundColor Green