Example #1
0
        protected virtual int PostExecuteTool(int exitCode)
        {
            if (!MinimalRebuildFromTracking && !TrackFileAccess)
            {
                return(exitCode);
            }

            SourceOutputs      = new CanonicalTrackedOutputFiles(TLogWriteFiles);
            SourceDependencies = new CanonicalTrackedInputFiles(
                TLogReadFiles,
                TrackedInputFiles,
                ExcludedInputPaths,
                SourceOutputs,
                false,
                MaintainCompositeRootingMarkers);

            IDictionary <string, string> sourcesToCommandLines = MapSourcesToCommandLines();

            if (exitCode != 0)
            {
                SourceOutputs.RemoveEntriesForSource(SourcesCompiled);
                SourceOutputs.SaveTlog();
                SourceDependencies.RemoveEntriesForSource(SourcesCompiled);
                SourceDependencies.SaveTlog();
                if (TrackCommandLines)
                {
                    if (MaintainCompositeRootingMarkers)
                    {
                        sourcesToCommandLines.Remove(
                            FileTracker.FormatRootingMarker(SourcesCompiled));
                    }
                    else
                    {
                        foreach (ITaskItem item in SourcesCompiled)
                        {
                            sourcesToCommandLines.Remove(
                                FileTracker.FormatRootingMarker(item));
                        }
                    }
                    WriteSourcesToCommandLinesTable(sourcesToCommandLines);
                }
            }
            else
            {
                AddTaskSpecificOutputs(SourcesCompiled, SourceOutputs);
                RemoveTaskSpecificOutputs(SourceOutputs);
                SourceOutputs.RemoveDependenciesFromEntryIfMissing(SourcesCompiled);

                string[] roots = null;
                if (MaintainCompositeRootingMarkers)
                {
                    roots = SourceOutputs.RemoveRootsWithSharedOutputs(SourcesCompiled);
                    foreach (string marker in roots)
                    {
                        SourceDependencies.RemoveEntryForSourceRoot(marker);
                    }
                }

                if (TrackedOutputFilesToIgnore != null && (TrackedOutputFilesToIgnore.Length > 0))
                {
                    var trackedOutputFilesToRemove = new Dictionary <string, ITaskItem>(
                        StringComparer.OrdinalIgnoreCase);
                    foreach (ITaskItem item in TrackedOutputFilesToIgnore)
                    {
                        trackedOutputFilesToRemove.Add(item.GetMetadata("FullPath"), item);
                    }
                    SourceOutputs.SaveTlog(
                        fullTrackedPath => !trackedOutputFilesToRemove.ContainsKey(fullTrackedPath));
                }
                else
                {
                    SourceOutputs.SaveTlog();
                }

                FileUtilities.DeleteEmptyFile(TLogWriteFiles);
                RemoveTaskSpecificInputs(SourceDependencies);
                SourceDependencies.RemoveDependenciesFromEntryIfMissing(SourcesCompiled);
                if (TrackedInputFilesToIgnore != null && TrackedInputFilesToIgnore.Length > 0)
                {
                    var trackedInputFilesToRemove = new Dictionary <string, ITaskItem>(
                        StringComparer.OrdinalIgnoreCase);
                    foreach (ITaskItem item in TrackedInputFilesToIgnore)
                    {
                        trackedInputFilesToRemove.Add(item.GetMetadata("FullPath"), item);
                    }
                    SourceDependencies.SaveTlog(
                        fullTrackedPath => !trackedInputFilesToRemove.ContainsKey(fullTrackedPath));
                }
                else
                {
                    SourceDependencies.SaveTlog();
                }

                FileUtilities.DeleteEmptyFile(TLogReadFiles);
                if (MaintainCompositeRootingMarkers)
                {
                    sourcesToCommandLines[FileTracker.FormatRootingMarker(SourcesCompiled)] =
                        GenerateCommandLine(CommandLineFormat.ForTracking);
                    if (roots != null)
                    {
                        foreach (string root in roots)
                        {
                            sourcesToCommandLines.Remove(root);
                        }
                    }
                }
                else
                {
                    string cmdLine = GenerateCommandLineExceptSources(
                        CommandLineFormat.ForTracking);
                    foreach (ITaskItem item in SourcesCompiled)
                    {
                        sourcesToCommandLines[FileTracker.FormatRootingMarker(item)] =
                            cmdLine + " " + item.GetMetadata("FullPath").ToUpperInvariant();
                    }
                }

                WriteSourcesToCommandLinesTable(sourcesToCommandLines);
            }

            return(exitCode);
        }
