protected override bool ComputeOutOfDateSources() { if (InputFiles[0].GetMetadata("PartialCompilation") != "true") { AssignDefaultTLogPaths(); SourceOutputs = new CanonicalTrackedOutputFiles(this, TLogWriteFiles); foreach (ITaskItem file in InputFiles) { SourceOutputs.AddComputedOutputForSourceRoot(FileTracker.FormatRootingMarker(file), file.GetMetadata("OutputFile")); } SourceOutputs.SaveTlog(); } return(base.ComputeOutOfDateSources()); }
protected override CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem[] compiledSources) { string path = Path.Combine(TlogDirectory, WriteTLogFilename); TaskItem item = new TaskItem(path); CanonicalTrackedOutputFiles trackedFiles = new CanonicalTrackedOutputFiles(new TaskItem[] { item }); foreach (ITaskItem sourceItem in compiledSources) { //remove this entry associated with compiled source which is about to be recomputed trackedFiles.RemoveEntriesForSource(sourceItem); //add entry with updated information trackedFiles.AddComputedOutputForSourceRoot(Path.GetFullPath(sourceItem.ItemSpec).ToUpperInvariant(), Path.GetFullPath(GetObjectFile(sourceItem)).ToUpperInvariant()); } //output tlog trackedFiles.SaveTlog(); return(trackedFiles); }
private CanonicalTrackedOutputFiles ConstructWriteTLog(ITaskItem[] upToDateSources) { // Remove any files we're about to compile from the log TaskItem item = new TaskItem(Path.Combine(TrackerIntermediateDirectory, WriteTLogNames[0])); CanonicalTrackedOutputFiles files = new CanonicalTrackedOutputFiles(new TaskItem[] { item }); files.RemoveEntriesForSource(Sources); // Add in the files we're compiling right now. Essentially just updating their output object filenames. foreach (ITaskItem sourceItem in upToDateSources) { string sourcePath = Path.GetFullPath(sourceItem.ItemSpec).ToUpperInvariant(); string objectFile = Path.GetFullPath(sourceItem.GetMetadata("ObjectFileName")).ToUpperInvariant(); files.AddComputedOutputForSourceRoot(sourcePath, objectFile); } // Save it out files.SaveTlog(); // Pass onto the ReadTLog saving return(files); }
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); } } }