28 (?:(?<PROVIDER>\w+)\:\:)?
34 (?<VERSION>[\w\-\.#]+)
37 (?:\s(?<OPTIONS>[\w=,']+))?
40 RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace
42 private static partial Regex SpecRegex();
49 var matches = spec.Parse(SpecRegex(), forceNullOnWhitespce:
true);
60 internal static IEnumerable<XRepoLibraryRecord> InstallXRepoLibrary(
IUnrealBuild build,
UnrealPlatform platform, LibrarySpec spec,
string options, AbsolutePath targetPath,
bool debug,
string runtime =
"MD")
62 var libraryFiles = targetPath /
"LibraryFiles";
65 options = options.AppendNonEmpty(
",") + $
"runtimes='{runtime}'";
67 var xrepoPlatArch = platform.GetXRepoPlatformArch();
69 var sdk = platform.GetSdk();
72 Assert.True(sdk.IsValid(build), $
"Attempting to use a platform which is not set up for cross compiling ({Unreal.GetHostPlatform()} -> {platform})");
73 sdk.Setup(build).Wait();
76 var sdkXMakeData = sdk?.GetXMakeData(build);
78 var extraArgs = ArgumentStringHandlerEx.Render(
80 -p {sdkXMakeData?.Platform ?? xrepoPlatArch.Platform.ToString()}
81 -a {xrepoPlatArch.Arch.ToCorrectString()}
82 -m {(debug ? "debug
" : "release
")}
83 {sdkXMakeData?.Arguments ?? ""}
86 XRepoTasks.Install(spec.Spec, options, extraArgs)
87 .When(sdkXMakeData?.ToolSetup !=
null, sdkXMakeData?.ToolSetup)
90 string[] HandlePaths(IEnumerable<AbsolutePath>? paths, AbsolutePath dstDir)
92 if (paths ==
null)
return [];
96 var dstPath = dstDir / i.Name;
97 if (i.FileExists() || i.DirectoryExists())
98 i.Copy(dstPath, ExistsPolicy.MergeAndOverwrite);
101 Log.Warning(
"A library is referring to a non-existing file or folder: {0}", i);
106 .Where(p => !
string.IsNullOrWhiteSpace(p))
111 return XRepoTasks.Fetch(spec.Spec, options, extraArgs)
112 .When(sdkXMakeData?.ToolSetup !=
null, sdkXMakeData?.ToolSetup)
114 .ParseXRepoFetch().NotNull(
"Couldn't parse XRepo package from fetch output")!
115 .Where(i => i.IsLibrary)
118 Log.Information(
"Handling library (dependency) {0} version {1}", i.InferredName!, i.Version);
119 var manifest = i.GetManifest().NotNull(
"Libraries must have a manifest.txt file")!;
120 return new XRepoLibraryRecord(
121 Spec:
new LibrarySpec(
122 i.InferredName! +
" " + i.Version!,
126 Options: manifest[
"configs"]?.ToString() ??
"",
127 Description: manifest[
"description"]?.ToString(),
128 IncludePaths: HandlePaths(i.IncludeDirs, libraryFiles / i.InferredName /
"Includes"),
129 SysIncludePaths: HandlePaths(i.SysIncludeDirs, libraryFiles / i.InferredName /
"SysIncludes"),
130 LibFiles: HandlePaths(i.LibFiles,
131 libraryFiles / i.InferredName /
"Libs" / platform / (debug ?
"Debug" :
"Release")),
133 ?.Select(l => platform.IsWindows && !l.EndsWith(
".lib") ? l +
".lib" : l)
136 ?.Select(l => platform.IsWindows && !l.EndsWith(
".lib") ? l +
".lib" : l)
138 Defines: i.Defines ?? []
162 public static void InstallXRepoLibrary(
this IUnrealBuild build,
string specIn,
string options, AbsolutePath targetPath, List<UnrealPlatform>? supportedPlatforms =
null,
string? suffix =
null,
string releaseRuntime =
"MD",
string debugRuntime =
"MD")
164 Log.Information(
"Installing library {0} via xrepo", specIn);
165 var spec =
ParseSpec(specIn) with { Options = options };
166 Log.Information(
" Name: {0}", spec.Name);
167 Log.Information(
" Version: {0}", spec.Version);
168 Log.Information(
" Provider: {0}", spec.Provider ??
"xrepo");
169 Log.Information(
" Options: {0}", spec.Options);
170 Log.Information(
" Features: {0}", spec.Features);
172 var platforms = UPlugin.Get(targetPath).Descriptor.SupportedTargetPlatforms;
173 if (platforms ==
null || platforms.IsEmpty())
178 foreach (var platform
in platforms)
180 if (!supportedPlatforms.IsNullOrEmpty() && supportedPlatforms!.All(p => p != platform))
182 Log.Information(
"{0} platform has been skipped", platform);
186 Log.Information(
"Installing debug build for {0}", platform);
187 var debugLibs = InstallXRepoLibrary(build, platform, spec, options, targetPath,
true, debugRuntime);
189 Log.Information(
"Installing release build for {0}", platform);
190 Log.Information(
" (metadata will be used from release build)");
191 var releaseLibs = InstallXRepoLibrary(build, platform, spec, options, targetPath,
false, releaseRuntime);
193 Log.Information(
"Generating partial module rule class for {0}", platform);