aboutsummaryrefslogtreecommitdiff
path: root/binding/unreal/build-plugin.ps1
blob: 7b5c39df8cbaa3e14690e68bd06c365effa6f6f1 (plain) (blame)
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
param(
    [Parameter(Mandatory = $true)]
    [string]$UE,
    [string]$Output = "",
    [switch]$Full
)

$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
if ($Output -eq "") {
    $Output = Join-Path $ScriptDir "build\DMVOPBridge"
}

$PluginDir = Join-Path $ScriptDir "DMVOPBridge"
$Plugin = Join-Path $PluginDir "DMVOPBridge.uplugin"
$HostDir = Join-Path $ScriptDir ".host"
$HostPluginDir = Join-Path $HostDir "Plugins\DMVOPBridge"
$HostProj = Join-Path $HostDir "HostProject.uproject"
$UAT = Join-Path $UE "Engine\Build\BatchFiles\RunUAT.bat"
$UBT = Join-Path $UE "Engine\Build\BatchFiles\Build.bat"

if (-not (Test-Path $UAT)) {
    Write-Host "UE not found at $UE" -ForegroundColor Red
    exit 1
}

# ── Ensure .host project + plugin symlink ──
if (-not (Test-Path $HostPluginDir)) {
    New-Item -ItemType Directory -Path (Join-Path $HostDir "Plugins") -Force | Out-Null
    cmd /c "mklink /J `"$HostPluginDir`" `"$PluginDir`"" | Out-Null
}

if (-not (Test-Path $HostProj)) {
    $proj = @"
{
    "FileVersion": 3,
    "EngineAssociation": "5.6",
    "Category": "",
    "Description": "",
    "Plugins": [
        { "Name": "DMVOPBridge", "Enabled": true }
    ]
}
"@
    Set-Content -Path $HostProj -Value $proj
}

if ($Full -or -not (Test-Path $Output)) {
    # ── Full build ──
    Write-Host "=== DMVOPBridge (full) ===" -ForegroundColor Cyan
    & $UAT BuildPlugin -Plugin="$Plugin" -Package="$Output" -Rocket
} else {
    # ── Incremental build ──
    Write-Host "=== DMVOPBridge (incremental) ===" -ForegroundColor Cyan
    & $UBT UnrealEditor Win64 Development `
        -Project="$HostProj" `
        -Plugin="$Plugin" `
        -TargetType=Editor

    # Ensure output has the base plugin files (.uplugin, Config, etc.)
    if (-not (Test-Path (Join-Path $Output "DMVOPBridge.uplugin"))) {
        Write-Host "  Copying plugin skeleton..." -ForegroundColor DarkYellow
        Copy-Item (Join-Path $PluginDir "*.uplugin") $Output -Force
        if (Test-Path (Join-Path $PluginDir "Config")) {
            Copy-Item (Join-Path $PluginDir "Config") $Output -Recurse -Force
        }
    }

    # Copy compiled binaries
    $DllSrc = "$PluginDir\Binaries"
    $DllDst = "$Output\Binaries"
    if (Test-Path $DllSrc) {
        Copy-Item $DllSrc $DllDst -Recurse -Force
        Write-Host "  Updated: $Output\Binaries"
    }
}

if ($LASTEXITCODE -eq 0) {
    Write-Host "=== Done ===" -ForegroundColor Green
} else {
    Write-Host "Build failed" -ForegroundColor Red
}