public void ParseEscapedSpacesTest() { DependencyParser parser = new DependencyParser(); parser.Parse(@"test.o: test.c my\ test.h my\ \test.h"); List<string> expected = new List<string>(); expected.Add(@"test.c"); expected.Add(@"my test.h"); expected.Add(@"my \test.h"); CollectionAssert.AreEquivalent(expected, parser.Dependencies); }
public void ParseMultiLineTest() { DependencyParser parser = new DependencyParser(); parser.Parse("test.o: test.c \\\n foo.h\\\n bar.h baz.h"); List<string> expected = new List<string>(); expected.Add(@"test.c"); expected.Add(@"foo.h"); expected.Add(@"bar.h"); expected.Add(@"baz.h"); CollectionAssert.AreEquivalent(expected, parser.Dependencies); }
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); } } } }
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); } } } }