You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
RootDirectory, EngineDirectory, UnrealBuildToolPath are now found in BuildUtilities' UnrealBuild namesapce. The way these are computed has changed. Previously, it was assumed that the application is UnrealBuildTool, and paths were constructed relative to that assembly. Now, the assumption is that the process is located under a "Engine/Build/DotNET" sub-path and paths are constructed relative to that. #jira none #ROBOMERGE-SOURCE: CL 16607440 in //UE5/Main/... #ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v828-16531559) [CL 16607455 by jonathan adamczewski in ue5-release-engine-test branch]
140 lines
4.7 KiB
C#
140 lines
4.7 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using EpicGames.Core;
|
|
using UnrealBuildBase;
|
|
|
|
namespace UnrealBuildTool
|
|
{
|
|
/// <summary>
|
|
/// Queries information about the targets supported by a project
|
|
/// </summary>
|
|
[ToolMode("QueryTargets", ToolModeOptions.XmlConfig | ToolModeOptions.BuildPlatformsHostOnly | ToolModeOptions.SingleInstance)]
|
|
class QueryTargetsMode : ToolMode
|
|
{
|
|
/// <summary>
|
|
/// Path to the project file to query
|
|
/// </summary>
|
|
[CommandLine("-Project=")]
|
|
FileReference? ProjectFile = null;
|
|
|
|
/// <summary>
|
|
/// Path to the output file to receive information about the targets
|
|
/// </summary>
|
|
[CommandLine("-Output=")]
|
|
FileReference? OutputFile = null;
|
|
|
|
/// <summary>
|
|
/// Execute the mode
|
|
/// </summary>
|
|
/// <param name="Arguments">Command line arguments</param>
|
|
/// <returns></returns>
|
|
public override int Execute(CommandLineArguments Arguments)
|
|
{
|
|
Arguments.ApplyTo(this);
|
|
|
|
// Create the build configuration object, and read the settings
|
|
BuildConfiguration BuildConfiguration = new BuildConfiguration();
|
|
XmlConfig.ApplyTo(BuildConfiguration);
|
|
Arguments.ApplyTo(BuildConfiguration);
|
|
|
|
// Ensure the path to the output file is valid
|
|
if(OutputFile == null)
|
|
{
|
|
OutputFile = GetDefaultOutputFile(ProjectFile);
|
|
}
|
|
|
|
// Create the rules assembly
|
|
RulesAssembly Assembly;
|
|
if (ProjectFile != null)
|
|
{
|
|
Assembly = RulesCompiler.CreateProjectRulesAssembly(ProjectFile, BuildConfiguration.bUsePrecompiled, BuildConfiguration.bSkipRulesCompile);
|
|
}
|
|
else
|
|
{
|
|
Assembly = RulesCompiler.CreateEngineRulesAssembly(BuildConfiguration.bUsePrecompiled, BuildConfiguration.bSkipRulesCompile);
|
|
}
|
|
|
|
// Write information about these targets
|
|
WriteTargetInfo(ProjectFile, Assembly, OutputFile, Arguments);
|
|
Log.TraceInformation("Written {0}", OutputFile);
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the path to the target info output file
|
|
/// </summary>
|
|
/// <param name="ProjectFile">Project file being queried</param>
|
|
/// <returns>Path to the output file</returns>
|
|
public static FileReference GetDefaultOutputFile(FileReference? ProjectFile)
|
|
{
|
|
if (ProjectFile == null)
|
|
{
|
|
return FileReference.Combine(UnrealBuild.EngineDirectory, "Intermediate", "TargetInfo.json");
|
|
}
|
|
else
|
|
{
|
|
return FileReference.Combine(ProjectFile.Directory, "Intermediate", "TargetInfo.json");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Writes information about the targets in an assembly to a file
|
|
/// </summary>
|
|
/// <param name="ProjectFile">The project file for the targets being built</param>
|
|
/// <param name="Assembly">The rules assembly for this target</param>
|
|
/// <param name="OutputFile">Output file to write to</param>
|
|
/// <param name="Arguments"></param>
|
|
public static void WriteTargetInfo(FileReference? ProjectFile, RulesAssembly Assembly, FileReference OutputFile, CommandLineArguments Arguments)
|
|
{
|
|
// Construct all the targets in this assembly
|
|
List<string> TargetNames = new List<string>();
|
|
Assembly.GetAllTargetNames(TargetNames, false);
|
|
|
|
// Write the output file
|
|
DirectoryReference.CreateDirectory(OutputFile.Directory);
|
|
using (JsonWriter Writer = new JsonWriter(OutputFile))
|
|
{
|
|
Writer.WriteObjectStart();
|
|
Writer.WriteArrayStart("Targets");
|
|
foreach (string TargetName in TargetNames)
|
|
{
|
|
// skip target rules that are platform extension or platform group specializations
|
|
string[] TargetPathSplit = TargetName.Split(new char[]{'_'}, StringSplitOptions.RemoveEmptyEntries );
|
|
if (TargetPathSplit.Length > 1 && (UnrealTargetPlatform.IsValidName(TargetPathSplit.Last()) || UnrealPlatformGroup.IsValidName(TargetPathSplit.Last()) ) )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Construct the rules object
|
|
TargetRules TargetRules;
|
|
try
|
|
{
|
|
string Architecture = UEBuildPlatform.GetBuildPlatform(BuildHostPlatform.Current.Platform).GetDefaultArchitecture(ProjectFile);
|
|
TargetRules = Assembly.CreateTargetRules(TargetName, BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development, Architecture, ProjectFile, Arguments);
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
Log.TraceWarning("Unable to construct target rules for {0}", TargetName);
|
|
Log.TraceVerbose(ExceptionUtils.FormatException(Ex));
|
|
continue;
|
|
}
|
|
|
|
// Write the target info
|
|
Writer.WriteObjectStart();
|
|
Writer.WriteValue("Name", TargetName);
|
|
Writer.WriteValue("Path", Assembly.GetTargetFileName(TargetName)?.ToString());
|
|
Writer.WriteValue("Type", TargetRules.Type.ToString());
|
|
Writer.WriteObjectEnd();
|
|
}
|
|
Writer.WriteArrayEnd();
|
|
Writer.WriteObjectEnd();
|
|
}
|
|
}
|
|
}
|
|
}
|