1212
1313namespace Nuke . Unreal . BoilerplateGenerators . XRepo ;
1414
15+ /// <summary>
16+ /// Utility classes for working with XRepo (or XMake) packages
17+ /// </summary>
1518public static partial class XRepoLibrary
1619{
1720 [ GeneratedRegex (
@@ -34,6 +37,9 @@ public static partial class XRepoLibrary
3437 ) ]
3538 private static partial Regex SpecRegex ( ) ;
3639
40+ /// <summary>
41+ /// Parses an input library spec string as a record
42+ /// </summary>
3743 public static LibrarySpec ParseSpec ( string spec )
3844 {
3945 var matches = spec . Parse ( SpecRegex ( ) , forceNullOnWhitespce : true ) ;
@@ -47,13 +53,10 @@ public static LibrarySpec ParseSpec(string spec)
4753 ) ;
4854 }
4955
50- internal static IEnumerable < XRepoLibraryRecord > InstallXRepoLibrary ( UnrealBuild self , LibrarySpec spec , string options , AbsolutePath targetPath , bool debug )
56+ internal static IEnumerable < XRepoLibraryRecord > InstallXRepoLibrary ( UnrealBuild self , LibrarySpec spec , string options , AbsolutePath targetPath , bool debug , string runtime = "MD" )
5157 {
5258 var libraryFiles = targetPath / "LibraryFiles" ;
53- options = options . AppendNonEmpty ( "," ) + ( debug
54- ? "runtimes='MDd'"
55- : "runtimes='MD'"
56- ) ;
59+ options = options . AppendNonEmpty ( "," ) + $ "runtimes='{ runtime } '";
5760 var xrepoPlatArch = self . Platform . GetXRepoPlatformArch ( ) ;
5861
5962 var extraArgs =
@@ -136,7 +139,17 @@ string[] ProcessPaths(string? paths, AbsolutePath dstDir)
136139 . ToArray ( ) ;
137140 }
138141
139- public static void InstallXRepoLibrary ( this UnrealBuild self , string specIn , string options , AbsolutePath targetPath , string ? suffix = null )
142+ /// <summary>
143+ /// Prepare a third-party library from an XRepo library spec for Unreal engine's consumption
144+ /// </summary>
145+ /// <param name="self">The build context</param>
146+ /// <param name="specIn">The library spec specified here (without the options) https://mcro.de/Nuke.Unreal/d2/d84/CppLibraries.html</param>
147+ /// <param name="options">Comma separated '=' delimited key-value pairs. Space is not allowed around commas</param>
148+ /// <param name="targetPath">Where library files should be organized</param>
149+ /// <param name="suffix">Optional addition to the name of library name exposed to Unreal</param>
150+ /// <param name="releaseRuntime">Windows CRT linkage for release versions (default is MD)</param>
151+ /// <param name="debugRuntime">Windows CRT linkage for debug versions (default is MD)</param>
152+ public static void InstallXRepoLibrary ( this UnrealBuild self , string specIn , string options , AbsolutePath targetPath , string ? suffix = null , string releaseRuntime = "MD" , string debugRuntime = "MD" )
140153 {
141154 Log . Information ( "Installing library {0} via xrepo" , specIn ) ;
142155 var spec = ParseSpec ( specIn ) with { Options = options } ;
@@ -147,10 +160,10 @@ public static void InstallXRepoLibrary(this UnrealBuild self, string specIn, str
147160 Log . Information ( " Features: {0}" , spec . Features ) ;
148161
149162 Log . Information ( "Installing debug build" ) ;
150- var debugLibs = InstallXRepoLibrary ( self , spec , options , targetPath , true ) ;
163+ var debugLibs = InstallXRepoLibrary ( self , spec , options , targetPath , true , debugRuntime ) ;
151164
152165 Log . Information ( "Installing release build (metadata will be used from release build)" ) ;
153- var releaseLibs = InstallXRepoLibrary ( self , spec , options , targetPath , false ) ;
166+ var releaseLibs = InstallXRepoLibrary ( self , spec , options , targetPath , false , releaseRuntime ) ;
154167
155168 Log . Information ( "Generating partial module rule class for {0}" , self . Platform ) ;
156169 new XRepoLibraryModuleGenerator ( ) . Generate (
0 commit comments