예제 #1
0
        private void ProcessTargetStartEvent(TargetStartedEvent e, TimelineBuilderContext context)
        {
            Debug.Assert(context.HasOpenBuilds);
            Debug.Assert(context.HasOpenProjects);

            BuildEntry targetEntry = new BuildEntry(e);

            context.OpenTargetEntries.Add(targetEntry);

            // a target's parent is a Project
            TargetEventContext targetContext = targetEntry.Context as TargetEventContext;

            Debug.Assert(targetContext != null);
            BuildEntry parentEntry = context.OpenProjectEntries.Find(projectEntry =>
            {
                ProjectEventContext projectContext = projectEntry.Context as ProjectEventContext;
                Debug.Assert(projectContext != null);

                return(projectContext.ContextId == targetContext.ContextId &&
                       projectContext.ProjectId == targetContext.ProjectId);
            });

            Debug.Assert(parentEntry != null);
            parentEntry.AddChild(e);
            parentEntry.AddChild(targetEntry);
        }
예제 #2
0
        private void ProcessProjectStartEvent(ProjectStartedEvent e, TimelineBuilderContext context)
        {
            Debug.Assert(context.HasOpenBuilds);

            BuildEntry projectEntry = new BuildEntry(e);

            context.OpenProjectEntries.Add(projectEntry);

            // projects always have a parent, we know which via parent event context
            BuildEntry parentEntry = null;

            // no parent event context mean we've been spawned from the build itself
            if (e.ParentEventContext == null)
            {
                parentEntry = context.RootEntry;
            }
            else
            {
                // a project's parent is a task, although the parent context refers to the task project's
                parentEntry = context.OpenTaskEntries.Find(taskEntry =>
                {
                    TaskEventContext taskContext = taskEntry.Context as TaskEventContext;
                    Debug.Assert(taskContext != null);

                    return(taskContext.ContextId == e.ParentEventContext.ContextId &&
                           taskContext.ProjectId == e.ParentEventContext.ProjectId);
                });

                // finding no task with matching data means our build was requested by a task that's already completed
                // we may have some luck finding the project that spawned that task
                if (parentEntry == null)
                {
                    // our build couldn't be started before within the same node, hence it was scheduled
                    Debug.Assert(e.Context.NodeId != e.ParentEventContext.NodeId);

                    parentEntry = context.OpenProjectEntries.Find(otherProjectEntry =>
                    {
                        ProjectEventContext projectContext = otherProjectEntry.Context as ProjectEventContext;
                        Debug.Assert(projectContext != null);

                        return(projectContext.ContextId == e.ParentEventContext.ContextId &&
                               projectContext.ProjectId == e.ParentEventContext.ProjectId);
                    });

                    // the project may have also finished
                    if (parentEntry == null)
                    {
                        // just consider the build itself our parent
                        parentEntry = context.RootEntry;
                    }
                }
            }

            Debug.Assert(parentEntry != null);
            parentEntry.AddChild(e);
            parentEntry.AddChild(projectEntry);
        }
예제 #3
0
        private void ProcessMessageEvent(MessageEvent e, TimelineBuilderContext context)
        {
            Debug.Assert(context.HasOpenBuilds);

            // a message can be executed as part of any entry: build, project, target or task
            BuildEntry parentEntry = null;

            // part of the build?
            if (e.Context == null)
            {
                parentEntry = context.RootEntry;
            }
            else
            {
                MessageEventContext messageContext = e.Context as MessageEventContext;

                // part of a task?
                if (messageContext.TaskId != null)
                {
                    Debug.Assert(messageContext.ProjectId != null);
                    Debug.Assert(messageContext.TargetId != null);

                    parentEntry = context.OpenTaskEntries.Find(taskEntry =>
                    {
                        TaskEventContext taskContext = taskEntry.Context as TaskEventContext;
                        Debug.Assert(taskContext != null);

                        return(taskContext.NodeId == messageContext.NodeId &&
                               taskContext.ContextId == messageContext.ContextId &&
                               taskContext.ProjectId == messageContext.ProjectId &&
                               taskContext.TargetId == messageContext.TargetId &&
                               taskContext.TaskId == messageContext.TaskId);
                    });
                }
                // part of a target?
                else if (messageContext.TargetId != null)
                {
                    Debug.Assert(messageContext.ProjectId != null);
                    Debug.Assert(messageContext.TaskId == null);

                    parentEntry = context.OpenTargetEntries.Find(targetEntry =>
                    {
                        TargetEventContext targetContext = targetEntry.Context as TargetEventContext;
                        Debug.Assert(targetContext != null);

                        return(targetContext.NodeId == messageContext.NodeId &&
                               targetContext.ContextId == messageContext.ContextId &&
                               targetContext.ProjectId == messageContext.ProjectId &&
                               targetContext.TargetId == messageContext.TargetId);
                    });
                }
                // part of a project?
                else if (messageContext.ProjectId != null)
                {
                    Debug.Assert(messageContext.TargetId == null);
                    Debug.Assert(messageContext.TaskId == null);

                    parentEntry = context.OpenProjectEntries.Find(projectEntry =>
                    {
                        ProjectEventContext projectContext = projectEntry.Context as ProjectEventContext;
                        Debug.Assert(projectContext != null);

                        return(projectContext.NodeId == messageContext.NodeId &&
                               projectContext.ContextId == messageContext.ContextId &&
                               projectContext.ProjectId == messageContext.ProjectId);
                    });
                }
                // part of the build itself?
                else
                {
                    parentEntry = context.RootEntry;
                }
            }

            Debug.Assert(parentEntry != null);
            parentEntry.AddChild(e);
        }