/// <summary>Finds the BuildEntity entity that applies to this entity.</summary> private static IEnumerable <IBuildableEntity> FindAncestorBuilds(EntityBase entity) { return(from ancestor in entity.AncestorsAndSelf() where ancestor is IBuildableEntity || ancestor is IDefinesBuild let b = (ancestor as IBuildableEntity) ?? ((IDefinesBuild)ancestor).BuildEntity where b != null && b.IsBuildable select b); }
protected override IEnumerable <bool> ExecuteStages(Model model) { // if node was not specified, use entire session if (node == null) { node = model.session.Entity.DataElement; System.Diagnostics.Debug.Assert(node != null); } // Get the entity being acted on EntityBase targetEntity = node.GetEntity(); // determine ancestors that need building var preReqBuilds = (from ancestor in targetEntity.AncestorsAndSelf() where ancestor is IBuildableEntity || ancestor is IDefinesBuild let b = (ancestor as IBuildableEntity) ?? ((IDefinesBuild)ancestor).BuildEntity where b != null && b.IsBuildable select b) .Reverse() // When running the builds, we want to run them from the top-down .ToArray(); // build each pre requisite in order foreach (var build in preReqBuilds) { System.Diagnostics.Debug.Assert(build != null); BuildCommand buildCmd = new BuildCommand(build, Rebuild, interactive); //Debug.WriteLine("BuildAndRunCommand spawning BuildCommand: " + build.DisplayName); buildCmd.Execute(model); yield return(true); // Next stage: Wait until the build finishes while (!buildCmd.Task.IsComplete) { yield return(true); } if (buildCmd.Task.Status == AppTaskStatus.Error || buildCmd.Task.ExitCode != 0) { SetError("Build failed."); yield break; } } // build at each container level child in parallel foreach (bool stageSuccessful in BuildChildren(model, targetEntity)) { if (stageSuccessful) { yield return(true); } else { SetError("Build failed."); yield break; } } // for each test, launch a task if (!buildonly) { // Lets just wait for any other queued commands to run // This adds it to the FollowupCommands. Followup cmds are only executing during // a controller.TimerTick. yield return(true); // Need to wait for all the refresh files to happen so we add it to the quiesce list. Debug.WriteLine("BuildAndRunCommand Quiescing RunAllTestsCommand"); model.controller.AddQuiesceCommand(new RunAllMCutTestsCommand(targetEntity, null, interactive)); } }