IsSDKValid( Bam.Core.StringArray availableSDKs, string sdk) { return(availableSDKs.Contains(sdk)); }
Evaluate() { this.ReasonToExecute = null; if (!this.PerformCompilation) { return; } var graph = Bam.Core.Graph.Instance; var factory = graph.MetaData as System.Threading.Tasks.TaskFactory; this.EvaluationTask = factory.StartNew(() => { // does the object file exist? var objectFilePath = this.GeneratedPaths[Key].Parse(); if (!System.IO.File.Exists(objectFilePath)) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.FileDoesNotExist(this.GeneratedPaths[Key]); return; } var objectFileWriteTime = System.IO.File.GetLastWriteTime(objectFilePath); // has the source file been evaluated to be rebuilt? if ((this as IRequiresSourceModule).Source.ReasonToExecute != null) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer(this.GeneratedPaths[Key], this.InputPath); return; } // is the source file newer than the object file? var sourcePath = this.InputPath.Parse(); var sourceWriteTime = System.IO.File.GetLastWriteTime(sourcePath); if (sourceWriteTime > objectFileWriteTime) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer(this.GeneratedPaths[Key], this.InputPath); return; } if (this is WinResource) { return; } // are there any headers as explicit dependencies (procedurally generated most likely), which are newer? var explicitHeadersUpdated = new Bam.Core.StringArray(); var explicitHeadersDeferred = new Bam.Core.StringArray(); foreach (var dep in this.Dependents) { if (!(dep is HeaderFile)) { continue; } if (null == dep.ReasonToExecute) { continue; } if (dep.ReasonToExecute.Reason == Bam.Core.ExecuteReasoning.EReason.InputFileIsNewer) { explicitHeadersUpdated.AddUnique((dep as HeaderFile).InputPath.Parse()); } else if (dep.ReasonToExecute.Reason == Bam.Core.ExecuteReasoning.EReason.DeferredEvaluation) { explicitHeadersDeferred.AddUnique((dep as HeaderFile).InputPath.Parse()); } } var includeSearchPaths = (this.Settings as C.ICommonCompilerSettings).IncludePaths; // implicitly search the same directory as the source path, as this is not needed to be explicitly on the include path list includeSearchPaths.AddUnique(this.CreateTokenizedString("@dir($(0))", this.InputPath)); var filesToSearch = new System.Collections.Generic.Queue <string>(); filesToSearch.Enqueue(sourcePath); var headerPathsFound = new Bam.Core.StringArray(); while (filesToSearch.Count > 0) { var fileToSearch = filesToSearch.Dequeue(); string fileContents = null; using (System.IO.TextReader reader = new System.IO.StreamReader(fileToSearch)) { fileContents = reader.ReadToEnd(); } // never know if developers are consistent with #include "header.h" or #include <header.h> so look for both // nor the amount of whitespace after #include var matches = System.Text.RegularExpressions.Regex.Matches( fileContents, "^\\s*#include\\s*[\"<]([^\\s]*)[\">]", System.Text.RegularExpressions.RegexOptions.Multiline); if (0 == matches.Count) { // no #includes return; } foreach (System.Text.RegularExpressions.Match match in matches) { var headerFile = match.Groups[1].Value; bool exists = false; // search for the file on the include paths the compiler uses foreach (var includePath in includeSearchPaths) { try { var potentialPath = System.IO.Path.Combine(includePath.Parse(), headerFile); if (!System.IO.File.Exists(potentialPath)) { continue; } potentialPath = System.IO.Path.GetFullPath(potentialPath); var headerWriteTime = System.IO.File.GetLastWriteTime(potentialPath); // early out - header is newer than generated object file if (headerWriteTime > objectFileWriteTime) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer( this.GeneratedPaths[Key], Bam.Core.TokenizedString.CreateVerbatim(potentialPath)); return; } // found #included header in list of explicitly dependent headers that have been updated if (explicitHeadersUpdated.Contains(potentialPath)) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer( this.GeneratedPaths[Key], Bam.Core.TokenizedString.CreateVerbatim(potentialPath)); return; } // found #included header in list of explicitly dependent headers that require a deferred evaluation if (explicitHeadersDeferred.Contains(potentialPath)) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.DeferredUntilBuild(this.GeneratedPaths[Key]); return; } if (!headerPathsFound.Contains(potentialPath)) { headerPathsFound.Add(potentialPath); filesToSearch.Enqueue(potentialPath); } exists = true; break; } catch (System.Exception ex) { Bam.Core.Log.MessageAll("IncludeDependency Exception: Cannot locate '{0}' on '{1}' due to {2}", headerFile, includePath, ex.Message); } } if (!exists) { #if false Bam.Core.Log.DebugMessage("***** Could not locate '{0}' on any include search path, included from {1}:\n{2}", match.Groups[1], fileToSearch, entry.includePaths.ToString('\n')); #endif } } } return; }); }
public override void Evaluate() { this.ReasonToExecute = null; var graph = Bam.Core.Graph.Instance; var factory = graph.MetaData as System.Threading.Tasks.TaskFactory; this.EvaluationTask = factory.StartNew(() => { // does the object file exist? var objectFilePath = this.GeneratedPaths[Key].Parse(); if (!System.IO.File.Exists(objectFilePath)) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.FileDoesNotExist(this.GeneratedPaths[Key]); return; } var objectFileWriteTime = System.IO.File.GetLastWriteTime(objectFilePath); // has the source file been evaluated to be rebuilt? if ((this as IRequiresSourceModule).Source.ReasonToExecute != null) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer(this.GeneratedPaths[Key], this.InputPath); return; } // is the source file newer than the object file? var sourcePath = this.InputPath.Parse(); var sourceWriteTime = System.IO.File.GetLastWriteTime(sourcePath); if (sourceWriteTime > objectFileWriteTime) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer(this.GeneratedPaths[Key], this.InputPath); return; } if (this is WinResource) { return; } // are there any headers as explicit dependencies (procedurally generated most likely), which are newer? var explicitHeadersUpdated = new Bam.Core.StringArray(); foreach (var dep in this.Dependents) { if (!(dep is HeaderFile)) { continue; } if (null == dep.ReasonToExecute) { continue; } explicitHeadersUpdated.AddUnique((dep as HeaderFile).InputPath.Parse()); } var includeSearchPaths = (this.Settings as C.ICommonCompilerSettings).IncludePaths; var filesToSearch = new System.Collections.Generic.Queue<string>(); filesToSearch.Enqueue(sourcePath); var headerPathsFound = new Bam.Core.StringArray(); while (filesToSearch.Count > 0) { var fileToSearch = filesToSearch.Dequeue(); string fileContents = null; using (System.IO.TextReader reader = new System.IO.StreamReader(fileToSearch)) { fileContents = reader.ReadToEnd(); } // never know if developers are consistent with #include "header.h" or #include <header.h> so look for both var matches = System.Text.RegularExpressions.Regex.Matches( fileContents, "^\\s*#include [\"<]([^\\s]*)[\">]", System.Text.RegularExpressions.RegexOptions.Multiline); if (0 == matches.Count) { // no #includes return; } foreach (System.Text.RegularExpressions.Match match in matches) { var headerFile = match.Groups[1].Value; bool exists = false; // search for the file on the include paths the compiler uses foreach (var includePath in includeSearchPaths) { try { var potentialPath = System.IO.Path.Combine(includePath.Parse(), headerFile); if (!System.IO.File.Exists(potentialPath)) { continue; } potentialPath = System.IO.Path.GetFullPath(potentialPath); var headerWriteTime = System.IO.File.GetLastWriteTime(potentialPath); // early out - header is newer than generated object file if (headerWriteTime > objectFileWriteTime) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer( this.GeneratedPaths[Key], Bam.Core.TokenizedString.CreateVerbatim(potentialPath)); return; } if (explicitHeadersUpdated.Contains(potentialPath)) { // found #included header in list of explicitly dependent headers that have been updated this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer( this.GeneratedPaths[Key], Bam.Core.TokenizedString.CreateVerbatim(potentialPath)); return; } if (!headerPathsFound.Contains(potentialPath)) { headerPathsFound.Add(potentialPath); filesToSearch.Enqueue(potentialPath); } exists = true; break; } catch (System.Exception ex) { Bam.Core.Log.MessageAll("IncludeDependency Exception: Cannot locate '{0}' on '{1}' due to {2}", headerFile, includePath, ex.Message); } } if (!exists) { #if false Bam.Core.Log.DebugMessage("***** Could not locate '{0}' on any include search path, included from {1}:\n{2}", match.Groups[1], fileToSearch, entry.includePaths.ToString('\n')); #endif } } } return; }); }
Evaluate() { this.ReasonToExecute = null; var graph = Bam.Core.Graph.Instance; var factory = graph.MetaData as System.Threading.Tasks.TaskFactory; this.EvaluationTask = factory.StartNew(() => { // does the object file exist? var objectFilePath = this.GeneratedPaths[Key].Parse(); if (!System.IO.File.Exists(objectFilePath)) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.FileDoesNotExist(this.GeneratedPaths[Key]); return; } var objectFileWriteTime = System.IO.File.GetLastWriteTime(objectFilePath); // has the source file been evaluated to be rebuilt? if ((this as IRequiresSourceModule).Source.ReasonToExecute != null) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer(this.GeneratedPaths[Key], this.InputPath); return; } // is the source file newer than the object file? var sourcePath = this.InputPath.Parse(); var sourceWriteTime = System.IO.File.GetLastWriteTime(sourcePath); if (sourceWriteTime > objectFileWriteTime) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer(this.GeneratedPaths[Key], this.InputPath); return; } if (this is WinResource) { return; } var includeSearchPaths = (this.Settings as C.ICommonCompilerSettings).IncludePaths; var filesToSearch = new System.Collections.Generic.Queue <string>(); filesToSearch.Enqueue(sourcePath); var headerPathsFound = new Bam.Core.StringArray(); while (filesToSearch.Count > 0) { var fileToSearch = filesToSearch.Dequeue(); string fileContents = null; using (System.IO.TextReader reader = new System.IO.StreamReader(fileToSearch)) { fileContents = reader.ReadToEnd(); } var matches = System.Text.RegularExpressions.Regex.Matches( fileContents, "^\\s*#include \"(.*)\"", System.Text.RegularExpressions.RegexOptions.Multiline); if (0 == matches.Count) { // no #includes return; } foreach (System.Text.RegularExpressions.Match match in matches) { bool exists = false; // search for the file on the include paths the compiler uses foreach (var includePath in includeSearchPaths) { try { var potentialPath = System.IO.Path.Combine(includePath.Parse(), match.Groups[1].Value); if (!System.IO.File.Exists(potentialPath)) { continue; } potentialPath = System.IO.Path.GetFullPath(potentialPath); var headerWriteTime = System.IO.File.GetLastWriteTime(potentialPath); // early out - header is newer than generated object file if (headerWriteTime > objectFileWriteTime) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer( this.GeneratedPaths[Key], Bam.Core.TokenizedString.CreateVerbatim(potentialPath)); return; } if (!headerPathsFound.Contains(potentialPath)) { headerPathsFound.Add(potentialPath); filesToSearch.Enqueue(potentialPath); } exists = true; break; } catch (System.Exception ex) { Bam.Core.Log.MessageAll("IncludeDependency Exception: Cannot locate '{0}' on '{1}' due to {2}", match.Groups[1].Value, includePath, ex.Message); } } if (!exists) { #if false Bam.Core.Log.DebugMessage("***** Could not locate '{0}' on any include search path, included from {1}:\n{2}", match.Groups[1], fileToSearch, entry.includePaths.ToString('\n')); #endif } } } return; }); }