Пример #1
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);
            }
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        protected virtual int PostExecuteTool(int exitCode, string responseFileCommands, string commandLineCommands)
        {
            TrackedOutputFiles = new CanonicalTrackedOutputFiles(this, TLogWriteFiles);

            TrackedInputFiles = new CanonicalTrackedInputFiles(this, TLogReadFiles, OutOfDateInputFiles, ExcludedInputPaths, TrackedOutputFiles, true, false);

            switch (exitCode)
            {
            case 0:
            {
                //
                // Successful build. Begin by collating known output files. (We have a manual workaround for instances where TrackedOutputFiles can't find rooted output.)
                //

                OutputFiles = TrackedOutputFiles.OutputsForSource(OutOfDateInputFiles);

                /*if (OutputFiles?.Length == 0)
                 * {
                 * var fileWrites = TrackerUtilities.ParseTrackerLogForCommandMapping(TrackedDependencies.ExpandWildcards(TLogWriteFiles));
                 *
                 * var writtenFiles = new HashSet<ITaskItem>();
                 *
                 * foreach (var keypair in fileWrites)
                 * {
                 *  writtenFiles.UnionWith(keypair.Value);
                 * }
                 *
                 * OutputFiles = writtenFiles.ToArray();
                 * }*/

                if (OutputFiles != null)
                {
                    foreach (var outfile in OutputFiles)
                    {
                        outfile.ItemSpec = PathUtils.GetExactPathName(outfile.ItemSpec.ToLowerInvariant());
                    }
                }

                //
                // Remove any instances where "input files" (sources which existed before this build) are shown as read/touched/written.
                //

                TrackedOutputFiles.RemoveDependenciesFromEntryIfMissing(OutOfDateInputFiles);

                TrackedInputFiles.RemoveDependenciesFromEntryIfMissing(OutOfDateInputFiles);

                //
                // Crunch the logs. This will erradicate un-rooted tracking data.
                //

                TrackedOutputFiles.SaveTlog();

                TrackedInputFiles.SaveTlog();

                break;
            }

            default:
            {
                //
                // Task failed. Remove any potentially processed file outputs to refresh clean state.
                //

                TrackedOutputFiles.RemoveEntriesForSource(OutOfDateInputFiles);

                TrackedInputFiles.RemoveEntriesForSource(OutOfDateInputFiles);

                TrackedOutputFiles.SaveTlog();

                TrackedInputFiles.SaveTlog();

                break;
            }
            }

            if (TLogCommandFiles != null)
            {
                OutputCommandTLog(TLogCommandFiles[0], responseFileCommands, commandLineCommands);
            }

            return(exitCode);
        }
Пример #3
0
        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);
                }
            }
        }
Пример #4
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);
        }
Пример #5
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);
        }