protected void AddPrerequisiteSourceFile(STBuildTarget Target, ISTBuildPlatform BuildPlatform, CPPEnvironment CompileEnvironment, FileItem SourceFile, List<FileItem> PrerequisiteItems) { PrerequisiteItems.Add(SourceFile); var RemoteThis = this as RemoteToolChain; bool bAllowUploading = RemoteThis != null && BuildHostPlatform.Current.Platform != STTargetPlatform.Mac; // Don't use remote features when compiling from a Mac if (bAllowUploading) { RemoteThis.QueueFileForBatchUpload(SourceFile); } if (!BuildConfiguration.bUseExperimentalFastBuildIteration) // In fast build iteration mode, we'll gather includes later on { // @todo fastubt: What if one of the prerequisite files has become missing since it was updated in our cache? (usually, because a coder eliminated the source file) // -> Two CASES: // 1) NOT WORKING: Non-unity file went away (SourceFile in this context). That seems like an existing old use case. Compile params or Response file should have changed? // 2) WORKING: Indirect file went away (unity'd original source file or include). This would return a file that no longer exists and adds to the prerequiteitems list var IncludedFileList = CPPEnvironment.FindAndCacheAllIncludedFiles(Target, SourceFile, BuildPlatform, CompileEnvironment.Config.CPPIncludeInfo, bOnlyCachedDependencies: BuildConfiguration.bUseExperimentalFastDependencyScan); foreach (FileItem IncludedFile in IncludedFileList) { PrerequisiteItems.Add(IncludedFile); if (bAllowUploading && !BuildConfiguration.bUseExperimentalFastDependencyScan) // With fast dependency scanning, we will not have an exhaustive list of dependencies here. We rely on PostCodeGeneration() to upload these files. { RemoteThis.QueueFileForBatchUpload(IncludedFile); } } } }
private static FileItem CachePCHUsageForCPPFile(STBuildTarget Target, FileItem CPPFile, ISTBuildPlatform BuildPlatform, List<string> IncludePathsToSearch, Dictionary<string, FileItem> IncludeFileSearchDictionary) { // @todo fastubt: We don't really need to scan every file looking for PCH headers, just need one. The rest is just for error checking. // @todo fastubt: We don't need all of the direct includes either. We just need the first, unless we want to check for errors. bool HasUObjects; List<DependencyInclude> DirectIncludeFilenames = CPPEnvironment.GetDirectIncludeDependencies(Target, CPPFile, BuildPlatform, bOnlyCachedDependencies: false, HasUObjects: out HasUObjects); if (BuildConfiguration.bPrintDebugInfo) { Log.TraceVerbose("Found direct includes for {0}: {1}", Path.GetFileName(CPPFile.AbsolutePath), string.Join(", ", DirectIncludeFilenames.Select(F => F.IncludeName))); } if (DirectIncludeFilenames.Count == 0) { return null; } var FirstInclude = DirectIncludeFilenames[0]; // The pch header should always be the first include in the source file. // NOTE: This is not an absolute path. This is just the literal include string from the source file! CPPFile.PCHHeaderNameInCode = FirstInclude.IncludeName; // Resolve the PCH header to an absolute path. // Check NullOrEmpty here because if the file could not be resolved we need to throw an exception if (!string.IsNullOrEmpty(FirstInclude.IncludeResolvedName) && // ignore any preexisting resolve cache if we are not configured to use it. BuildConfiguration.bUseIncludeDependencyResolveCache && // if we are testing the resolve cache, we force UBT to resolve every time to look for conflicts !BuildConfiguration.bTestIncludeDependencyResolveCache) { CPPFile.PrecompiledHeaderIncludeFilename = FirstInclude.IncludeResolvedName; return FileItem.GetItemByFullPath(CPPFile.PrecompiledHeaderIncludeFilename); } // search the include paths to resolve the file. FileItem PrecompiledHeaderIncludeFile = CPPEnvironment.FindIncludedFile(CPPFile.PCHHeaderNameInCode, !BuildConfiguration.bCheckExternalHeadersForModification, IncludePathsToSearch, IncludeFileSearchDictionary); if (PrecompiledHeaderIncludeFile == null) { throw new BuildException("The first include statement in source file '{0}' is trying to include the file '{1}' as the precompiled header, but that file could not be located in any of the module's include search paths.", CPPFile.AbsolutePath, CPPFile.PCHHeaderNameInCode); } CPPEnvironment.IncludeDependencyCache[Target].CacheResolvedIncludeFullPath(CPPFile, 0, PrecompiledHeaderIncludeFile.AbsolutePath); CPPFile.PrecompiledHeaderIncludeFilename = PrecompiledHeaderIncludeFile.AbsolutePath; return PrecompiledHeaderIncludeFile; }