Example #2
0
        private void FinishExecute(bool success)
        {
            if (!MinimalRebuildFromTracking && !TrackFileAccess)
            {
                return;
            }

            var outputs       = new CanonicalTrackedOutputFiles(TLogWriteFiles);
            var compactInputs = new CanonicalTrackedInputFiles(
                TLogReadFiles,
                TrackedInputFiles,
                ExcludedInputPaths,
                outputs,
                false,
                MaintainCompositeRootingMarkers);

            IDictionary <string, string> sourcesToOptions = MapSourcesToOptions();

            if (!success)
            {
                outputs.RemoveEntriesForSource(SourcesCompiled);
                outputs.SaveTlog();
                compactInputs.RemoveEntriesForSource(SourcesCompiled);
                compactInputs.SaveTlog();
                if (MaintainCompositeRootingMarkers)
                {
                    sourcesToOptions.Remove(
                        FileTracker.FormatRootingMarker(SourcesCompiled));
                }
                else
                {
                    foreach (ITaskItem item in SourcesCompiled)
                    {
                        sourcesToOptions.Remove(
                            FileTracker.FormatRootingMarker(item));
                    }
                }
                WriteSourcesToOptionsTable(sourcesToOptions);
            }
            else
            {
                AddTaskSpecificOutputs(SourcesCompiled, outputs);
                RemoveTaskSpecificOutputs(outputs);
                outputs.RemoveDependenciesFromEntryIfMissing(SourcesCompiled);

                string[] roots = null;
                if (MaintainCompositeRootingMarkers)
                {
                    roots = outputs.RemoveRootsWithSharedOutputs(SourcesCompiled);
                    foreach (string marker in roots)
                    {
                        compactInputs.RemoveEntryForSourceRoot(marker);
                    }
                }

                if (TrackedOutputFilesToIgnore != null && (TrackedOutputFilesToIgnore.Length > 0))
                {
                    var trackedOutputFilesToRemove = new Dictionary <string, ITaskItem>(
                        StringComparer.OrdinalIgnoreCase);
                    foreach (ITaskItem item in TrackedOutputFilesToIgnore)
                    {
                        trackedOutputFilesToRemove.Add(item.GetMetadata("FullPath"), item);
                    }
                    outputs.SaveTlog(
                        fullTrackedPath => !trackedOutputFilesToRemove.ContainsKey(fullTrackedPath));
                }
                else
                {
                    outputs.SaveTlog();
                }

                FileUtilities.DeleteEmptyFile(TLogWriteFiles);
                RemoveTaskSpecificInputs(compactInputs);
                compactInputs.RemoveDependenciesFromEntryIfMissing(SourcesCompiled);
                if (TrackedInputFilesToIgnore != null && TrackedInputFilesToIgnore.Length > 0)
                {
                    var trackedInputFilesToRemove = new Dictionary <string, ITaskItem>(
                        StringComparer.OrdinalIgnoreCase);
                    foreach (ITaskItem item in TrackedInputFilesToIgnore)
                    {
                        trackedInputFilesToRemove.Add(item.GetMetadata("FullPath"), item);
                    }
                    compactInputs.SaveTlog(
                        fullTrackedPath => !trackedInputFilesToRemove.ContainsKey(fullTrackedPath));
                }
                else
                {
                    compactInputs.SaveTlog();
                }

                FileUtilities.DeleteEmptyFile(TLogReadFiles);
                if (MaintainCompositeRootingMarkers)
                {
                    sourcesToOptions[FileTracker.FormatRootingMarker(SourcesCompiled)] =
                        GenerateOptions(OptionFormat.ForTracking);
                    if (roots != null)
                    {
                        foreach (string root in roots)
                        {
                            sourcesToOptions.Remove(root);
                        }
                    }
                }
                else
                {
                    string options = GenerateOptionsExceptSources(OptionFormat.ForTracking);
                    foreach (ITaskItem item in SourcesCompiled)
                    {
                        sourcesToOptions[FileTracker.FormatRootingMarker(item)] =
                            options + " " + item.GetMetadata("FullPath").ToUpperInvariant();
                    }
                }

                WriteSourcesToOptionsTable(sourcesToOptions);
            }
        }
