13using System.Collections.Generic;
16using System.Reflection;
17using System.Runtime.CompilerServices;
18using System.Xml.Serialization;
55 var serializer =
new XmlSerializer(GetType());
56 serializer.Serialize(writer,
this);
61 using TextWriter writer =
new StreamWriter(file);
68 var result = serializer.Deserialize(stream);
74 if (file ==
null || !File.Exists(file))
return null;
75 using var stream =
new FileStream(file, FileMode.Open);
108 this ModuleRules
self,
110 string filePattern =
null,
111 bool thirdParty =
true,
112 string destinationPostfix =
""
114 var dllExtension = self.Target.Platform == UnrealTargetPlatform.Win64 ?
"dll" :
"so";
115 filePattern ??=
"*." + dllExtension;
116 var binaries = thirdParty ?
self.PluginBinaries() /
"ThirdParty" :
self.PluginBinaries();
117 var dstDir =
self.PluginModuleBinariesPlatform(thirdParty ?
"ThirdParty" :
"") / destinationPostfix;
118 var files = libraryFolder.Copy(dstDir, filePattern);
120 foreach (var dep
in files)
self.RuntimeDependencies.Add(dep);
121 self.DefineDllPath(dstDir.RelativeToBase(
self.PluginPath()));
124 .Where(f => f.HasExtension(
"." + dllExtension))
134 public static void DefineDllPath(
this ModuleRules
self,
string pluginRelativePath)
136 self.PublicRuntimeLibraryPaths.Add(
self.
PluginPath() / pluginRelativePath);
137 self.PublicDefinitions.Add($
"{self.GetBaseModuleName().ToUpper()}_DLL_PATH=TEXT(\"{pluginRelativePath}\")");
145 public static void DefineDllList(
this ModuleRules
self, IEnumerable<string> dlls)
147 var dllsCache = dlls.ToArray();
148 var dllList =
string.Join(
',', dllsCache.Select(d => $
"TEXT(\"{d}\")"));
149 self.PublicDefinitions.Add($
"{self.GetBaseModuleName().ToUpper()}_DLL_FILES={dllList}");
150 self.PublicDelayLoadDLLs.AddRange(dllsCache);
174 var manifestFile =
self.ModulePath() /
"RuntimeDeps.xml";
178 Log.TraceInformationOnce(
179 "{0}: Ignoring RuntimeDeps.xml because {1} doesn't exist.",
186 var runtimeDeps = deps.Files
187 .Where(i => i.Platform?.Contains(
self.Target.Platform.ToString()) ??
true)
188 .Where(i => i.Config?.Contains(
self.GetLibraryConfig(allowDebugLibraries)) ??
true)
191 foreach (var dep
in runtimeDeps)
self.RuntimeDependencies.Add(dep);
193 var runtimeLibPath = deps.RuntimeLibraryPath
194 .Where(i => i.Platform?.Contains(
self.Target.Platform.ToString()) ??
true)
195 .Where(i => i.Config?.Contains(
self.GetLibraryConfig(allowDebugLibraries)) ??
true)
196 .Select(i => i.Value)
199 $
"Binaries/ThirdParty/{self.GetBaseModuleName()}/{self.Target.Platform}/{self.GetLibraryConfig(allowDebugLibraries)}";
201 self.DefineDllPath(runtimeLibPath);
203 var dllDeps = deps.Dlls
204 .Where(i => i.Platform?.Contains(
self.Target.Platform.ToString()) ??
true)
205 .Where(i => i.Config?.Contains(
self.GetLibraryConfig(allowDebugLibraries)) ??
true)
206 .Select(i => i.Value);
208 self.DefineDllList(dllDeps);
A simplified copy of NUKE's own AbsolutePath class https://github.com/nuke-build/nuke/blob/develop/so...
Convenience utilities for module rules.
static void UseRuntimeDependencies(this ModuleRules self, bool allowDebugLibraries=true)
static void DefineDllPath(this ModuleRules self, string pluginRelativePath)
Propagate a search path for module-specific delay loaded DLL files to C++ source via preprocessor.
static AbsolutePath PluginPath(this ModuleRules self)
Path to the plugin folder to which this module belongs
static void DefineDllList(this ModuleRules self, IEnumerable< string > dlls)
Propagate delay loaded module-specific dynamic library files to C++ source via preprocessor.
static void PrepareRuntimeDependencies(this ModuleRules self, AbsolutePath libraryFolder, string filePattern=null, bool thirdParty=true, string destinationPostfix="")
Model for reading a collection of runtime dependencies gathered by an external tool into an XML docum...
RuntimeDependency[] Files
void Serialize(string file)
void Serialize(TextWriter writer)
static RuntimeDependencies Deserialize(FileStream stream)
RuntimeDependency[] RuntimeLibraryPath
static RuntimeDependencies Deserialize(string file)
Model for one runtime dependency.