/// <summary> /// Function to call to after reset default data. /// </summary> public static void PostReset() { // Configuration overrides. string SteamVersion = "Steamv132"; bCompileSteamOSS = bCompileSteamOSS && Directory.Exists(UEBuildConfiguration.UEThirdPartySourceDirectory + "Steamworks/" + SteamVersion) == true; bCompileMcpOSS = bCompileMcpOSS && Directory.Exists("Runtime/Online/NotForLicensees/OnlineSubsystemMcp") == true; bCompileSimplygon = bCompileSimplygon && Directory.Exists(UEBuildConfiguration.UEThirdPartySourceDirectory + "NotForLicensees") == true && Directory.Exists(UEBuildConfiguration.UEThirdPartySourceDirectory + "NotForLicensees/Simplygon") == true && Directory.Exists("Developer/SimplygonMeshReduction") == true && !(ProjectFileGenerator.bGenerateProjectFiles && ProjectFileGenerator.bGeneratingRocketProjectFiles); if (UnrealBuildTool.CommandLineContains(@"UnrealCodeAnalyzer") || UnrealBuildTool.CommandLineContains(@"UnrealHeaderTool")) { BuildConfiguration.bRunUnrealCodeAnalyzer = false; } if (BuildConfiguration.bRunUnrealCodeAnalyzer) { BuildConfiguration.bUsePCHFiles = false; BuildConfiguration.bUseUnityBuild = false; BuildConfiguration.bUseSharedPCHs = false; BuildConfiguration.bAllowXGE = false; } }
/// <summary> /// Selects which platforms and build configurations we want in the project file /// </summary> /// <param name="IncludeAllPlatforms">True if we should include ALL platforms that are supported on this machine. Otherwise, only desktop platforms will be included.</param> /// <param name="SupportedPlatformNames">Output string for supported platforms, returned as comma-separated values.</param> protected override void SetupSupportedPlatformsAndConfigurations(bool IncludeAllPlatforms, out string SupportedPlatformNames) { // Call parent implementation to figure out the actual platforms base.SetupSupportedPlatformsAndConfigurations(IncludeAllPlatforms, out SupportedPlatformNames); // Certain platforms override the project file format because their debugger add-ins may not yet support the latest // version of Visual Studio. This is their chance to override that. foreach (var SupportedPlatform in SupportedPlatforms) { var BuildPlatform = UEBuildPlatform.GetBuildPlatform(SupportedPlatform, true); if (BuildPlatform != null) { // Don't worry about platforms that we're missing SDKs for if (BuildPlatform.HasRequiredSDKsInstalled() == SDKStatus.Valid) { // Make sure Visual Studio 2013 project files will work... if (ProjectFileFormat == VCProjectFileFormat.VisualStudio2013) { // ...but only if the user didn't override this via the command-line. if (!UnrealBuildTool.CommandLineContains("-2013")) { // Visual Studio 2013 is not supported by Xbox One debugger add-in yet if (SupportedPlatform == UnrealTargetPlatform.XboxOne) { Log.TraceInformation("Forcing Visual Studio 2012 projects for Xbox One compatibility (use '-2013' to override.)"); ProjectFileFormat = VCProjectFileFormat.VisualStudio2012; } } } } } } }
/// <summary> /// Function to call to after reset default data. /// </summary> public static void PostReset() { // Analyzing UCA is disabled for debugging convenience. if (UnrealBuildTool.CommandLineContains(@"UnrealCodeAnalyzer") // UHT is necessary to generate code for proper compilation. || UnrealBuildTool.CommandLineContains(@"UnrealHeaderTool")) { BuildConfiguration.bRunUnrealCodeAnalyzer = false; } // Couple flags have to be set properly when running UCA. if (BuildConfiguration.bRunUnrealCodeAnalyzer) { // Analyzing header usage makes more sense on non unity builds. BuildConfiguration.bUseUnityBuild = false; // Unfortunately clang doesn't work with PCH files specified via cl.exe syntax. BuildConfiguration.bUsePCHFiles = false; BuildConfiguration.bUseSharedPCHs = false; //BuildConfiguration.bUseUBTMakefiles = false; //BuildConfiguration.bUseActionHistory = false; } }
/// <summary> /// Builds and runs the header tool and touches the header directories. /// Performs any early outs if headers need no changes, given the UObject modules, tool path, game name, and configuration /// </summary> public static bool ExecuteHeaderToolIfNecessary(UEToolChain ToolChain, UEBuildTarget Target, CPPEnvironment GlobalCompileEnvironment, List <UHTModuleInfo> UObjectModules, FileReference ModuleInfoFileName, ref ECompilationResult UHTResult) { if (ProgressWriter.bWriteMarkup) { Log.WriteLine(LogEventType.Console, "@progress push 5%"); } using (ProgressWriter Progress = new ProgressWriter("Generating code...", false)) { // We never want to try to execute the header tool when we're already trying to build it! var bIsBuildingUHT = Target.GetTargetName().Equals("UnrealHeaderTool", StringComparison.InvariantCultureIgnoreCase); var RootLocalPath = Path.GetFullPath(ProjectFileGenerator.RootRelativePath); // check if UHT is out of date DateTime HeaderToolTimestamp = DateTime.MaxValue; bool bHaveHeaderTool = !bIsBuildingUHT && GetHeaderToolTimestamp(out HeaderToolTimestamp); // ensure the headers are up to date bool bUHTNeedsToRun = (UEBuildConfiguration.bForceHeaderGeneration == true || !bHaveHeaderTool || AreGeneratedCodeFilesOutOfDate(UObjectModules, HeaderToolTimestamp)); if (bUHTNeedsToRun || UnrealBuildTool.IsGatheringBuild) { // Since code files are definitely out of date, we'll now finish computing information about the UObject modules for UHT. We // want to save this work until we know that UHT actually needs to be run to speed up best-case iteration times. if (UnrealBuildTool.IsGatheringBuild) // In assembler-only mode, PCH info is loaded from our UBTMakefile! { foreach (var UHTModuleInfo in UObjectModules) { // Only cache the PCH name if we don't already have one. When running in 'gather only' mode, this will have already been cached if (string.IsNullOrEmpty(UHTModuleInfo.PCH)) { UHTModuleInfo.PCH = ""; // We need to figure out which PCH header this module is including, so that UHT can inject an include statement for it into any .cpp files it is synthesizing var DependencyModuleCPP = (UEBuildModuleCPP)Target.GetModuleByName(UHTModuleInfo.ModuleName); var ModuleCompileEnvironment = DependencyModuleCPP.CreateModuleCompileEnvironment(GlobalCompileEnvironment); DependencyModuleCPP.CachePCHUsageForModuleSourceFiles(ModuleCompileEnvironment); if (DependencyModuleCPP.ProcessedDependencies.UniquePCHHeaderFile != null) { UHTModuleInfo.PCH = DependencyModuleCPP.ProcessedDependencies.UniquePCHHeaderFile.AbsolutePath; } } } } } // @todo ubtmake: Optimization: Ideally we could avoid having to generate this data in the case where UHT doesn't even need to run! Can't we use the existing copy? (see below use of Manifest) UHTManifest Manifest = new UHTManifest(Target, RootLocalPath, ToolChain.ConvertPath(RootLocalPath + '\\'), UObjectModules); if (!bIsBuildingUHT && bUHTNeedsToRun) { // Always build UnrealHeaderTool if header regeneration is required, unless we're running within a Rocket ecosystem or hot-reloading if (UnrealBuildTool.RunningRocket() == false && UEBuildConfiguration.bDoNotBuildUHT == false && UEBuildConfiguration.bHotReloadFromIDE == false && !(bHaveHeaderTool && !UnrealBuildTool.IsGatheringBuild && UnrealBuildTool.IsAssemblingBuild)) // If running in "assembler only" mode, we assume UHT is already up to date for much faster iteration! { // If it is out of date or not there it will be built. // If it is there and up to date, it will add 0.8 seconds to the build time. Log.TraceInformation("Building UnrealHeaderTool..."); var UBTArguments = new StringBuilder(); UBTArguments.Append("UnrealHeaderTool"); // Which desktop platform do we need to compile UHT for? UBTArguments.Append(" " + BuildHostPlatform.Current.Platform.ToString()); // NOTE: We force Development configuration for UHT so that it runs quickly, even when compiling debug UBTArguments.Append(" " + UnrealTargetConfiguration.Development.ToString()); // NOTE: We disable mutex when launching UBT from within UBT to compile UHT UBTArguments.Append(" -NoMutex"); if (UnrealBuildTool.CommandLineContains("-noxge")) { UBTArguments.Append(" -noxge"); } // Propagate command-line option if (UnrealBuildTool.CommandLineContains("-2015")) { UBTArguments.Append(" -2015"); } if (UnrealBuildTool.CommandLineContains("-2013")) { UBTArguments.Append(" -2013"); } // Add UHT plugins to UBT command line as external plugins if (Target.UnrealHeaderToolPlugins != null && Target.UnrealHeaderToolPlugins.Count > 0) { foreach (PluginInfo Plugin in Target.UnrealHeaderToolPlugins) { UBTArguments.Append(" -PLUGIN \"" + Plugin.File + "\""); } } if (RunExternalExecutable(UnrealBuildTool.GetUBTPath(), UBTArguments.ToString()) != 0) { return(false); } } Progress.Write(1, 3); var ActualTargetName = String.IsNullOrEmpty(Target.GetTargetName()) ? "UE4" : Target.GetTargetName(); Log.TraceInformation("Parsing headers for {0}", ActualTargetName); string HeaderToolPath = GetHeaderToolPath(); if (!File.Exists(HeaderToolPath)) { throw new BuildException("Unable to generate headers because UnrealHeaderTool binary was not found ({0}).", Path.GetFullPath(HeaderToolPath)); } // Disable extensions when serializing to remove the $type fields Directory.CreateDirectory(ModuleInfoFileName.Directory.FullName); System.IO.File.WriteAllText(ModuleInfoFileName.FullName, fastJSON.JSON.Instance.ToJSON(Manifest, new fastJSON.JSONParameters { UseExtensions = false })); string CmdLine = (Target.ProjectFile != null) ? "\"" + Target.ProjectFile.FullName + "\"" : Target.GetTargetName(); CmdLine += " \"" + ModuleInfoFileName + "\" -LogCmds=\"loginit warning, logexit warning, logdatabase error\" -Unattended -WarningsAsErrors"; if (UnrealBuildTool.IsEngineInstalled()) { CmdLine += " -installed"; } if (UEBuildConfiguration.bFailIfGeneratedCodeChanges) { CmdLine += " -FailIfGeneratedCodeChanges"; } if (!bInvalidateUHTMakefile && BuildConfiguration.bUseUHTMakefiles) { CmdLine += " -UseMakefiles"; } if (!UEBuildConfiguration.bCompileAgainstEngine) { CmdLine += " -NoEnginePlugins"; } Log.TraceInformation(" Running UnrealHeaderTool {0}", CmdLine); Stopwatch s = new Stopwatch(); s.Start(); UHTResult = (ECompilationResult)RunExternalExecutable(ExternalExecution.GetHeaderToolPath(), CmdLine); s.Stop(); if (UHTResult != ECompilationResult.Succeeded) { // On Linux and Mac, the shell will return 128+signal number exit codes if UHT gets a signal (e.g. crashes or is interrupted) if ((BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Linux || BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac) && (int)(UHTResult) >= 128 ) { // SIGINT is 2, so 128 + SIGINT is 130 UHTResult = ((int)(UHTResult) == 130) ? ECompilationResult.Canceled : ECompilationResult.CrashOrAssert; } Log.TraceInformation("Error: Failed to generate code for {0} - error code: {2} ({1})", ActualTargetName, (int)UHTResult, UHTResult.ToString()); return(false); } Log.TraceInformation("Reflection code generated for {0} in {1} seconds", ActualTargetName, s.Elapsed.TotalSeconds); if (BuildConfiguration.bPrintPerformanceInfo) { Log.TraceInformation("UnrealHeaderTool took {1}", ActualTargetName, (double)s.ElapsedMilliseconds / 1000.0); } // Now that UHT has successfully finished generating code, we need to update all cached FileItems in case their last write time has changed. // Otherwise UBT might not detect changes UHT made. DateTime StartTime = DateTime.UtcNow; FileItem.ResetInfos(); double ResetDuration = (DateTime.UtcNow - StartTime).TotalSeconds; Log.TraceVerbose("FileItem.ResetInfos() duration: {0}s", ResetDuration); } else { Log.TraceVerbose("Generated code is up to date."); } Progress.Write(2, 3); // There will never be generated code if we're building UHT, so this should never be called. if (!bIsBuildingUHT) { // Allow generated code to be sync'd to remote machines if needed. This needs to be done even if UHT did not run because // generated headers include other generated headers using absolute paths which in case of building remotely are already // the remote machine absolute paths. Because of that parsing headers will not result in finding all includes properly. // @todo ubtmake: Need to figure out what this does in the assembler case, and whether we need to run it ToolChain.PostCodeGeneration(Manifest); } // touch the directories UpdateDirectoryTimestamps(UObjectModules); Progress.Write(3, 3); } if (ProgressWriter.bWriteMarkup) { Log.WriteLine(LogEventType.Console, "@progress pop"); } return(true); }
/// <summary> /// Discover and fill in the project info /// </summary> public static void FillProjectInfo() { DateTime StartTime = DateTime.Now; List <string> DirectoriesToSearch = new List <string>(); // Find all the .uprojectdirs files contained in the root folder and add their entries to the search array string RootDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetOriginalLocation()), "..", "..", ".."); string EngineSourceDirectory = Path.GetFullPath(Path.Combine(RootDirectory, "Engine", "Source")); foreach (string File in Directory.EnumerateFiles(RootDirectory, "*.uprojectdirs", SearchOption.TopDirectoryOnly)) { string FilePath = Path.GetFullPath(File); Log.TraceVerbose("\tFound uprojectdirs file {0}", FilePath); using (StreamReader Reader = new StreamReader(FilePath)) { string LineRead; while ((LineRead = Reader.ReadLine()) != null) { string ProjDirEntry = LineRead.Trim(); if (String.IsNullOrEmpty(ProjDirEntry) == false) { if (ProjDirEntry.StartsWith(";")) { // Commented out line... skip it continue; } else { string DirPath = Path.GetFullPath(Path.Combine(RootDirectory, ProjDirEntry)); DirectoriesToSearch.Add(DirPath); } } } } } Log.TraceVerbose("\tFound {0} directories to search", DirectoriesToSearch.Count); foreach (string DirToSearch in DirectoriesToSearch) { Log.TraceVerbose("\t\tSearching {0}", DirToSearch); if (Directory.Exists(DirToSearch)) { foreach (string SubDir in Directory.EnumerateDirectories(DirToSearch, "*", SearchOption.TopDirectoryOnly)) { Log.TraceVerbose("\t\t\tFound subdir {0}", SubDir); string[] SubDirFiles = Directory.GetFiles(SubDir, "*.uproject", SearchOption.TopDirectoryOnly); foreach (string UProjFile in SubDirFiles) { Log.TraceVerbose("\t\t\t\t{0}", UProjFile); AddProject(new FileReference(UProjFile)); } } } else { Log.TraceVerbose("ProjectInfo: Skipping directory {0} from .uprojectdirs file as it doesn't exist.", DirToSearch); } } DateTime StopTime = DateTime.Now; if (BuildConfiguration.bPrintPerformanceInfo) { TimeSpan TotalProjectInfoTime = StopTime - StartTime; Log.TraceInformation("FillProjectInfo took {0} milliseconds", TotalProjectInfoTime.Milliseconds); } if (UnrealBuildTool.CommandLineContains("-dumpprojectinfo")) { UProjectInfo.DumpProjectInfo(); } }
/// <summary> /// Discover and fill in the project info /// </summary> public static void FillProjectInfo() { DateTime StartTime = DateTime.Now; List <string> DirectoriesToSearch = new List <string>(); // Find all the .uprojectdirs files contained in the root folder and add their entries to the search array string RootDirectory = Path.Combine(Utils.GetExecutingAssemblyDirectory(), "..", "..", ".."); string EngineSourceDirectory = Path.GetFullPath(Path.Combine(RootDirectory, "Engine", "Source")); foreach (var File in Directory.EnumerateFiles(RootDirectory, "*.uprojectdirs", SearchOption.TopDirectoryOnly)) { string FilePath = Path.GetFullPath(File); Log.TraceVerbose("\tFound uprojectdirs file {0}", FilePath); using (StreamReader Reader = new StreamReader(FilePath)) { string LineRead; while ((LineRead = Reader.ReadLine()) != null) { string ProjDirEntry = LineRead.Trim(); if (String.IsNullOrEmpty(ProjDirEntry) == false) { if (ProjDirEntry.StartsWith(";")) { // Commented out line... skip it continue; } else { string DirPath = Path.GetFullPath(Path.Combine(RootDirectory, ProjDirEntry)); DirectoriesToSearch.Add(DirPath); } } } } } Log.TraceVerbose("\tFound {0} directories to search", DirectoriesToSearch.Count); // Initialize the target finding time to 0 TimeSpan TotalTargetTime = DateTime.Now - DateTime.Now; foreach (string DirToSearch in DirectoriesToSearch) { Log.TraceVerbose("\t\tSearching {0}", DirToSearch); if (Directory.Exists(DirToSearch)) { foreach (string SubDir in Directory.EnumerateDirectories(DirToSearch, "*", SearchOption.TopDirectoryOnly)) { Log.TraceVerbose("\t\t\tFound subdir {0}", SubDir); string[] SubDirFiles = Directory.GetFiles(SubDir, "*.uproject", SearchOption.TopDirectoryOnly); foreach (string UProjFile in SubDirFiles) { string RelativePath = Utils.MakePathRelativeTo(UProjFile, EngineSourceDirectory); Log.TraceVerbose("\t\t\t\t{0}", RelativePath); if (!ProjectInfoDictionary.ContainsKey(RelativePath)) { DateTime TargetStartTime = DateTime.Now; string SourceFolder = Path.Combine(Path.GetDirectoryName(UProjFile), "Source"); bool bIsCodeProject = Directory.Exists(SourceFolder); AddProject(RelativePath, bIsCodeProject); if (bIsCodeProject) { // Find all Target.cs files bool bFoundTargetFiles = false; if (!FindTargetFiles(SourceFolder, ref bFoundTargetFiles)) { Log.TraceVerbose("No target files found under " + SourceFolder); } } DateTime TargetStopTime = DateTime.Now; TotalTargetTime += TargetStopTime - TargetStartTime; } } } } else { Log.TraceVerbose("ProjectInfo: Skipping directory {0} from .uprojectdirs file as it doesn't exist.", DirToSearch); } } DateTime StopTime = DateTime.Now; if (BuildConfiguration.bPrintPerformanceInfo) { TimeSpan TotalProjectInfoTime = StopTime - StartTime; Log.TraceInformation("FillProjectInfo took {0} milliseconds (AddTargetInfo {1} ms)", TotalProjectInfoTime.Milliseconds, TotalTargetTime.Milliseconds); } if (UnrealBuildTool.CommandLineContains("-dumpprojectinfo")) { UProjectInfo.DumpProjectInfo(); } }
/// <summary> /// Discover and fill in the project info /// </summary> public static void FillProjectInfo() { DateTime StartTime = DateTime.Now; List <DirectoryReference> DirectoriesToSearch = new List <DirectoryReference>(); // Find all the .uprojectdirs files contained in the root folder and add their entries to the search array string EngineSourceDirectory = Path.GetFullPath(Path.Combine(RootDirectory, "Engine", "Source")); foreach (FileReference ProjectDirsFile in UnrealBuildTool.RootDirectory.EnumerateFileReferences("*.uprojectdirs", SearchOption.TopDirectoryOnly)) { Log.TraceVerbose("\tFound uprojectdirs file {0}", ProjectDirsFile.FullName); foreach (string Line in File.ReadAllLines(ProjectDirsFile.FullName)) { string TrimLine = Line.Trim(); if (!TrimLine.StartsWith(";")) { DirectoryReference BaseProjectDir = DirectoryReference.Combine(UnrealBuildTool.RootDirectory, TrimLine); if (BaseProjectDir.IsUnderDirectory(UnrealBuildTool.RootDirectory)) { DirectoriesToSearch.Add(BaseProjectDir); } else { Log.TraceWarning("Project search path '{0}' is not under root directory, ignoring.", TrimLine); } } } } Log.TraceVerbose("\tFound {0} directories to search", DirectoriesToSearch.Count); foreach (DirectoryReference DirToSearch in DirectoriesToSearch) { Log.TraceVerbose("\t\tSearching {0}", DirToSearch.FullName); if (DirToSearch.Exists()) { foreach (DirectoryReference SubDir in DirToSearch.EnumerateDirectoryReferences("*", SearchOption.TopDirectoryOnly)) { Log.TraceVerbose("\t\t\tFound subdir {0}", SubDir.FullName); foreach (FileReference UProjFile in SubDir.EnumerateFileReferences("*.uproject", SearchOption.TopDirectoryOnly)) { Log.TraceVerbose("\t\t\t\t{0}", UProjFile.FullName); AddProject(UProjFile); } } } else { Log.TraceVerbose("ProjectInfo: Skipping directory {0} from .uprojectdirs file as it doesn't exist.", DirToSearch); } } DateTime StopTime = DateTime.Now; if (BuildConfiguration.bPrintPerformanceInfo) { TimeSpan TotalProjectInfoTime = StopTime - StartTime; Log.TraceInformation("FillProjectInfo took {0} milliseconds", TotalProjectInfoTime.Milliseconds); } if (UnrealBuildTool.CommandLineContains("-dumpprojectinfo")) { UProjectInfo.DumpProjectInfo(); } }