Example #1
0
        protected override void RemoveTaskSpecificInputs(CanonicalTrackedInputFiles compactInputs)
        {
            // This is necessary because the VC tracker gets confused by the intermingling of reading and writing by the support apps

            foreach (KeyValuePair<string, Dictionary<string, string>> pair in compactInputs.DependencyTable)
            {
                List<string> delFiles = new List<string>();

                foreach (KeyValuePair<string, string> depFile in pair.Value)
                {
                    // Remove the -unaligned.apk file, it shouldn't be in the input list
                    if ( depFile.Key.ToLowerInvariant().EndsWith( "-unaligned.apk" ) )
                    {
                        delFiles.Add(depFile.Key);
                    }
                    // Same deal with build.prop
                    if ( depFile.Key.ToLowerInvariant().EndsWith( "build.prop" ) )
                    {
                        delFiles.Add( depFile.Key );
                    }
                }

                // Do deletions
                foreach (string delFile in delFiles)
                {
                    pair.Value.Remove(delFile);
                }

                // Add the two .so files to the inputs
                if ( pair.Value.ContainsKey( m_inputSoPath.ToUpperInvariant() ) == false )
                {
                    pair.Value.Add( m_inputSoPath.ToUpperInvariant(), null );
                }
                if ( pair.Value.ContainsKey( m_armEabiSoPath.ToUpperInvariant() ) == false )
                {
                    pair.Value.Add( m_armEabiSoPath.ToUpperInvariant(), null );
                }
            }
        }
Example #2
0
        public void SaveCompactedReadTlog_MaintainCompositeRootingMarkers()
        {
            Console.WriteLine("Test: SaveCompactedReadTlog_MaintainCompositeRootingMarkers");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\two1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\two2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\two3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\three1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\three2.h", "");

            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\three.cpp", "");

            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\twothree.obj", "");

            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one1.read.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
            });

            File.WriteAllLines("TestFiles\\one2.read.tlog", new string[] {
                "#Command some-command1",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
            });

            File.WriteAllLines("TestFiles\\two1.read.tlog", new string[] {
                "#Command some-command2",
                "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\two2.h"),
                Path.GetFullPath("TestFiles\\two3.h"),
            });

            File.WriteAllLines("TestFiles\\three1.read.tlog", new string[] {
                "#Command some-command2",
                "^" + Path.GetFullPath("TestFiles\\three.cpp"),
                Path.GetFullPath("TestFiles\\three1.h")
            });

            File.WriteAllLines("TestFiles\\twothree.read.tlog", new string[] {
                "#Command some-command2",
                "^" + Path.GetFullPath("TestFiles\\three.cpp") + "|" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\two2.h"),
                Path.GetFullPath("TestFiles\\two3.h"),
                Path.GetFullPath("TestFiles\\three1.h"),
                Path.GetFullPath("TestFiles\\three2.h")
            });

            ITaskItem[] tlogs = {
                                    new TaskItem("TestFiles\\one1.read.tlog"),
                                    new TaskItem("TestFiles\\one2.read.tlog"),
                                    new TaskItem("TestFiles\\two1.read.tlog"),
                                    new TaskItem("TestFiles\\three1.read.tlog"),
                                    new TaskItem("TestFiles\\twothree.read.tlog")
                                };

            ITaskItem[] inputs = {
                                     new TaskItem("TestFiles\\one.cpp"),
                                     new TaskItem("TestFiles\\two.cpp"),
                                     new TaskItem("TestFiles\\three.cpp")
                                 };

            ITaskItem[] outputs = {
                                      new TaskItem("TestFiles\\one.obj"),
                                      new TaskItem("TestFiles\\twothree.obj")
                                  };

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    tlogs,
                    inputs,
                    null,
                    outputs,
                    false, /* no minimal rebuild optimization */
                    true /* keep composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            // nothing should be out of date
            Assert.Equal(0, outofdate.Length);
            Assert.Equal(4, d.DependencyTable.Count);

            // dependencies should include the three .h files written into the .tlogs + the rooting marker
            Assert.Equal(4, d.DependencyTable[Path.GetFullPath("TestFiles\\three.cpp") + "|" + Path.GetFullPath("TestFiles\\two.cpp")].Values.Count);

            d.SaveTlog();

            CanonicalTrackedInputFiles d2 = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    tlogs,
                    inputs,
                    null,
                    outputs,
                    false, /* no minimal rebuild optimization */
                    true /* keep composite rooting markers */
                );

            ITaskItem[] outofdate2 = d2.ComputeSourcesNeedingCompilation();

            Assert.Equal(0, outofdate.Length);
            Assert.Equal(4, d2.DependencyTable.Count);

            // dependencies should include the three .h files written into the .tlogs + the two rooting marker files
            Assert.Equal(4, d2.DependencyTable[Path.GetFullPath("TestFiles\\three.cpp") + "|" + Path.GetFullPath("TestFiles\\two.cpp")].Values.Count);
        }
Example #3
0
 public void CreateTrackedDependencies()
 {
     Console.WriteLine("Test: CreateTrackedDependencies");
     ITaskItem[] sources = null;
     ITaskItem[] outputs = null;
     CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
         (
             DependencyTestHelper.MockTask,
             null,
             sources,
             null,
             outputs,
             false, /* no minimal rebuild optimization */
             false /* shred composite rooting markers */
         );
     Assert.NotNull(d);
 }
Example #4
0
        public void ReadTLogWithInitialEmptyLine()
        {
            Console.WriteLine("Test: ReadTLogWithInitialEmptyLine");

            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");

            File.WriteAllLines("TestFiles\\one.tlog", new string[] { "", "^FOO" });
            MockTask task = DependencyTestHelper.MockTask;

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    task,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            Assert.Equal(1, ((task as ITask).BuildEngine as MockEngine).Warnings); // "Should have a warning."
            Assert.Equal(0, d.DependencyTable.Count); // "DependencyTable should be empty."
        }
