Beispiel #1
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);
                }
            }
        }