Example #3
0
        protected int ExecuteTool2(string pathToTool, string responseFileCommands, string commandLineCommands)
        {
            int num = 0;

            try
            {
                num = this.TrackerExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
            }
            finally
            {
                if (this.MinimalRebuildFromTracking || this.TrackFileAccess)
                {
                    CanonicalTrackedOutputFiles outputs       = new CanonicalTrackedOutputFiles(this.TLogWriteFiles);
                    CanonicalTrackedInputFiles  compactInputs = new CanonicalTrackedInputFiles(this.TLogReadFiles, this.TrackedInputFiles, this.ExcludedInputPaths, outputs, false, this.MaintainCompositeRootingMarkers);
                    string[] strArray = null;
                    IDictionary <string, string> sourcesToCommandLines = this.MapSourcesToCommandLines();
                    if (num != 0)
                    {
                        outputs.RemoveEntriesForSource(this.SourcesCompiled);
                        outputs.SaveTlog();
                        compactInputs.RemoveEntriesForSource(this.SourcesCompiled);
                        compactInputs.SaveTlog();
                        if (this.MaintainCompositeRootingMarkers)
                        {
                            sourcesToCommandLines.Remove(FileTracker.FormatRootingMarker(this.SourcesCompiled));
                        }
                        else
                        {
                            foreach (ITaskItem item in this.SourcesCompiled)
                            {
                                sourcesToCommandLines.Remove(FileTracker.FormatRootingMarker(item));
                            }
                        }
                        this.WriteSourcesToCommandLinesTable(sourcesToCommandLines);
                    }
                    else
                    {
                        this.AddTaskSpecificOutputs(this.SourcesCompiled, outputs);
                        this.RemoveTaskSpecificOutputs(outputs);
                        outputs.RemoveDependenciesFromEntryIfMissing(this.SourcesCompiled);
                        if (this.MaintainCompositeRootingMarkers)
                        {
                            strArray = outputs.RemoveRootsWithSharedOutputs(this.SourcesCompiled);
                            foreach (string str in strArray)
                            {
                                compactInputs.RemoveEntryForSourceRoot(str);
                            }
                        }
                        if ((this.TrackedOutputFilesToIgnore != null) && (this.TrackedOutputFilesToIgnore.Length > 0))
                        {
                            Dictionary <string, ITaskItem> trackedOutputFilesToRemove = new Dictionary <string, ITaskItem>(StringComparer.OrdinalIgnoreCase);
                            foreach (ITaskItem item2 in this.TrackedOutputFilesToIgnore)
                            {
                                trackedOutputFilesToRemove.Add(item2.GetMetadata("FullPath"), item2);
                            }
                            outputs.SaveTlog(delegate(string fullTrackedPath)
                            {
                                if (trackedOutputFilesToRemove.ContainsKey(fullTrackedPath))
                                {
                                    return(false);
                                }
                                return(true);
                            });
                        }
                        else
                        {
                            outputs.SaveTlog();
                        }
                        this.RemoveTaskSpecificInputs(compactInputs);
                        compactInputs.RemoveDependenciesFromEntryIfMissing(this.SourcesCompiled);
                        if ((this.TrackedInputFilesToIgnore != null) && (this.TrackedInputFilesToIgnore.Length > 0))
                        {
                            Dictionary <string, ITaskItem> trackedInputFilesToRemove = new Dictionary <string, ITaskItem>(StringComparer.OrdinalIgnoreCase);
                            foreach (ITaskItem item3 in this.TrackedInputFilesToIgnore)
                            {
                                trackedInputFilesToRemove.Add(item3.GetMetadata("FullPath"), item3);
                            }
                            compactInputs.SaveTlog(delegate(string fullTrackedPath)
                            {
                                if (trackedInputFilesToRemove.ContainsKey(fullTrackedPath))
                                {
                                    return(false);
                                }
                                return(true);
                            });
                        }
                        else
                        {
                            compactInputs.SaveTlog();
                        }
                        if (this.MaintainCompositeRootingMarkers)
                        {
                            string str2 = GenerateCommandLine();
                            sourcesToCommandLines[FileTracker.FormatRootingMarker(this.SourcesCompiled)] = str2;
                            if (strArray != null)
                            {
                                foreach (string str3 in strArray)
                                {
                                    sourcesToCommandLines.Remove(str3);
                                }
                            }
                        }
                        else
                        {
                            string str4 = this.SourcesPropertyName ?? "Sources";
                            string str5 = GenerateCommandLineExceptSwitches(new string[] { str4 });
                            foreach (ITaskItem item4 in this.SourcesCompiled)
                            {
                                sourcesToCommandLines[FileTracker.FormatRootingMarker(item4)] = str5 + " " + item4.GetMetadata("FullPath").ToUpperInvariant();
                            }
                        }
                        this.WriteSourcesToCommandLinesTable(sourcesToCommandLines);
                    }
                }
            }

            return(num);
        }