Example #5
0
        public void ReplaceOutputForSource()
        {
            Console.WriteLine("Test: ReplaceOutputForSource");

            if (File.Exists(Path.GetFullPath("TestFiles\\three.i")))
            {
                File.Delete(Path.GetFullPath("TestFiles\\three.i"));
            }

            // Prepare read tlog
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\three.cpp", "");
            Thread.Sleep(sleepTimeMilliseconds);
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\three.obj", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one.read.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
                "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
                "^" + Path.GetFullPath("TestFiles\\three.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
            });

            // Our source files
            ITaskItem[] sources = {
                                    new TaskItem("TestFiles\\one.cpp"),
                                    new TaskItem("TestFiles\\two.cpp"),
                                    new TaskItem("TestFiles\\three.cpp"),
                                };

            // Prepare write tlog
            File.WriteAllLines("TestFiles\\one.write.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one.obj"),
                "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\two.obj"),
                "^" + Path.GetFullPath("TestFiles\\three.cpp"),
                Path.GetFullPath("TestFiles\\three.obj"),
            });

            // Represent our tracked and computed outputs
            CanonicalTrackedOutputFiles outputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask, DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));

            // Change the output (note that this doesn't affect the timestamp)
            File.Move(Path.GetFullPath("TestFiles\\three.obj"), Path.GetFullPath("TestFiles\\three.i"));

            string threeRootingMarker = FileTracker.FormatRootingMarker(new TaskItem("TestFiles\\three.cpp"));
            // Remove the fact that three.obj was the tracked output
            bool removed = outputs.RemoveOutputForSourceRoot(threeRootingMarker, Path.GetFullPath("TestFiles\\three.obj"));
            Assert.True(removed);
            // "Compute" the replacement output information for this compilation, rather than the one originally tracked
            outputs.AddComputedOutputForSourceRoot(threeRootingMarker, Path.GetFullPath("TestFiles\\three.i"));

            // Represent our tracked and provided inputs
            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    sources,
                    null,
                    outputs,
                    true, /* minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            // We should have one output for three.cpp
            Assert.Equal(1, outputs.DependencyTable[threeRootingMarker].Count);
            Assert.Equal(false, outputs.DependencyTable[threeRootingMarker].ContainsKey(Path.GetFullPath("TestFiles\\three.obj")));

            // All things should be up to date
            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(0, outofdate.Length);

            // Delete the new output
            File.Delete(Path.GetFullPath("TestFiles\\three.i"));

            // This means a recompile would be required for the roots
            d.SourcesNeedingCompilation = null;
            outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(1, outofdate.Length);
        }
Example #6
0
        public void NonExistentTlog()
        {
            Console.WriteLine("Test: NonExistentTlog");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");

            // Just to be sure, delete the test tlog.
            File.Delete("TestFiles\\one.tlog");

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            Assert.Equal(1, outofdate.Length);
            Assert.Equal(outofdate[0].ItemSpec, "TestFiles\\one.cpp");
        }
Example #7
0
        public void PrimarySourceNotInTlog()
        {
            Console.WriteLine("Test: PrimarySourceNotInTlog");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");

            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            // Primary Source; not appearing in this Tlog..
            File.WriteAllLines("TestFiles\\one.tlog", new string[] {
                "#Command some-command",
                Path.GetFullPath("TestFiles\\foo.cpp"),
                Path.GetFullPath("TestFiles\\foo.h"),
            });

            // Touch the obj - normally this would mean uptodate, but since there
            // is no tlog entry for the primary source, we want a rebuild of it.
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            Assert.Equal(1, outofdate.Length);
            Assert.Equal(outofdate[0].ItemSpec, "TestFiles\\one.cpp");
        }
Example #8
0
        protected void CalcSourcesToBuild()
        {
            //check if full recompile is required otherwise perform incremental
            if (ForcedRebuildRequired() || MinimalRebuildFromTracking == false)
            {
                CompileSourceList = Sources;
                return;
            }

            //retrieve list of sources out of date due to command line changes
            List<ITaskItem> outOfDateSourcesFromCommandLine = GetOutOfDateSourcesFromCmdLineChanges();

            //retrieve sources out of date due to tracking
            CanonicalTrackedOutputFiles outputs = new CanonicalTrackedOutputFiles(this, TLogWriteFiles);
            TrackedInputFiles = new CanonicalTrackedInputFiles(this,
                                                               TLogReadFiles,
                                                               Sources,
                                                               ExcludedInputPaths,
                                                               outputs,
                                                               true,
                                                               false);
            ITaskItem[] outOfDateSourcesFromTracking = TrackedInputFiles.ComputeSourcesNeedingCompilation();

            //merge out of date lists
            CompileSourceList = MergeOutOfDateSources(outOfDateSourcesFromTracking, outOfDateSourcesFromCommandLine);
            if (CompileSourceList.Length == 0)
            {
                SkippedExecution = true;
                return;
            }

            //remove sources to compile from tracked file list
            TrackedInputFiles.RemoveEntriesForSource(CompileSourceList);
            outputs.RemoveEntriesForSource(CompileSourceList);
            TrackedInputFiles.SaveTlog();
            outputs.SaveTlog();
        }
        public void MultipleCanonicalCLAcrossTlogs2()
        {
            Console.WriteLine("Test: MultipleCanonicalCLAcrossTlogs2");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one1.tlog", new string[] {
                "#Command some-command",
                Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
            });

            File.WriteAllLines("TestFiles\\one2.tlog", new string[] {
                "#Command some-command1",
                Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
            });

            // Touch one
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");

            ITaskItem[] tlogs = {
                                    new TaskItem("TestFiles\\one1.tlog"),
                                    new TaskItem("TestFiles\\one2.tlog")
                                };

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    tlogs,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            Assert.IsTrue(outofdate.Length == 1);
            Assert.IsTrue(outofdate[0].ItemSpec == "TestFiles\\one.cpp");
        }
Example #10
0
 //         private void ReadUnicodeOutput(object stateInfo)
 //         {
 //             uint num;
 //             byte[] lpBuffer = new byte[0x400];
 //             string str = string.Empty;
 //         Label_0011:
 //             if (!NativeMethodsShared.ReadFile(this.unicodePipeReadHandle, lpBuffer, 0x400, out num, NativeMethodsShared.NullIntPtr) || (num == 0))
 //             {
 //                 if (!string.IsNullOrEmpty(str))
 //                 {
 //                     base.Log.LogMessageFromText(str, base.StandardOutputImportanceToUse);
 //                 }
 //                 this.unicodeOutputEnded.Set();
 //             }
 //             else
 //             {
 //                 string str2 = str + Encoding.Unicode.GetString(lpBuffer, 0, (int) num);
 //                 while (true)
 //                 {
 //                     int length = -1;
 //                     length = str2.IndexOf('\n');
 //                     if (length == -1)
 //                     {
 //                         break;
 //                     }
 //                     string lineOfText = str2.Substring(0, length);
 //                     str2 = str2.Substring(length + 1);
 //                     if ((lineOfText.Length > 0) && lineOfText.EndsWith("\r"))
 //                     {
 //                         lineOfText = lineOfText.Substring(0, lineOfText.Length - 1);
 //                     }
 //                     base.Log.LogMessageFromText(lineOfText, base.StandardOutputImportanceToUse);
 //                 }
 //                 str = str2;
 //                 goto Label_0011;
 //             }
 //         }
 protected virtual void RemoveTaskSpecificInputs(CanonicalTrackedInputFiles compactInputs)
 {
 }
Example #11
0
        private void ConstructReadTLog( ITaskItem[] upToDateSources, CanonicalTrackedOutputFiles outputs )
        {
            string readTrackerPath = Path.GetFullPath( TrackerIntermediateDirectory + "\\" + ReadTLogNames[0] );

            // Rewrite out read log, with the sources we're *not* compiling right now.
            TaskItem readTrackerItem = new TaskItem( readTrackerPath );
            CanonicalTrackedInputFiles files = new CanonicalTrackedInputFiles(new TaskItem[] { readTrackerItem }, Sources, outputs, false, false);
            files.RemoveEntriesForSource(Sources);
            files.SaveTlog();

            // Now append onto the read log the sources we're compiling. It'll parse the .d files for each compiled file, so we know the
            // dependency header files associated with it, these will be recorded in the logfile.
            using ( StreamWriter writer = new StreamWriter( readTrackerPath, true, Encoding.Unicode ) )
            {
                foreach ( ITaskItem sourceItem in upToDateSources )
                {
                    string itemSpec = sourceItem.ItemSpec;
                    string sourcePath = Path.GetFullPath( sourceItem.ItemSpec ).ToUpperInvariant();
                    string objectFile = Path.GetFullPath( sourceItem.GetMetadata( "ObjectFileName" ) );
                    string dotDFile = Path.GetFullPath( Path.GetDirectoryName( objectFile ) + "\\" + Path.GetFileNameWithoutExtension( objectFile ) + ".d" );

                    try
                    {
                        writer.WriteLine("^" + sourcePath);
                        if (File.Exists(dotDFile))
                        {
                            DepFileParse depFileParse = new DepFileParse(dotDFile);

                            foreach (string dependentFile in depFileParse.DependentFiles)
                            {
                                if (dependentFile != sourcePath)
                                {
                                    if (File.Exists(dependentFile) == false)
                                    {
                                        Log.LogMessage(MessageImportance.High, "File " + sourcePath + " is missing dependent file: " + dependentFile);
                                    }

                                    writer.WriteLine(dependentFile);
                                }
                            }

                            // Done with this .d file. So delete it
                            try
                            {
                                File.Delete(dotDFile);
                            }
                            finally
                            {

                            }
                        }
                        else if (File.Exists(objectFile))
                        {
                            Log.LogMessage(MessageImportance.High, "File " + sourcePath + " is missing it's .d file: " + dotDFile);
                        }
                    }
                    catch ( Exception )
                    {
                        Log.LogError( "Failed processing dependencies in: " + dotDFile );
                    }
                }
            }
        }
Example #12
0
 //         private void BeginUnicodeOutput()
 //         {
 //             this.unicodePipeReadHandle = null;
 //             this.unicodePipeWriteHandle = null;
 //             this.unicodeOutputEnded = null;
 //             if (this.UseUnicodeOutput)
 //             {
 //                 NativeMethodsShared.SecurityAttributes lpPipeAttributes = new NativeMethodsShared.SecurityAttributes {
 //                     lpSecurityDescriptor = NativeMethodsShared.NullIntPtr,
 //                     bInheritHandle = true
 //                 };
 //                 if (NativeMethodsShared.CreatePipe(out this.unicodePipeReadHandle, out this.unicodePipeWriteHandle, lpPipeAttributes, 0))
 //                 {
 //                     List<string> list = new List<string>();
 //                     if (base.EnvironmentVariables != null)
 //                     {
 //                         list.AddRange(base.EnvironmentVariables);
 //                     }
 //                     list.Add("VS_UNICODE_OUTPUT=" + this.unicodePipeWriteHandle.DangerousGetHandle());
 //                     base.EnvironmentVariables = list.ToArray();
 //                     this.unicodeOutputEnded = new AutoResetEvent(false);
 //                     ThreadPool.QueueUserWorkItem(new WaitCallback(this.ReadUnicodeOutput));
 //                 }
 //                 else
 //                 {
 //                     base.Log.LogWarningWithCodeFromResources("TrackedVCToolTask.CreateUnicodeOutputPipeFailed", new object[] { this.ToolName });
 //                 }
 //             }
 //         }
 /*internal*/
 protected virtual bool ComputeOutOfDateSources()
 {
     if (this.TrackerIntermediateDirectory != null)
     {
         string trackerIntermediateDirectory = this.TrackerIntermediateDirectory;
     }
     if (this.MinimalRebuildFromTracking || this.TrackFileAccess)
     {
         this.AssignDefaultTLogPaths();
     }
     if (this.MinimalRebuildFromTracking && !this.ForcedRebuildRequired())
     {
         CanonicalTrackedOutputFiles outputs = new CanonicalTrackedOutputFiles(this, this.TLogWriteFiles);
         this.sourceDependencies = new CanonicalTrackedInputFiles(this, this.TLogReadFiles, this.TrackedInputFiles, this.ExcludedInputPaths, outputs, this.UseMinimalRebuildOptimization, this.MaintainCompositeRootingMarkers);
         ITaskItem[] sourcesOutOfDateThroughTracking = this.SourceDependencies.ComputeSourcesNeedingCompilation(false);
         List<ITaskItem> sourcesWithChangedCommandLines = this.GenerateSourcesOutOfDateDueToCommandLine();
         this.SourcesCompiled = this.MergeOutOfDateSourceLists(sourcesOutOfDateThroughTracking, sourcesWithChangedCommandLines);
         if (this.SourcesCompiled.Length == 0)
         {
             this.SkippedExecution = true;
             return this.SkippedExecution;
         }
         this.SourcesCompiled = this.AssignOutOfDateSources(this.SourcesCompiled);
         this.SourceDependencies.RemoveEntriesForSource(this.SourcesCompiled);
         this.SourceDependencies.SaveTlog();
         outputs.RemoveEntriesForSource(this.SourcesCompiled);
         outputs.SaveTlog();
     }
     else
     {
         this.SourcesCompiled = this.TrackedInputFiles;
         if ((this.SourcesCompiled == null) || (this.SourcesCompiled.Length == 0))
         {
             this.SkippedExecution = true;
             return this.SkippedExecution;
         }
     }
     if (this.TrackFileAccess)
     {
         this.RootSource = FileTracker.FormatRootingMarker(this.SourcesCompiled);
     }
     this.SkippedExecution = false;
     return this.SkippedExecution;
 }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    protected override bool Setup ()
    {
      bool result = base.Setup ();

      OutOfDateSources = Sources;

      if (result && !SkippedExecution)
      {
        // 
        // Retrieve list of sources considered out-of-date due to either command line changes or tracker flagging.
        // TODO: Switch use of CanonicalTracked* helpers to TrackedFileManager.
        // 

        CanonicalTrackedOutputFiles trackedOutputFiles = new CanonicalTrackedOutputFiles (this, TLogWriteFiles);

        TrackedInputFiles = new CanonicalTrackedInputFiles (this, TLogReadFiles, Sources, ExcludedInputPaths, trackedOutputFiles, true, false);//true);

        ITaskItem [] outOfDateSourcesFromTracking = TrackedInputFiles.ComputeSourcesNeedingCompilation ();// (true);

        ITaskItem [] outOfDateSourcesFromCommandLine = GetOutOfDateSourcesFromCmdLineChanges (Sources);

#if DEBUG
        Log.LogMessageFromText (string.Format ("[{0}] --> No. out-of-date sources (from tracking): {1}", ToolName, outOfDateSourcesFromTracking.Length), MessageImportance.Low);

        Log.LogMessageFromText (string.Format ("[{0}] --> No. out-of-date sources (command line differs): {1}", ToolName, outOfDateSourcesFromCommandLine.Length), MessageImportance.Low);
#endif

        // 
        // Merge out-of-date lists from both sources and assign these for compilation.
        // 

        HashSet<ITaskItem> mergedOutOfDateSources = new HashSet<ITaskItem> (outOfDateSourcesFromTracking);

        foreach (ITaskItem item in outOfDateSourcesFromCommandLine)
        {
          if (!mergedOutOfDateSources.Contains (item))
          {
            mergedOutOfDateSources.Add (item);
          }
        }

        OutOfDateSources = new ITaskItem [mergedOutOfDateSources.Count];

        mergedOutOfDateSources.CopyTo (OutOfDateSources);

        if ((OutOfDateSources == null) || (OutOfDateSources.Length == 0))
        {
          SkippedExecution = true;
        }
        else
        {
          // 
          // Remove sources to compile from tracked file list.
          // 

          TrackedInputFiles.RemoveEntriesForSource (OutOfDateSources);

          trackedOutputFiles.RemoveEntriesForSource (OutOfDateSources);

          TrackedInputFiles.SaveTlog ();

          trackedOutputFiles.SaveTlog ();
        }
      }

#if DEBUG
      Log.LogMessageFromText (string.Format ("[{0}] --> Skipped execution: {1}", ToolName, SkippedExecution), MessageImportance.Low);

      for (int i = 0; i < OutOfDateSources.Length; ++i)
      {
        Log.LogMessageFromText (string.Format ("[{0}] --> Out-of-date Sources: [{1}] {2}", ToolName, i, OutOfDateSources [i].ToString ()), MessageImportance.Low);
      }
#endif

      return result;
    }
