private void ConstructCommandTLog(ITaskItem[] upToDateSources, DependencyFilter inputFilter) { IDictionary <string, string> commandLines = this.MapSourcesToCommandLines(); if (upToDateSources != null) { string text = this.SourcesPropertyName ?? "Sources"; string cmdLine = base.GenerateCommandLineExceptSwitches(new string[1] { text }, CommandLineFormat.ForTracking #if TOOLS_V14 || TOOLS_V15 , EscapeFormat.Default #endif ); foreach (ITaskItem upToDateSource in upToDateSources) { string metadata = upToDateSource.GetMetadata("FullPath"); if (inputFilter == null || inputFilter(metadata)) { commandLines[FileTracker.FormatRootingMarker(upToDateSource)] = cmdLine + " " + metadata.ToUpperInvariant(); } else { commandLines.Remove(FileTracker.FormatRootingMarker(upToDateSource)); } } } this.WriteSourcesToCommandLinesTable(commandLines); }
private void ConstructCommandTLog(ITaskItem[] upToDateSources, DependencyFilter inputFilter) { StringBuilder cmdLine = new StringBuilder(Utils.EST_MAX_CMDLINE_LEN); // This updates any newly built source files' command line in the tlog files. So the dep checker can see when we modify // compiler switches, that the command line changed and we have to rebuild the file. IDictionary <string, string> sourcesToCommandLines = MapSourcesToCommandLines(); if (upToDateSources != null) { foreach (ITaskItem item in upToDateSources) { m_currentSourceItem = item; string sourcePath = item.GetMetadata("FullPath"); if ((inputFilter == null) || inputFilter(sourcePath)) { // Add this newly built source files' command line into the tlog file cmdLine.Length = 0; cmdLine.Append(GenerateResponseFileCommands()); cmdLine.Append(" "); cmdLine.Append(sourcePath.ToUpperInvariant()); sourcesToCommandLines[FileTracker.FormatRootingMarker(item)] = cmdLine.ToString(); } else { sourcesToCommandLines.Remove(FileTracker.FormatRootingMarker(item)); } } } WriteSourcesToCommandLinesTable(sourcesToCommandLines); }
public void SaveTlog(DependencyFilter includeInTLog) { if ((this.tlogFiles != null) && (this.tlogFiles.Length > 0)) { string key = DependencyTableCache.FormatNormalizedTlogRootingMarker(this.tlogFiles); lock (DependencyTableCache.DependencyTable) { if (DependencyTableCache.DependencyTable.ContainsKey(key)) { DependencyTableCache.DependencyTable.Remove(key); } } string itemSpec = this.tlogFiles[0].ItemSpec; foreach (ITaskItem item in this.tlogFiles) { File.WriteAllText(item.ItemSpec, "", Encoding.Unicode); } using (StreamWriter writer = new StreamWriter(itemSpec, false, Encoding.Unicode)) { foreach (string str3 in this.dependencyTable.Keys) { Dictionary <string, DateTime> dictionary = this.dependencyTable[str3]; writer.WriteLine("^" + str3); foreach (string str4 in dictionary.Keys) { if ((includeInTLog == null) || includeInTLog(str4)) { writer.WriteLine(str4); } } } } } }
private void ConstructCommandTLog(ITaskItem[] upToDateSources, DependencyFilter inputFilter) { IDictionary <string, string> commandLines = this.MapSourcesToCommandLines(); if (upToDateSources != null) { string cmdLine = GenerateCommandLineCommands(VCToolTask.CommandLineFormat.ForTracking #if TOOLS_V14 || TOOLS_V15 , EscapeFormat.Default #endif ); foreach (ITaskItem upToDateSource in upToDateSources) { string metadata = upToDateSource.GetMetadata("FullPath"); if (inputFilter == null || inputFilter(metadata)) { commandLines[FileTracker.FormatRootingMarker(upToDateSource)] = cmdLine; } else { commandLines.Remove(FileTracker.FormatRootingMarker(upToDateSource)); } } } this.WriteSourcesToCommandLinesTable(commandLines); }
public void SaveTlog(DependencyFilter includeInTLog) { if (_tlogFiles != null && (_tlogFiles.Length > 0)) { string tLogRootingMarker = DependencyTableCache.FormatNormalizedTlogRootingMarker(_tlogFiles); lock (DependencyTableCache.DependencyTable) { // The tracking logs in the cache will be invalidated by this write // remove the cached entries to be sure if (DependencyTableCache.DependencyTable.ContainsKey(tLogRootingMarker)) { DependencyTableCache.DependencyTable.Remove(tLogRootingMarker); } } string firstTlog = _tlogFiles[0].ItemSpec; // empty all tlogs foreach (ITaskItem tlogFile in _tlogFiles) { File.WriteAllText(tlogFile.ItemSpec, "", Encoding.Unicode); } // Write out the dependency information as a new tlog using (StreamWriter newTlog = new StreamWriter(firstTlog, false, Encoding.Unicode)) { foreach (string fileEntry in _dependencyTable.Keys) { // Give the task a chance to filter dependencies out of the written TLog if (includeInTLog == null || includeInTLog(fileEntry)) { // Write out the entry newTlog.WriteLine(fileEntry); } } } } else if (_tlogMarker != String.Empty) { string markerDirectory = Path.GetDirectoryName(_tlogMarker); if (!Directory.Exists(markerDirectory)) { Directory.CreateDirectory(markerDirectory); } // There were no TLogs to save, so use the TLog marker // to create a marker file that can be used for up-to-date check. File.WriteAllText(_tlogMarker, ""); } }
public void SaveTlog(DependencyFilter includeInTLog) { if (_tlogFiles != null && (_tlogFiles.Length > 0)) { string tLogRootingMarker = DependencyTableCache.FormatNormalizedTlogRootingMarker(_tlogFiles); lock (DependencyTableCache.DependencyTable) { // The tracking logs in the cache will be invalidated by this compaction // remove the cached entries to be sure if (DependencyTableCache.DependencyTable.ContainsKey(tLogRootingMarker)) { DependencyTableCache.DependencyTable.Remove(tLogRootingMarker); } } string firstTlog = _tlogFiles[0].ItemSpec; // empty all tlogs foreach (ITaskItem tlogFile in _tlogFiles) { File.WriteAllText(tlogFile.ItemSpec, "", System.Text.Encoding.Unicode); } // Write out the dependency information as a new tlog using (StreamWriter outputs = new StreamWriter(firstTlog, false, System.Text.Encoding.Unicode)) { foreach (string rootingMarker in _dependencyTable.Keys) { Dictionary <string, DateTime> dependencies = _dependencyTable[rootingMarker]; outputs.WriteLine("^" + rootingMarker); foreach (string file in dependencies.Keys) { // Give the task a chance to filter dependencies out of the written TLog if (includeInTLog == null || includeInTLog(file)) { // Write out the entry outputs.WriteLine(file); } } } } } }
public void SaveTlog(DependencyFilter includeInTLog) { if ((this.tlogFiles != null) && (this.tlogFiles.Length > 0)) { string key = DependencyTableCache.FormatNormalizedTlogRootingMarker(this.tlogFiles); lock (DependencyTableCache.DependencyTable) { if (DependencyTableCache.DependencyTable.ContainsKey(key)) { DependencyTableCache.DependencyTable.Remove(key); } } string itemSpec = this.tlogFiles[0].ItemSpec; foreach (ITaskItem item in this.tlogFiles) { File.WriteAllText(item.ItemSpec, "", Encoding.Unicode); } using (StreamWriter writer = new StreamWriter(itemSpec, false, Encoding.Unicode)) { foreach (string str3 in this.dependencyTable.Keys) { if ((includeInTLog == null) || includeInTLog(str3)) { writer.WriteLine(str3); } } return; } } if (this.tlogMarker != string.Empty) { string directoryName = Path.GetDirectoryName(this.tlogMarker); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllText(this.tlogMarker, ""); } }
public void SaveTlog(DependencyFilter includeInTLog) { if (_tlogFiles != null && (_tlogFiles.Length > 0)) { string tLogRootingMarker = DependencyTableCache.FormatNormalizedTlogRootingMarker(_tlogFiles); lock (DependencyTableCache.DependencyTable) { // The tracking logs in the cache will be invalidated by this compaction // remove the cached entries to be sure if (DependencyTableCache.DependencyTable.ContainsKey(tLogRootingMarker)) { DependencyTableCache.DependencyTable.Remove(tLogRootingMarker); } } string firstTlog = _tlogFiles[0].ItemSpec; // empty all tlogs foreach (ITaskItem tlogFile in _tlogFiles) { File.WriteAllText(tlogFile.ItemSpec, "", System.Text.Encoding.Unicode); } // Write out the dependency information as a new tlog using (StreamWriter outputs = new StreamWriter(firstTlog, false, System.Text.Encoding.Unicode)) { foreach (string rootingMarker in _dependencyTable.Keys) { Dictionary<string, DateTime> dependencies = _dependencyTable[rootingMarker]; outputs.WriteLine("^" + rootingMarker); foreach (string file in dependencies.Keys) { // Give the task a chance to filter dependencies out of the written TLog if (includeInTLog == null || includeInTLog(file)) { // Write out the entry outputs.WriteLine(file); } } } } } }
public void SaveTlog(DependencyFilter includeInTLog) { if ((this.tlogFiles != null) && (this.tlogFiles.Length > 0)) { string key = DependencyTableCache.FormatNormalizedTlogRootingMarker(this.tlogFiles); lock (DependencyTableCache.DependencyTable) { if (DependencyTableCache.DependencyTable.ContainsKey(key)) { DependencyTableCache.DependencyTable.Remove(key); } } string itemSpec = this.tlogFiles[0].ItemSpec; foreach (ITaskItem item in this.tlogFiles) { File.WriteAllText(item.ItemSpec, "", Encoding.Unicode); } using (StreamWriter writer = new StreamWriter(itemSpec, false, Encoding.Unicode)) { foreach (string str3 in this.dependencyTable.Keys) { Dictionary<string, DateTime> dictionary = this.dependencyTable[str3]; writer.WriteLine("^" + str3); foreach (string str4 in dictionary.Keys) { if ((includeInTLog == null) || includeInTLog(str4)) { writer.WriteLine(str4); } } } } } }
private void ConstructCommandTLog( ITaskItem[] upToDateSources, DependencyFilter inputFilter ) { StringBuilder cmdLine = new StringBuilder( Utils.EST_MAX_CMDLINE_LEN ); // This updates any newly built source files' command line in the tlog files. So the dep checker can see when we modify // compiler switches, that the command line changed and we have to rebuild the file. IDictionary<string, string> sourcesToCommandLines = MapSourcesToCommandLines(); if ( upToDateSources != null ) { foreach ( ITaskItem item in upToDateSources ) { m_currentSourceItem = item; string sourcePath = item.GetMetadata( "FullPath" ); if ( ( inputFilter == null ) || inputFilter( sourcePath ) ) { // Add this newly built source files' command line into the tlog file cmdLine.Length = 0; cmdLine.Append( GenerateResponseFileCommands() ); cmdLine.Append( " " ); cmdLine.Append( sourcePath.ToUpperInvariant() ); sourcesToCommandLines[FileTracker.FormatRootingMarker( item )] = cmdLine.ToString(); } else { sourcesToCommandLines.Remove( FileTracker.FormatRootingMarker( item ) ); } } } WriteSourcesToCommandLinesTable( sourcesToCommandLines ); }
public void SaveTlog(DependencyFilter includeInTLog) { // If there are no tlog files, then this will be a clean build // so there is no need to write a new tlog if (_tlogFiles != null && (_tlogFiles.Length > 0)) { string tLogRootingMarker = DependencyTableCache.FormatNormalizedTlogRootingMarker(_tlogFiles); lock (DependencyTableCache.DependencyTable) { // The tracking logs in the cache will be invalidated by this compaction // remove the cached entries if (DependencyTableCache.DependencyTable.ContainsKey(tLogRootingMarker)) { DependencyTableCache.DependencyTable.Remove(tLogRootingMarker); } } string firstTlog = _tlogFiles[0].ItemSpec; // empty all tlogs foreach (ITaskItem tlogFile in _tlogFiles) { File.WriteAllText(tlogFile.ItemSpec, "", System.Text.Encoding.Unicode); } // Write out the remaining dependency information as a new tlog using (StreamWriter inputs = new StreamWriter(firstTlog, false, System.Text.Encoding.Unicode)) { if (!_maintainCompositeRootingMarkers) { foreach (string primaryFile in _dependencyTable.Keys) { if (!primaryFile.Contains("|")) // composite roots are not needed { Dictionary<string, string> dependencies = _dependencyTable[primaryFile]; inputs.WriteLine("^" + primaryFile); foreach (string file in dependencies.Keys) { // We only want to write the tlog entry if it isn't the primary file // and we aren't being asked to filter it out if (file != primaryFile && (includeInTLog == null || includeInTLog(file))) { inputs.WriteLine(file); } } } } } else { // Just output the rooting markers and their dependencies -- we don't want to // compact out the composite ones. foreach (string rootingMarker in _dependencyTable.Keys) { Dictionary<string, string> dependencies = _dependencyTable[rootingMarker]; inputs.WriteLine("^" + rootingMarker); foreach (string file in dependencies.Keys) { // Give the task a chance to filter dependencies out of the written TLog if (includeInTLog == null || includeInTLog(file)) { // Write out the entry inputs.WriteLine(file); } } } } } } }
private void ConstructCommandTLog(ITaskItem[] upToDateSources, DependencyFilter inputFilter) { IDictionary<string, string> commandLines = this.MapSourcesToCommandLines(); if (upToDateSources != null) { string cmdLine = GenerateCommandLineCommands(VCToolTask.CommandLineFormat.ForTracking #if TOOLS_V14 , EscapeFormat.Default #endif ); foreach (ITaskItem upToDateSource in upToDateSources) { string metadata = upToDateSource.GetMetadata("FullPath"); if (inputFilter == null || inputFilter(metadata)) commandLines[FileTracker.FormatRootingMarker(upToDateSource)] = cmdLine; else commandLines.Remove(FileTracker.FormatRootingMarker(upToDateSource)); } } this.WriteSourcesToCommandLinesTable(commandLines); }
protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) { responseFileCommands = responseFileCommands.Replace("[PackageName]", PackageName); commandLineCommands = commandLineCommands.Replace("[PackageName]", PackageName); string src = ""; foreach (var item in Sources) src += " " + item.ToString(); if (ShowCommandLine) Log.LogMessage(MessageImportance.High, pathToTool + " " + responseFileCommands + " " + commandLineCommands); else Log.LogMessage(MessageImportance.High, "Compiling" + src); /* return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands); */ int num = 0; try { num = this.TrackerExecuteTool(pathToTool, responseFileCommands, commandLineCommands); return num; } finally { if (this.MinimalRebuildFromTracking || this.TrackFileAccess) { CanonicalTrackedOutputFiles trackedOutputFiles = new CanonicalTrackedOutputFiles(this.TLogWriteFiles); CanonicalTrackedInputFiles trackedInputFiles = new CanonicalTrackedInputFiles(this.TLogReadFiles, this.Sources, this.ExcludedInputPaths, trackedOutputFiles, true, this.MaintainCompositeRootingMarkers); DependencyFilter includeInTLog = new DependencyFilter(this.OutputDependencyFilter); DependencyFilter dependencyFilter = new DependencyFilter(this.InputDependencyFilter); this.trackedInputFilesToRemove = new Dictionary<string, ITaskItem>((IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase); if (this.TrackedInputFilesToIgnore != null) { foreach (ITaskItem taskItem in this.TrackedInputFilesToIgnore) this.trackedInputFilesToRemove.Add(taskItem.GetMetadata("FullPath"), taskItem); } this.trackedOutputFilesToRemove = new Dictionary<string, ITaskItem>((IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase); if (this.TrackedOutputFilesToIgnore != null) { foreach (ITaskItem taskItem in this.TrackedOutputFilesToIgnore) this.trackedOutputFilesToRemove.Add(taskItem.GetMetadata("FullPath"), taskItem); } trackedOutputFiles.RemoveDependenciesFromEntryIfMissing(this.SourcesCompiled); trackedInputFiles.RemoveDependenciesFromEntryIfMissing(this.SourcesCompiled); if (num != 0) { ITaskItem[] source1; ITaskItem[] upToDateSources; if (this.SourcesCompiled.Length > 1) { KeyValuePair<string, bool>[] keyValuePairArray = new KeyValuePair<string, bool>[]{ new KeyValuePair<string, bool>("ObjectFile", true), /* new KeyValuePair<string, bool>("BrowseInformationFile", this.BrowseInformation), new KeyValuePair<string, bool>("XMLDocumentationFileName", this.GenerateXMLDocumentationFiles) */ }; foreach (ITaskItem source2 in this.Sources) { string sourceKey = FileTracker.FormatRootingMarker(source2); foreach (KeyValuePair<string, bool> keyValuePair in keyValuePairArray) { string metadata = source2.GetMetadata(keyValuePair.Key); if (keyValuePair.Value && !string.IsNullOrEmpty(metadata)) trackedOutputFiles.AddComputedOutputForSourceRoot(sourceKey, metadata); } } source1 = trackedInputFiles.ComputeSourcesNeedingCompilation(); List<ITaskItem> taskItemList = new List<ITaskItem>(); int index = 0; foreach (ITaskItem taskItem in this.SourcesCompiled) { if (index >= source1.Length) taskItemList.Add(taskItem); else if (!source1[index].Equals((object) taskItem)) taskItemList.Add(taskItem); else ++index; } upToDateSources = taskItemList.ToArray(); foreach (ITaskItem source2 in this.Sources) { string sourceRoot = FileTracker.FormatRootingMarker(source2); foreach (KeyValuePair<string, bool> keyValuePair in keyValuePairArray) { string metadata = source2.GetMetadata(keyValuePair.Key); if (keyValuePair.Value && !string.IsNullOrEmpty(metadata)) trackedOutputFiles.RemoveOutputForSourceRoot(sourceRoot, metadata); } } } else { source1 = this.SourcesCompiled; upToDateSources = new ITaskItem[0]; } //trackedOutputFiles.RemoveEntriesForSource(source1, this.preprocessOutput); trackedOutputFiles.SaveTlog(includeInTLog); trackedInputFiles.RemoveEntriesForSource(source1); trackedInputFiles.SaveTlog(dependencyFilter); this.ConstructCommandTLog(upToDateSources, dependencyFilter); } else { this.RemoveTaskSpecificInputs(trackedInputFiles); trackedOutputFiles.SaveTlog(includeInTLog); trackedInputFiles.SaveTlog(dependencyFilter); this.ConstructCommandTLog(this.SourcesCompiled, dependencyFilter); } TrackedVCToolTask.DeleteEmptyFile(this.TLogWriteFiles); TrackedVCToolTask.DeleteEmptyFile(this.TLogReadFiles); } } }
protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) { responseFileCommands = responseFileCommands.Replace("[PackageName]", PackageName); commandLineCommands = commandLineCommands.Replace("[PackageName]", PackageName); string src = ""; foreach (var item in Sources) { src += " " + item.ToString(); } if (ShowCommandLine) { Log.LogMessage(MessageImportance.High, pathToTool + " " + commandLineCommands + " " + responseFileCommands); } else { Log.LogMessage(MessageImportance.High, "Compiling" + src); } /* * return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands); */ int num = 0; try { num = this.TrackerExecuteTool(pathToTool, responseFileCommands, commandLineCommands); return(num); } finally { if (this.MinimalRebuildFromTracking || this.TrackFileAccess) { CanonicalTrackedOutputFiles trackedOutputFiles = new CanonicalTrackedOutputFiles(this.TLogWriteFiles); CanonicalTrackedInputFiles trackedInputFiles = new CanonicalTrackedInputFiles(this.TLogReadFiles, this.Sources, this.ExcludedInputPaths, trackedOutputFiles, true, this.MaintainCompositeRootingMarkers); DependencyFilter includeInTLog = new DependencyFilter(this.OutputDependencyFilter); DependencyFilter dependencyFilter = new DependencyFilter(this.InputDependencyFilter); this.trackedInputFilesToRemove = new Dictionary <string, ITaskItem>((IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase); if (this.TrackedInputFilesToIgnore != null) { foreach (ITaskItem taskItem in this.TrackedInputFilesToIgnore) { this.trackedInputFilesToRemove.Add(taskItem.GetMetadata("FullPath"), taskItem); } } this.trackedOutputFilesToRemove = new Dictionary <string, ITaskItem>((IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase); if (this.TrackedOutputFilesToIgnore != null) { foreach (ITaskItem taskItem in this.TrackedOutputFilesToIgnore) { this.trackedOutputFilesToRemove.Add(taskItem.GetMetadata("FullPath"), taskItem); } } trackedOutputFiles.RemoveDependenciesFromEntryIfMissing(this.SourcesCompiled); trackedInputFiles.RemoveDependenciesFromEntryIfMissing(this.SourcesCompiled); if (num != 0) { ITaskItem[] source1; ITaskItem[] upToDateSources; if (this.SourcesCompiled.Length > 1) { KeyValuePair <string, bool>[] keyValuePairArray = new KeyValuePair <string, bool>[] { new KeyValuePair <string, bool>("ObjectFile", true), /* * new KeyValuePair<string, bool>("BrowseInformationFile", this.BrowseInformation), * new KeyValuePair<string, bool>("XMLDocumentationFileName", this.GenerateXMLDocumentationFiles) */ }; foreach (ITaskItem source2 in this.Sources) { string sourceKey = FileTracker.FormatRootingMarker(source2); foreach (KeyValuePair <string, bool> keyValuePair in keyValuePairArray) { string metadata = source2.GetMetadata(keyValuePair.Key); if (keyValuePair.Value && !string.IsNullOrEmpty(metadata)) { trackedOutputFiles.AddComputedOutputForSourceRoot(sourceKey, metadata); } } } source1 = trackedInputFiles.ComputeSourcesNeedingCompilation(); List <ITaskItem> taskItemList = new List <ITaskItem>(); int index = 0; foreach (ITaskItem taskItem in this.SourcesCompiled) { if (index >= source1.Length) { taskItemList.Add(taskItem); } else if (!source1[index].Equals((object)taskItem)) { taskItemList.Add(taskItem); } else { ++index; } } upToDateSources = taskItemList.ToArray(); foreach (ITaskItem source2 in this.Sources) { string sourceRoot = FileTracker.FormatRootingMarker(source2); foreach (KeyValuePair <string, bool> keyValuePair in keyValuePairArray) { string metadata = source2.GetMetadata(keyValuePair.Key); if (keyValuePair.Value && !string.IsNullOrEmpty(metadata)) { trackedOutputFiles.RemoveOutputForSourceRoot(sourceRoot, metadata); } } } } else { source1 = this.SourcesCompiled; upToDateSources = new ITaskItem[0]; } //trackedOutputFiles.RemoveEntriesForSource(source1, this.preprocessOutput); trackedOutputFiles.SaveTlog(includeInTLog); trackedInputFiles.RemoveEntriesForSource(source1); trackedInputFiles.SaveTlog(dependencyFilter); this.ConstructCommandTLog(upToDateSources, dependencyFilter); } else { this.RemoveTaskSpecificInputs(trackedInputFiles); trackedOutputFiles.SaveTlog(includeInTLog); trackedInputFiles.SaveTlog(dependencyFilter); this.ConstructCommandTLog(this.SourcesCompiled, dependencyFilter); } TrackedVCToolTask.DeleteEmptyFile(this.TLogWriteFiles); TrackedVCToolTask.DeleteEmptyFile(this.TLogReadFiles); } } }