private static string ExtractNameFrom(BuildEntry buildEntry, BuildData buildData) { Event e = buildEntry.StartEvent; string name = null; if (e is BuildStartedEvent) { StringBuilder builder = new StringBuilder(); builder.Append($"{buildData.BuildConfiguration.Target}"); builder.Append($" - {buildData.BuildConfiguration.Configuration}|{buildData.BuildConfiguration.Platform}"); builder.Append($" - Max parallel: {buildData.BuildConfiguration.MaxParallelProjects} projects, {buildData.BuildConfiguration.MaxParallelCLTasksPerProject} CL tasks per project"); builder.Append($" - {buildData.BuildConfiguration.SolutionPath}"); name = builder.ToString(); } else if (e is ProjectStartedEvent) { name = (e as ProjectStartedEvent).ProjectFile; // find the longest common path between project and solution, then remove it from project file path string[] solutionPath = buildData.BuildConfiguration.SolutionPath.Split(Path.DirectorySeparatorChar); string[] projectPath = name.Split(Path.DirectorySeparatorChar); int firstDifferenceIndex = -1; int minPathSteps = Math.Min(solutionPath.Length, projectPath.Length); for (int i = 0; i < minPathSteps; ++i) { if (solutionPath[i] != projectPath[i]) { firstDifferenceIndex = i; break; } } if (firstDifferenceIndex >= 0) { name = String.Join(Path.DirectorySeparatorChar.ToString(), projectPath, firstDifferenceIndex, projectPath.Length - firstDifferenceIndex); } } else if (e is TargetStartedEvent) { name = (e as TargetStartedEvent).TargetName; } else if (e is TaskStartedEvent) { name = (e as TaskStartedEvent).TaskName; } return(name); }
private Timeline BuildTimelineFrom(BuildData buildData, TimelineBuilderContext context) { Timeline timeline = new Timeline(buildData.BuildConfiguration.MaxParallelProjects); // build belongs to NodeId 0, as reported by MSBuild, while other entries start at NodeId 1 Debug.Assert(context.RootEntry.Context == null); TimelineBuildEntry topLevelTimelineBuildEntry = new TimelineBuildEntry(context.RootEntry, buildData); timeline.AddRoot(topLevelTimelineBuildEntry); // process other entries BuildTimelineEntries(timeline, topLevelTimelineBuildEntry, buildData); return(timeline); }
public TimelineBuilder(BuildData buildData) { m_buildData = buildData; }
private void BuildTimelineEntries(Timeline timeline, TimelineBuildEntry parent, BuildData buildData) { foreach (BuildEntry childEntry in parent.BuildEntry.ChildEntries) { TimelineBuildEntry timelineEntry = new TimelineBuildEntry(childEntry, buildData); // same NodeId? there's a TimelineEntry hierarchy if (parent.BuildEntry.Context?.NodeId == childEntry.Context.NodeId) { parent.AddChild(timelineEntry); } // different NodeId? we've got a new root else { timeline.AddRoot(timelineEntry); } Debug.Assert(timelineEntry != null); BuildTimelineEntries(timeline, timelineEntry, buildData); } }