Example #14
0
        protected override void OutputReadTLog(ITaskItem[] compiledSources, CanonicalTrackedOutputFiles outputs)
        {
            string trackerPath = Path.GetFullPath(TlogDirectory + ReadTLogFilenames[0]);

            //save tlog for sources not compiled during this execution
            TaskItem readTrackerItem = new TaskItem(trackerPath);
            CanonicalTrackedInputFiles files = new CanonicalTrackedInputFiles(new TaskItem[] { readTrackerItem }, Sources, outputs, false, false);
            files.RemoveEntriesForSource(compiledSources);
            files.SaveTlog();

            //add tlog information for compiled sources
            using (StreamWriter writer = new StreamWriter(trackerPath, true, Encoding.Unicode))
            {
                foreach (ITaskItem source in compiledSources)
                {
                    string sourcePath = Path.GetFullPath(source.ItemSpec).ToUpperInvariant();
                    string objectFilePath = GetObjectFile(source);
                    string depFilePath = Path.ChangeExtension(objectFilePath, ".d");

                    try
                    {
                        if (File.Exists(depFilePath) == false)
                        {
                            Log.LogMessage(MessageImportance.High, depFilePath + " not found");
                        }
                        else
                        {
                            writer.WriteLine("^" + sourcePath);
                            DependencyParser parser = new DependencyParser(depFilePath);

                            foreach (string filename in parser.Dependencies)
                            {
                                //source itself not required
                                if (filename == sourcePath)
                                    continue;

                                if (File.Exists(filename) == false)
                                {
                                    Log.LogMessage(MessageImportance.High, "File " + sourcePath + " is missing dependency " + filename);
                                }

                                string fname = filename.ToUpperInvariant();
                                fname = Path.GetFullPath(fname);
                                writer.WriteLine(fname);
                            }

                            //remove d file
                            try
                            {
                                File.Delete(depFilePath);
                            }
                            finally
                            {

                            }
                        }

                    }
                    catch (Exception)
                    {
                        Log.LogError("Failed to update " + readTrackerItem + " for " + sourcePath);
                    }
                }
            }
        }
