/// <summary> /// Compile a rules assembly for the current target /// </summary> /// <param name="ProjectFile">The project file being compiled</param> /// <param name="TargetName">The target being built</param> /// <param name="bSkipRulesCompile">Whether to skip compiling any rules assemblies</param> /// <param name="bUsePrecompiled">Whether to use a precompiled engine/enterprise build</param> /// <param name="ForeignPlugin">Foreign plugin to be compiled</param> /// <returns>The compiled rules assembly</returns> public static RulesAssembly CreateTargetRulesAssembly(FileReference ProjectFile, string TargetName, bool bSkipRulesCompile, bool bUsePrecompiled, FileReference ForeignPlugin) { RulesAssembly RulesAssembly; if (ProjectFile != null) { RulesAssembly = CreateProjectRulesAssembly(ProjectFile, bUsePrecompiled, bSkipRulesCompile); } else { RulesAssembly = CreateEngineRulesAssembly(bUsePrecompiled, bSkipRulesCompile); if (RulesAssembly.GetTargetFileName(TargetName) == null) { // Target isn't part of the engine assembly, try the enterprise assembly RulesAssembly EnterpriseRulesAssembly = CreateEnterpriseRulesAssembly(bUsePrecompiled, bSkipRulesCompile); if (EnterpriseRulesAssembly != null) { RulesAssembly = EnterpriseRulesAssembly; } } } if (ForeignPlugin != null) { RulesAssembly = CreatePluginRulesAssembly(ForeignPlugin, bSkipRulesCompile, RulesAssembly, true); } return(RulesAssembly); }
/// <summary> /// Gets the source file containing rules for the given target /// </summary> /// <param name="TargetName">The name of the target</param> /// <returns>The filename containing rules for this target, or an empty string if not found</returns> public FileReference GetTargetFileName(string TargetName) { FileReference TargetFile; if (TargetNameToTargetFile.TryGetValue(TargetName, out TargetFile)) { return(TargetFile); } else { return((Parent == null) ? null : Parent.GetTargetFileName(TargetName)); } }
/// <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(); } }
public static void GetTargetUWPPaths(RulesAssembly InTargetRulesAssembly, string InTargetName, TargetRules InTargetRules, out string OutEngineSourceRelativeBinaryPath, out string OutRelativeTargetPath) { OutEngineSourceRelativeBinaryPath = ""; OutRelativeTargetPath = ""; string TargetFilename = InTargetRulesAssembly.GetTargetFileName(InTargetName).FullName; string ProjectSourceFolder = new FileInfo(TargetFilename).DirectoryName; string EnginePath = Path.Combine(ProjectFileGenerator.EngineRelativePath); string EngineSourcePath = Path.Combine(EnginePath, "Source"); string RelativeTargetFilename = Utils.MakePathRelativeTo(TargetFilename, EngineSourcePath); if ((RelativeTargetFilename.StartsWith("..") == false) && (RelativeTargetFilename.Contains(":") == false)) { // This target must be UNDER Engine/Source... RelativeTargetFilename = Path.Combine(EngineSourcePath, RelativeTargetFilename); } RelativeTargetFilename = RelativeTargetFilename.Replace("\\", "/"); EnginePath = EnginePath.Replace("\\", "/"); Int32 LastSourceIdx = RelativeTargetFilename.LastIndexOf("Source"); if (LastSourceIdx != -1) { RelativeTargetFilename = RelativeTargetFilename.Substring(0, LastSourceIdx); } else { RelativeTargetFilename = ""; } OutRelativeTargetPath = RelativeTargetFilename; if (InTargetRules.bOutputToEngineBinaries) { RelativeTargetFilename = EnginePath; } OutEngineSourceRelativeBinaryPath = Path.Combine(RelativeTargetFilename, "Binaries/UWP/"); OutEngineSourceRelativeBinaryPath = OutEngineSourceRelativeBinaryPath.Replace("\\", "/"); }
/// <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) { // 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(); } }