Refactor ViveVBS plugin build to UE5 conventions

Why: the previous Build.cs copied the Vive DLLs manually via File.Copy
only for the Editor target, leaving Game/packaged builds with missing
runtime dependencies. The DYNAMIC_LINKAGE branch was also syntactically
broken, the SDK header/lib lived inside Source/, and the .uplugin used
the deprecated WhitelistPlatforms key.

- Move SDK to ThirdParty/VBS_SDK/{include,lib/Win64,bin/Win64}/ via
  git renames so history is preserved.
- Replace File.Copy + Editor-only branch with idiomatic
  RuntimeDependencies.Add(staged, source, NonUFS) — UBT now copies the
  DLLs next to the binary for both Editor (modular) and Game (monolithic)
  and stages them at packaging time.
- Drop dead #if DYNAMIC_LINKAGE block.
- Move SDK include path from Public to Private (no public header
  exposes Vive types) and remove the now-dead include from 4 public
  headers; add the SDK include to the 4 .cpp that actually use it.
- Rename WhitelistPlatforms -> PlatformAllowList (UE5).
- Populate FilterPlugin.ini with the ThirdParty paths so the plugin
  is redistributable when packaged standalone.

Validated by clean builds of PS_ViveVBSEditor (Win64 Development) and
PS_ViveVBS (Win64 Development Game), both exit 0, with UBT logging
the automatic Copy steps for the 3 Vive DLLs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-06 07:25:15 +02:00
parent aced61ec47
commit 7f9d5cbe4c
16 changed files with 42 additions and 96 deletions

View File

@@ -1,8 +1,7 @@
[FilterPlugin]
; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and
; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively.
;
; Examples:
; /README.txt
; /Extras/...
; /Binaries/ThirdParty/*.dll
/ThirdParty/VBS_SDK/include/...
/ThirdParty/VBS_SDK/lib/Win64/...
/ThirdParty/VBS_SDK/bin/Win64/...

View File

@@ -2,6 +2,7 @@
#include "../Public/Global.h"
#include "VS_PC_SDK.h"
DEFINE_LOG_CATEGORY(PS_ViveVBS);

View File

@@ -2,6 +2,7 @@
#include "../Public/GunMode.h"
#include "VS_PC_SDK.h"
//DEFINE_LOG_CATEGORY(PS_ViveVBS);

View File

@@ -3,6 +3,7 @@
#include "../Public/MBLS.h"
#include "../Public/Global.h"
#include "VS_PC_SDK.h"
//DEFINE_LOG_CATEGORY(PS_ViveVBS);

View File

@@ -2,6 +2,7 @@
#include "../Public/Passthrough.h"
#include "VS_PC_SDK.h"
//DEFINE_LOG_CATEGORY(PS_ViveVBS);

View File

@@ -4,7 +4,6 @@
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "../VBS_SDK/VS_PC_SDK.h"
#include "Global.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(PS_ViveVBS, Log, All);

View File

@@ -4,7 +4,6 @@
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "../VBS_SDK/VS_PC_SDK.h"
#include "Global.h"
#include "GunMode.generated.h"

View File

@@ -4,7 +4,6 @@
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "../VBS_SDK/VS_PC_SDK.h"
#include "Global.h"
#include "MBLS.generated.h"

View File

@@ -4,7 +4,6 @@
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "../VBS_SDK/VS_PC_SDK.h"
#include "Global.h"
#include "Passthrough.generated.h"

View File

@@ -8,96 +8,43 @@ public class ViveVBS : ModuleRules
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
// ... add other private include paths required here ...
}
);
PublicDependencyModuleNames.AddRange(
new string[]
PublicDependencyModuleNames.AddRange(new string[]
{
"Core",
// ... add other public dependencies that you statically link with here ...
}
);
});
PrivateDependencyModuleNames.AddRange(
new string[]
PrivateDependencyModuleNames.AddRange(new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
// ... add private dependencies that you statically link with here ...
}
);
});
if (Target.Platform == UnrealTargetPlatform.Win64)
{
string SdkRoot = Path.Combine(PluginDirectory, "ThirdParty", "VBS_SDK");
string IncludeDir = Path.Combine(SdkRoot, "include");
string LibDir = Path.Combine(SdkRoot, "lib", "Win64");
string BinDir = Path.Combine(SdkRoot, "bin", "Win64");
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
#if DYNAMIC_LINKAGE
PublicDefinitions.Add("VBS_DYNAMIC_LINKAGE=1");
#endif
string VBS_SDK_PATH = Path.Combine(PluginDirectory, "Source/ViveVBS/VBS_SDK/");
PublicIncludePaths.Add(VBS_SDK_PATH);
#if DYNAMIC_LINKAGE
PublicDelayLoadDLLs.Add("VS_PC_SDK.dll");
PublicDelayLoadDLLs.Add("RRServerManageAPI.dll");
RuntimeDependencies.Add("$(EngineDir)/Binaries/ThirdParty/VBS_SDK/VS_PC_SDK.dll"));
RuntimeDependencies.Add("$(EngineDir)/Binaries/ThirdParty/VBS_SDK/RRServerManageAPI.dll"));
PrivateIncludePaths.Add(IncludeDir);
PublicAdditionalLibraries.Add(Path.Combine(LibDir, "VS_PC_SDK.lib"));
#else
PublicAdditionalLibraries.Add(Path.Combine(VBS_SDK_PATH, "VS_PC_SDK.lib"));
string[] Dlls =
{
"VS_PC_SDK.dll",
"RRServerManageAPI.dll",
"VSWPipeVarClient64U_MT.dll",
};
if (Target.Type == TargetRules.TargetType.Editor)
foreach (string Dll in Dlls)
{
string srcPath = Path.Combine(ModuleDirectory, "../../ThirdParty/Win64/");
string destPath = Path.Combine(ModuleDirectory, "../../../../Binaries/Win64/");
string[] dlls = { "VS_PC_SDK.dll", "RRServerManageAPI.dll", "VSWPipeVarClient64U_MT.dll" };
foreach (string dll in dlls)
{
string src = srcPath + dll;
string dest = destPath + dll;
bool needCopy = !File.Exists(dest);
if (!needCopy)
{
var srcInfo = new FileInfo(src);
var destInfo = new FileInfo(dest);
needCopy = srcInfo.LastWriteTimeUtc > destInfo.LastWriteTimeUtc
|| srcInfo.Length != destInfo.Length;
}
if (needCopy)
{
try
{
File.Copy(src, dest, true);
}
catch (IOException)
{
System.Console.WriteLine("ViveVBS: Could not copy " + dll + " (file locked). Using existing copy.");
RuntimeDependencies.Add(
Path.Combine("$(BinaryOutputDir)", Dll),
Path.Combine(BinDir, Dll),
StagedFileType.NonUFS);
}
}
}
}
RuntimeDependencies.Add("$(ProjectDir)/Binaries/Win64/VS_PC_SDK.dll");
RuntimeDependencies.Add("$(ProjectDir)/Binaries/Win64/RRServerManageAPI.dll");
RuntimeDependencies.Add("$(ProjectDir)/Binaries/Win64/VSWPipeVarClient64U_MT.dll");
#endif
}
}

View File

@@ -19,7 +19,7 @@
"Name": "ViveVBS",
"Type": "Runtime",
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"PlatformAllowList": [
"Win64"
]
}