Example #15
0
        public void MultiplePrimaryCanonicalCLUnderTemp()
        {
            string currentDirectory = Directory.GetCurrentDirectory();
            string tempPath = Path.GetTempPath();

            try
            {
                Directory.SetCurrentDirectory(tempPath);

                Console.WriteLine("Test: MultiplePrimaryCanonicalCL");
                // Prepare files
                DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
                DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
                DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
                DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
                DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");

                DependencyTestHelper.WriteAll("TestFiles\\two1.h", "");
                DependencyTestHelper.WriteAll("TestFiles\\two2.h", "");
                DependencyTestHelper.WriteAll("TestFiles\\two3.h", "");
                DependencyTestHelper.WriteAll("TestFiles\\two.cpp", "");
                DependencyTestHelper.WriteAll("TestFiles\\two.obj", "");

                Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
                File.WriteAllLines("TestFiles\\one.tlog", new string[] {
                    "#Command some-command",
                    "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                    Path.GetFullPath("TestFiles\\one1.h"),
                    Path.GetFullPath("TestFiles\\one2.h"),
                    Path.GetFullPath("TestFiles\\one3.h"),
                    "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                    Path.GetFullPath("TestFiles\\two1.h"),
                    Path.GetFullPath("TestFiles\\two2.h"),
                    Path.GetFullPath("TestFiles\\two3.h"),
                });

                // Touch one
                Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
                DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
                Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
                DependencyTestHelper.WriteAll("TestFiles\\two2.h", "");

                CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                    (
                        DependencyTestHelper.MockTask,
                        DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                        new ITaskItem[] {
                            new TaskItem("TestFiles\\one.cpp"),
                            new TaskItem("TestFiles\\two.cpp"),
                            },
                        null,
                        new ITaskItem[] {
                            new TaskItem("TestFiles\\one.obj"),
                            new TaskItem("TestFiles\\two.obj"),
                            },
                        false, /* no minimal rebuild optimization */
                        false /* shred composite rooting markers */
                    );

                ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

                Assert.Equal(2, outofdate.Length);
                Assert.True((outofdate[0].ItemSpec == "TestFiles\\one.cpp" && outofdate[1].ItemSpec == "TestFiles\\two.cpp") ||
                                 (outofdate[1].ItemSpec == "TestFiles\\one.cpp" && outofdate[0].ItemSpec == "TestFiles\\two.cpp"));
            }
            finally
            {
                Directory.SetCurrentDirectory(currentDirectory);
            }
        }
        public void EmptyTLog()
        {
            Console.WriteLine("Test: EmptyTLog");

            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.tlog", "");

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            Assert.IsTrue(outofdate.Length == 1);
            Assert.IsTrue(outofdate[0].ItemSpec == "TestFiles\\one.cpp");
        }
Example #17
0
        public void MultipleRootedCLNonDependency()
        {
            Console.WriteLine("Test: MultipleRootedCLNonDependency");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\two1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\two2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\two3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.cpp", "");

            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one1.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                "#Command some-command1",
                "^" + Path.GetFullPath("TestFiles\\two.cpp"), // this root marker represents the end of the dependencies for one.cpp
                Path.GetFullPath("TestFiles\\two2.h"),
                Path.GetFullPath("TestFiles\\two3.h"),
            });

            // Touch one
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            DependencyTestHelper.WriteAll("TestFiles\\two2.h", "");

            ITaskItem[] tlogs = {
                                    new TaskItem("TestFiles\\one1.tlog")
                                };

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    tlogs,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            Assert.Equal(0, outofdate.Length);
        }
Example #18
0
        public void MultipleCanonicalCLCompactMissingOnSuccess()
        {
            Console.WriteLine("Test: MultipleCanonicalCLCompactMissingOnSuccess");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one.read.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
            });

            File.WriteAllLines("TestFiles\\one.write.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one.obj"),
                Path.GetFullPath("TestFiles\\sometempfile.obj")
            });

            CanonicalTrackedOutputFiles compactOutputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask, DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));
            compactOutputs.RemoveDependenciesFromEntryIfMissing(new TaskItem(Path.GetFullPath("TestFiles\\one.cpp")));
            compactOutputs.SaveTlog();

            // Compact the read tlog
            CanonicalTrackedInputFiles compactInputs = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    compactOutputs,
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            compactInputs.RemoveDependenciesFromEntryIfMissing(new TaskItem(Path.GetFullPath("TestFiles\\one.cpp")));
            compactInputs.SaveTlog();

            CanonicalTrackedOutputFiles outputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    outputs,
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            Assert.Equal(0, outofdate.Length);
        }
Example #19
0
        public void OutputCLMinimalRebuildOptimizationComputed()
        {
            Console.WriteLine("Test: OutputCLMinimalRebuildOptimizationComputed");

            // Prepare read tlog
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\three.cpp", "");
            Thread.Sleep(sleepTimeMilliseconds);
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\three.obj", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one.read.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
                "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
                "^" + Path.GetFullPath("TestFiles\\three.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
            });

            // Our source files
            ITaskItem[] sources = {
                                    new TaskItem("TestFiles\\one.cpp"),
                                    new TaskItem("TestFiles\\two.cpp"),
                                    new TaskItem("TestFiles\\three.cpp"),
                                };

            // Prepare write tlog
            File.WriteAllLines("TestFiles\\one.write.tlog", new string[] {
                "#Command some-command",
                "^" + FileTracker.FormatRootingMarker(sources),
                Path.GetFullPath("TestFiles\\one.obj"),
                Path.GetFullPath("TestFiles\\two.obj"),
                Path.GetFullPath("TestFiles\\three.obj"),
            });

            // Represent our tracked and computed outputs
            CanonicalTrackedOutputFiles outputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask, DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));

            // "Compute" the additional output information for this compilation, rather than them being tracked
            outputs.AddComputedOutputForSourceRoot(Path.GetFullPath("TestFiles\\one.cpp"), Path.GetFullPath("TestFiles\\one.obj"));
            outputs.AddComputedOutputForSourceRoot(Path.GetFullPath("TestFiles\\two.cpp"), Path.GetFullPath("TestFiles\\two.obj"));
            outputs.AddComputedOutputForSourceRoot(Path.GetFullPath("TestFiles\\three.cpp"), Path.GetFullPath("TestFiles\\three.obj"));

            // Represent our tracked and provided inputs
            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    sources,
                    null,
                    outputs,
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            // First of all, all things should be up to date
            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(0, outofdate.Length);

            // Delete one of the outputs in the group
            File.Delete(Path.GetFullPath("TestFiles\\two.obj"));

            // With optimization off, all sources in the group will need compilation
            d.SourcesNeedingCompilation = null;
            outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(3, outofdate.Length);

            // With optimization on, only the source that matches the output will need compilation
            d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    sources,
                    null,
                    outputs,
                    true, /* enable minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(1, outofdate.Length);
            // And the source is.. two.cpp!
            Assert.Equal(outofdate[0].ItemSpec, "TestFiles\\two.cpp");
        }
Example #20
0
        public void MultipleCanonicalCLCompactMissingOnSuccessMultiEntry()
        {
            Console.WriteLine("Test: MultipleCanonicalCLCompactMissingOnSuccessMultiEntry");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one.read.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
                "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\two1.h"),
                Path.GetFullPath("TestFiles\\two2.h"),
            });

            File.WriteAllLines("TestFiles\\one.write.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one.obj"),
                Path.GetFullPath("TestFiles\\sometempfile.obj"),
                "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\two.obj"),
                Path.GetFullPath("TestFiles\\sometempfile2.obj")
            });

            CanonicalTrackedOutputFiles compactOutputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask, DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));
            compactOutputs.RemoveDependenciesFromEntryIfMissing(new TaskItem(Path.GetFullPath("TestFiles\\one.cpp")));
            compactOutputs.SaveTlog();
            // Compact the read tlog
            CanonicalTrackedInputFiles compactInputs = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    compactOutputs,
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            compactInputs.RemoveDependenciesFromEntryIfMissing(new TaskItem(Path.GetFullPath("TestFiles\\one.cpp")));
            compactInputs.SaveTlog();

            CanonicalTrackedOutputFiles writtenOutputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));

            CanonicalTrackedInputFiles writtenInputs = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    writtenOutputs,
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            Assert.Equal(1, writtenOutputs.DependencyTable[Path.GetFullPath("TestFiles\\one.cpp")].Count);
            Assert.Equal(4, writtenInputs.DependencyTable[Path.GetFullPath("TestFiles\\one.cpp")].Count);
            // Everything to do with two.cpp should be left intact
            Assert.Equal(2, writtenOutputs.DependencyTable[Path.GetFullPath("TestFiles\\two.cpp")].Count);
            Assert.Equal(3, writtenInputs.DependencyTable[Path.GetFullPath("TestFiles\\two.cpp")].Count);
        }
Example #21
0
        public void ReadTLogWithDuplicateInRoot()
        {
            Console.WriteLine("Test: ReadTLogWithDuplicateInRoot");

            //Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\foo.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");

            ITaskItem[] sources = new ITaskItem[] { new TaskItem("TestFiles\\foo.cpp"), new TaskItem("TestFiles\\foo.cpp") };

            File.WriteAllLines("TestFiles\\one.tlog", new string[] { "^TestFiles\\foo.cpp|TestFiles\\foo.cpp", "TestFiles\\bar.cpp", "TestFiles\\foo.cpp" });
            MockTask task = DependencyTestHelper.MockTask;

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    task,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    sources,
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            Assert.NotEqual(0, d.DependencyTable.Count); // "Dependency Table should not be empty."
        }
Example #22
0
        public void ExcludeSpecificDirectory()
        {
            Console.WriteLine("Test: ExcludeSpecificDirectory");

            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\three.cpp", "");

            Thread.Sleep(sleepTimeMilliseconds);

            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\three.obj", "");

            Thread.Sleep(sleepTimeMilliseconds);

            Directory.CreateDirectory("TestFiles\\Foo");
            DependencyTestHelper.WriteAll("TestFiles\\Foo\\one2.h", "");

            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register

            File.WriteAllLines("TestFiles\\one.read.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\one1.h").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\Foo\\one2.h").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\one3.h").ToUpperInvariant(),
                "^" + Path.GetFullPath("TestFiles\\two.cpp").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\one1.h").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\Foo\\one2.h").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\one3.h").ToUpperInvariant(),
                "^" + Path.GetFullPath("TestFiles\\three.cpp").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\one1.h").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\Foo\\one2.h").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\one3.h").ToUpperInvariant(),
            });

            // Our source files
            ITaskItem[] sources = {
                                    new TaskItem("TestFiles\\one.cpp"),
                                    new TaskItem("TestFiles\\two.cpp"),
                                    new TaskItem("TestFiles\\three.cpp"),
                                };

            // Prepare write tlog
            File.WriteAllLines("TestFiles\\one.write.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\one.obj").ToUpperInvariant(),
                "^" + Path.GetFullPath("TestFiles\\two.cpp").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\two.obj").ToUpperInvariant(),
                "^" + Path.GetFullPath("TestFiles\\three.cpp").ToUpperInvariant(),
                Path.GetFullPath("TestFiles\\three.obj").ToUpperInvariant(),
            });

            // Represent our tracked and computed outputs
            CanonicalTrackedOutputFiles outputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask, DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));

            // Represent our tracked and provided inputs
            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    sources,
                    new TaskItem[] { new TaskItem(Path.GetFullPath("TeSTfiles\\Foo")) },
                    outputs,
                    true, /* minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            // All things should be up to date
            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(0, outofdate.Length);
        }
Example #23
0
        public void RemoveDependencyFromEntry()
        {
            Console.WriteLine("Test: RemoveDependencyFromEntry");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.tlh", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.tli", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one.read.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
                Path.GetFullPath("TestFiles\\one3.obj"),
                Path.GetFullPath("TestFiles\\one3.tlh"),
                Path.GetFullPath("TestFiles\\one3.tli"),
            });

            File.WriteAllLines("TestFiles\\one.write.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
                Path.GetFullPath("TestFiles\\one3.obj"),
                Path.GetFullPath("TestFiles\\one3.tlh"),
                Path.GetFullPath("TestFiles\\one3.tli"),
            });

            CanonicalTrackedOutputFiles compactOutputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask, DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));
            compactOutputs.RemoveDependencyFromEntry(new TaskItem(Path.GetFullPath("TestFiles\\one.cpp")), new TaskItem(Path.GetFullPath("TestFiles\\one3.obj")));
            compactOutputs.SaveTlog();

            CanonicalTrackedOutputFiles writtenOutputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));

            Assert.False(writtenOutputs.DependencyTable[Path.GetFullPath("TestFiles\\one.cpp")].ContainsKey(Path.GetFullPath("TestFiles\\one3.obj")));

            CanonicalTrackedInputFiles compactInputs = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    compactOutputs,
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            compactInputs.RemoveDependencyFromEntry(new TaskItem(Path.GetFullPath("TestFiles\\one.cpp")), new TaskItem(Path.GetFullPath("TestFiles\\one3.obj")));
            compactInputs.SaveTlog();

            CanonicalTrackedInputFiles writtenInputs = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    writtenOutputs,
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            Assert.False(writtenInputs.DependencyTable[Path.GetFullPath("TestFiles\\one.cpp")].ContainsKey(Path.GetFullPath("TestFiles\\one3.obj")));
        }
Example #24
0
        public void MultipleCanonicalCLMissingDependency()
        {
            Console.WriteLine("Test: MultipleCanonicalCLMissingDependency");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
            });

            // Delete one of our dependencies
            string missing = Path.GetFullPath("TestFiles\\one2.h");
            File.Delete(missing);

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            // We're out of date, since a missing dependency indicates out-of-dateness
            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(1, outofdate.Length);

            // The dependency has been recorded and retrieved correctly
            Assert.True(d.DependencyTable[Path.GetFullPath("TestFiles\\one.cpp")].ContainsKey(missing));

            // Save out the compacted read log - our missing dependency will be compacted away
            // The tlog will have to entries compacted, since we're not up to date
            d.RemoveEntriesForSource(d.SourcesNeedingCompilation);
            d.SaveTlog();

            // read the tlog back in again
            d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            // We're out of date, since a missing dependency indicates out-of-dateness
            outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(1, outofdate.Length);

            // We have a source outstanding for recompilation, it will not appear in
            // the tracking information as it will be written again
            Assert.False(d.DependencyTable.ContainsKey(Path.GetFullPath("TestFiles\\one.cpp")));
        }
Example #25
0
        public void SaveCompactedReadTlog()
        {
            Console.WriteLine("Test: SaveCompactedReadTlog");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\two1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\two2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\two3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.obj", "");

            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one1.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
            });

            File.WriteAllLines("TestFiles\\one2.tlog", new string[] {
                "#Command some-command1",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
            });

            File.WriteAllLines("TestFiles\\two1.tlog", new string[] {
                "#Command some-command2",
                "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\two2.h"),
                Path.GetFullPath("TestFiles\\two3.h"),
            });

            // Touch one
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");

            ITaskItem[] tlogs = {
                                    new TaskItem("TestFiles\\one1.tlog"),
                                    new TaskItem("TestFiles\\one2.tlog"),
                                    new TaskItem("TestFiles\\two1.tlog")
                                };

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    tlogs,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            Assert.Equal(1, outofdate.Length);
            Assert.Equal(outofdate[0].ItemSpec, "TestFiles\\one.cpp");

            d.RemoveEntriesForSource(d.SourcesNeedingCompilation);
            d.SaveTlog();

            // All the tlogs need to still be there even after compaction
            // It's OK for them to be empty, but their absence might mean a partial clean
            // A missing tlog would mean a clean build
            Assert.True(Microsoft.Build.Utilities.TrackedDependencies.ItemsExist(tlogs));

            // There should be no difference in the out of date files after compaction
            CanonicalTrackedInputFiles d1 = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    tlogs,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            outofdate = d1.ComputeSourcesNeedingCompilation();

            Assert.Equal(1, outofdate.Length);
            Assert.Equal(outofdate[0].ItemSpec, "TestFiles\\one.cpp");

            ITaskItem[] tlogs2 = {
                                    tlogs[0]
                                 };

            // All log information should now be in the tlog[0]
            CanonicalTrackedInputFiles d2 = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    tlogs2,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\two.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\two.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            outofdate = d2.ComputeSourcesNeedingCompilation();

            Assert.Equal(0, outofdate.Length);
            Assert.Equal(1, d2.DependencyTable.Count);
            Assert.False(d2.DependencyTable.ContainsKey(Path.GetFullPath("TestFiles\\one.cpp")));

            // There should be no difference even if we send in all the original tlogs
            CanonicalTrackedInputFiles d3 = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    tlogs,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\two.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\two.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            outofdate = d3.ComputeSourcesNeedingCompilation();

            Assert.Equal(0, outofdate.Length);
            Assert.Equal(1, d3.DependencyTable.Count);
            Assert.False(d3.DependencyTable.ContainsKey(Path.GetFullPath("TestFiles\\one.cpp")));
        }
Example #26
0
        public void MultipleCanonicalCLMissingInputDependencyRemoved()
        {
            Console.WriteLine("Test: MultipleCanonicalCLMissingInputDependencyRemoved");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
            });

            // Delete one of our dependencies
            string missing = Path.GetFullPath("TestFiles\\one2.h");
            File.Delete(missing);

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            // We're out of date, since a missing dependency indicates out-of-dateness
            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(1, outofdate.Length);

            // The dependency has been recorded and retrieved correctly
            Assert.True(d.DependencyTable[Path.GetFullPath("TestFiles\\one.cpp")].ContainsKey(missing));

            // Save out the compacted read log - our missing dependency will be compacted away
            // Use an anonymous method to encapsulate the contains check for the tlogs
            d.SaveTlog(delegate (string fullTrackedPath)
            {
                // We need to answer the question "should fullTrackedPath be included in the TLog?"
                return (String.Compare(fullTrackedPath, missing, StringComparison.OrdinalIgnoreCase) != 0);
            });

            // read the tlog back in again
            d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            // We're not out of date, since the missing dependency has been removed
            outofdate = d.ComputeSourcesNeedingCompilation();
            Assert.Equal(0, outofdate.Length);
        }
Example #27
0
        public void SingleRootedCL()
        {
            Console.WriteLine("Test: SingleRootedCL");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            File.WriteAllLines("TestFiles\\one.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one.h"),
            });

            // Touch one
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            DependencyTestHelper.WriteAll("TestFiles\\one.h", "");

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            Assert.Equal(1, outofdate.Length);
            Assert.Equal(outofdate[0].ItemSpec, "TestFiles\\one.cpp");
        }
Example #28
0
        public void MultipleCanonicalCLMissingOutputDependencyRemoved()
        {
            Console.WriteLine("Test: MultipleCanonicalCLMissingOutputDependencyRemoved");
            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one1.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one2.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one3.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.cpp", "");
            Thread.Sleep(sleepTimeMilliseconds); // need to wait since the timestamp check needs some time to register
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\two.obj", "");

            File.WriteAllLines("TestFiles\\one.read.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
                Path.GetFullPath("TestFiles\\one3.h"),
                "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\one1.h"),
                Path.GetFullPath("TestFiles\\one2.h"),
            });

            File.WriteAllLines("TestFiles\\one.write.tlog", new string[] {
                "#Command some-command",
                "^" + Path.GetFullPath("TestFiles\\one.cpp"),
                Path.GetFullPath("TestFiles\\one.obj"),
                "^" + Path.GetFullPath("TestFiles\\two.cpp"),
                Path.GetFullPath("TestFiles\\two.obj"),
                Path.GetFullPath("TestFiles\\sometempfile2.obj")
            });

            string missing = Path.GetFullPath("TestFiles\\sometempfile2.obj");

            CanonicalTrackedOutputFiles compactOutputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask, DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));
            // Save out the compacted read log - our missing dependency will be compacted away
            // Use an anonymous method to encapsulate the contains check for the tlogs
            compactOutputs.SaveTlog(delegate (string fullTrackedPath)
            {
                // We need to answer the question "should fullTrackedPath be included in the TLog?"
                return (String.Compare(fullTrackedPath, missing, StringComparison.OrdinalIgnoreCase) != 0);
            });

            // Read the Tlogs back in..
            compactOutputs = new CanonicalTrackedOutputFiles(DependencyTestHelper.MockTask, DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.write.tlog")));
            // Compact the read tlog
            CanonicalTrackedInputFiles compactInputs = new CanonicalTrackedInputFiles
                (
                    DependencyTestHelper.MockTask,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.read.tlog")),
                    new TaskItem[] { new TaskItem("TestFiles\\one.cpp"), new TaskItem("TestFiles\\two.cpp") },
                    null,
                    compactOutputs,
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            compactInputs.SaveTlog();

            ITaskItem[] outofDate = compactInputs.ComputeSourcesNeedingCompilation();
            Assert.Equal(0, outofDate.Length);
        }
Example #29
0
        public void InvalidReadTLogName()
        {
            Console.WriteLine("Test: InvalidReadTLogName");

            // Prepare files
            DependencyTestHelper.WriteAll("TestFiles\\one.h", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.cpp", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.obj", "");
            DependencyTestHelper.WriteAll("TestFiles\\one.tlog", "");

            MockTask task = DependencyTestHelper.MockTask;

            CanonicalTrackedInputFiles d = new CanonicalTrackedInputFiles
                (
                    task,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\|one|.tlog")),
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.cpp")),
                    null,
                    DependencyTestHelper.ItemArray(new TaskItem("TestFiles\\one.obj")),
                    false, /* no minimal rebuild optimization */
                    false /* shred composite rooting markers */
                );

            ITaskItem[] outofdate = d.ComputeSourcesNeedingCompilation();

            Assert.Equal(1, ((task as ITask).BuildEngine as MockEngine).Warnings); // "Should have an error."
            Assert.Equal(0, d.DependencyTable.Count); // "DependencyTable should be empty."
        }
Example #30
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;
        }