private void buildRule(BuildState state, p_Rule pRule) { state.PushBadLocation("bad"); state.PushGoodLocation("good"); checkBuilder.AppendFormat("public bool check{0}() {{", pRule.ruleName); obtainBuilder.AppendFormat("public p_{0} obtain{0}() {{", pRule.ruleName); classesBuilder.AppendFormat("public class p_{0} {{", pRule.ruleName); buildRuleExpression(state, pRule.RuleExpression); checkBuilder.Append(@"good: symbolGenerator.RestoreState(); return true;"); checkBuilder.Append(@"bad: symbolGenerator.PopState(); return false;"); checkBuilder.AppendLine("}\r\n\r\n\r\n\r\n"); obtainBuilder.AppendLine("}\r\n\r\n\r\n\r\n"); classesBuilder.AppendLine("}\r\n\r\n\r\n\r\n"); state.PopGoodLocation(); state.PopBadLocation(); }
internal Target (XmlElement targetElement, Project project, ImportedProject importedProject) { if (project == null) throw new ArgumentNullException ("project"); if (targetElement == null) throw new ArgumentNullException ("targetElement"); this.targetElement = targetElement; this.name = targetElement.GetAttribute ("Name"); this.project = project; this.engine = project.ParentEngine; this.importedProject = importedProject; this.onErrorElements = new List <XmlElement> (); this.buildState = BuildState.NotStarted; this.buildTasks = new List <BuildTask> (); this.batchingImpl = new TargetBatchingImpl (project, this.targetElement); bool onErrorFound = false; foreach (XmlNode xn in targetElement.ChildNodes) { if (xn is XmlElement) { XmlElement xe = (XmlElement) xn; if (xe.Name == "OnError") { onErrorElements.Add (xe); onErrorFound = true; } else if (onErrorFound) throw new InvalidProjectFileException ( "The element <OnError> must be last under element <Target>. Found element <Error> instead."); else buildTasks.Add (new BuildTask (xe, this)); } } }
public GameState() { this.buildState = new BuildState(); this.regularState = new RegularState(); this.pauseState = new PauseState(); state = regularState; }
private void buildOrPiece(BuildState state, p_OrPiece orPiece) { var curState = state.nextGoodState++; state.PushGoodLocation("endOfOr" + curState); state.PushBadLocation("curBad" + curState); var itms = Helper.CombineArray(orPiece.RuleExpression1, orPiece.RuleExpressions).ToArray(); int ind = 0; foreach (p_RuleExpression expression in itms) { var j = state.nextGoodState; state.PushBadLocation(string.Format("bottomPiece{0}", j)); buildRuleExpression(state, expression); state.PopBadLocation(); checkBuilder.AppendLine(string.Format("bottomPiece{0}:", j)); if (ind++ == itms.Length-1) checkBuilder.AppendLine("goto " + state.BadLocation() + ";"); else checkBuilder.AppendLine("goto nextPiece" + state.nextGoodState + ";"); } state.PopBadLocation(); state.PopGoodLocation(); checkBuilder.AppendLine("curBad" + curState + ": goto " + state.BadLocation(state.nextGoodState) + ";"); checkBuilder.AppendLine("endOfOr" + curState + ":"); checkBuilder.AppendLine(string.Format("goto {0};", state.GoodLocation)); }
public void UpdateStatus(BuildState state, DateTimeOffset timeStamp) { lock (device) { if (!device.IsOpen) device.Open(); } switch (state) { case BuildState.Unknown: device.TurnOn(Color.Red); device.TurnOn(Color.Green); device.TurnOff(Color.Yellow); break; case BuildState.Succeeded: device.TurnOff(Color.Red); device.TurnOff(Color.Yellow); TurnOnColorWithCustomPowerLevel(Color.Green, timeStamp); lastCompletedState = state;; break; case BuildState.Error: case BuildState.Failed: device.TurnOff(Color.Green); device.TurnOff(Color.Yellow); TurnOnColorWithCustomPowerLevel(Color.Red, timeStamp); if (lastCompletedState != BuildState.Failed && lastCompletedState != BuildState.Error) device.StartBuzzer(100, 2, 20, 20); lastCompletedState = state; break; case BuildState.Running: device.TurnOff(Color.Red); if (lastCompletedState == BuildState.Succeeded) { device.TurnOff(Color.Yellow); device.Flash(Color.Green); } else { device.TurnOff(Color.Green); device.Flash(Color.Yellow); } break; default: device.Flash(Color.Red); break; } lastCompletedState = state != BuildState.Running ? state : lastCompletedState; lastUpdateTime = timeStamp; }
static void Main() { var plugin = new TextToSpeechPlugin(); var buildState = new BuildState(); Task sayBuildFixed = plugin.Start(buildState, BuildStatus.Fixed); sayBuildFixed.Wait(); Task sayBuildBroken = plugin.Start(buildState, BuildStatus.Broken); sayBuildBroken.RunSynchronously(); Task sayBuildStillBroken = plugin.Start(buildState, BuildStatus.StillBroken); sayBuildStillBroken.RunSynchronously(); }
internal Target (XmlElement targetElement, Project project, ImportedProject importedProject) { if (project == null) throw new ArgumentNullException ("project"); if (targetElement == null) throw new ArgumentNullException ("targetElement"); this.targetElement = targetElement; this.name = targetElement.GetAttribute ("Name"); this.project = project; this.engine = project.ParentEngine; this.importedProject = importedProject; this.onErrorElements = new List <XmlElement> (); this.buildState = BuildState.NotStarted; this.buildTasks = new List <BuildTask> (); this.batchingImpl = new TargetBatchingImpl (project, this.targetElement); bool onErrorFound = false; foreach (XmlNode xn in targetElement.ChildNodes) { if (xn is XmlElement) { XmlElement xe = (XmlElement) xn; if (xe.Name == "OnError") { onErrorElements.Add (xe); onErrorFound = true; } else if (onErrorFound) throw new InvalidProjectFileException ( "The element <OnError> must be last under element <Target>. Found element <Error> instead."); #if NET_3_5 else if (xe.Name == "ItemGroup") { //don't blow up for ItemGroups inside Targets in >= 3.5 // TODO: evaluate them (see https://bugzilla.xamarin.com/show_bug.cgi?id=1862 and test in TargetTest.cs ) continue; } #endif else buildTasks.Add (new BuildTask (xe, this)); } } }
public void RecieveBuildResult(Revision buildRevision, BuildState state) { RecieveBuildResult(buildRevision.Number, state); throw new NotImplementedException("TODO: インスタンスの保存を行う"); }
public void Tick() { // Pick a free queue var queue = ai.FindQueues(category).FirstOrDefault(); if (queue == null) { return; } var currentBuilding = queue.CurrentItem(); switch (state) { case BuildState.ChooseItem: var item = chooseItem(queue); if (item == null) { state = BuildState.WaitForFeedback; lastThinkTick = ai.ticks; } else { HackyAI.BotDebug("AI: Starting production of {0}".F(item.Name)); state = BuildState.WaitForProduction; ai.world.IssueOrder(Order.StartProduction(queue.self, item.Name, 1)); } break; case BuildState.WaitForProduction: if (currentBuilding == null) { return; } if (currentBuilding.Paused) { ai.world.IssueOrder(Order.PauseProduction(queue.self, currentBuilding.Item, false)); } else if (currentBuilding.Done) { state = BuildState.WaitForFeedback; lastThinkTick = ai.ticks; // Place the building var type = BuildingType.Building; if (Rules.Info[currentBuilding.Item].Traits.Contains <AttackBaseInfo>()) { type = BuildingType.Defense; } else if (Rules.Info[currentBuilding.Item].Traits.Contains <OreRefineryInfo>()) { type = BuildingType.Refinery; } var location = ai.ChooseBuildLocation(currentBuilding.Item, type); if (location == null) { HackyAI.BotDebug("AI: Nowhere to place {0}".F(currentBuilding.Item)); ai.world.IssueOrder(Order.CancelProduction(queue.self, currentBuilding.Item, 1)); } else { ai.world.IssueOrder(new Order("PlaceBuilding", ai.p.PlayerActor, false) { TargetLocation = location.Value, TargetString = currentBuilding.Item }); } } break; case BuildState.WaitForFeedback: if (ai.ticks - lastThinkTick > HackyAI.feedbackTime) { state = BuildState.ChooseItem; } break; } }
private void Exec_Reload(BuildState NewState) { _buildState = NewState; _timer.Enabled = true; _timer.StopCountdown(); switch (NewState) { case BuildState.Build: { if (_piston.Velocity >= 0) { _piston.Velocity = -_piston.Velocity; _piston.Enabled = true; } _projector.Enabled = true; foreach (IMyShipWelder welder in _welders) { welder.Enabled = true; } _timer.TriggerDelay = 30; _timer.StartCountdown(); } break; case BuildState.Rise: { _piston.Enabled = true; if (_piston.Velocity <= 0) { _piston.Velocity = -_piston.Velocity; } _timer.TriggerDelay = 125; _timer.StartCountdown(); } break; case BuildState.Cut: { _torpDock.Enabled = true; foreach (IMyThrust cutter in _cutters) { cutter.Enabled = true; } _projector.Enabled = false; foreach (IMyShipWelder welder in _welders) { welder.Enabled = false; } _timer.TriggerDelay = 10; _timer.StartCountdown(); } break; case BuildState.Reset: { _torpDock.Connect(); foreach (IMyThrust cutter in _cutters) { cutter.Enabled = false; } _timer.TriggerDelay = 8; _timer.StartCountdown(); } break; case BuildState.Idle: { } break; default: return; } }
/// <summary> /// Sets the build state back to "NotStarted". /// </summary> internal void ResetBuildStatus ( ) { this.buildState = BuildState.NotStarted; }
/// <summary> /// Builds this target if it has not already been built as part of its parent project. Before we actually execute the /// tasks for this target, though, we first call on all the dependent targets to build themselves. /// This function may throw InvalidProjectFileException /// </summary> internal void Build ( ProjectBuildState buildContext ) { // Depending on the build state, we may do different things. switch (buildState) { case BuildState.InProgress: // In single proc mode if the build state was already "in progress" // and somebody just told us to build ourselves, it means that there is // a loop (circular dependency) in the target dependency graph. In multi // proc mode we need to analyze the dependency graph before we can // tell if there a circular dependency or if two independent chains // of targets happen to need the result of this target. if (parentEngine.Router.SingleThreadedMode || buildContext.ContainsCycle(this.Name)) { ProjectErrorUtilities.VerifyThrowInvalidProject(false, TargetElement, "CircularDependency", targetName); } else { buildContext.CurrentBuildContextState = ProjectBuildState.BuildContextState.WaitingForTarget; this.executionState.AddWaitingBuildContext(buildContext); } break; case BuildState.CompletedSuccessfully: case BuildState.CompletedUnsuccessfully: // If this target has already been built as part of this project, // we're not going to build it again. Just return the result // from when it was built previously. Note: This condition // could really only ever hold true if the user specifically // requested us to build multiple targets and there existed // a direct or indirect dependency relationship between two or // more of those top-level targets. // Note: we aren't really entering the target in question here, so don't use the target // event context. Using the target ID for skipped messages would force us to // cache the individual target IDs for unloaded projects and it's not really worth the trouble. // Just use the parent event context. parentEngine.LoggingServices.LogComment(buildContext.ProjectBuildEventContext, ((buildState == BuildState.CompletedSuccessfully) ? "TargetAlreadyCompleteSuccess" : "TargetAlreadyCompleteFailure"), this.targetName); // Only contexts which are generated from an MSBuild task could need // the outputs of this target, such contexts have a non-null evaluation // request if ((buildState == BuildState.CompletedSuccessfully) && (buildContext.BuildRequest.OutputsByTarget != null && buildContext.NameOfBlockingTarget == null)) { error.VerifyThrow( String.Compare(EscapingUtilities.UnescapeAll(buildContext.NameOfTargetInProgress), this.Name, StringComparison.OrdinalIgnoreCase) == 0, "The name of the target in progress is inconsistent with the target being built"); error.VerifyThrow(targetOutputItems != null, "If the target built successfully, we must have its outputs."); buildContext.BuildRequest.OutputsByTarget[Name] = targetOutputItems.ToArray(); } if (buildContext.NameOfBlockingTarget == null) { buildContext.BuildRequest.ResultByTarget[Name] = buildState; } break; case BuildState.NotStarted: case BuildState.Skipped: { // Always have to create a new context in build as other projects or targets may try and build this target BuildEventContext targetBuildEventContext = new BuildEventContext ( buildContext.ProjectBuildEventContext.NodeId, this.id, buildContext.ProjectBuildEventContext.ProjectContextId, buildContext.ProjectBuildEventContext.TaskId ); Expander expander = new Expander(this.parentProject.evaluatedProperties, this.parentProject.evaluatedItemsByName); // We first make sure no batching was attempted with the target's condition. if (!conditionCheckedForInvalidMetadataReferences) { if (ExpressionShredder.ContainsMetadataExpressionOutsideTransform(this.Condition)) { ProjectErrorUtilities.ThrowInvalidProject(this.conditionAttribute, "TargetConditionHasInvalidMetadataReference", targetName, this.Condition); } conditionCheckedForInvalidMetadataReferences = true; } // If condition is false (based on propertyBag), set this target's state to // "Skipped" since we won't actually build it. if (!Utilities.EvaluateCondition(this.Condition, this.conditionAttribute, expander, null, ParserOptions.AllowProperties | ParserOptions.AllowItemLists, parentEngine.LoggingServices, targetBuildEventContext)) { buildState = BuildState.Skipped; if (buildContext.NameOfBlockingTarget == null) { buildContext.BuildRequest.ResultByTarget[Name] = buildState; } if (!parentEngine.LoggingServices.OnlyLogCriticalEvents) { // Expand the expression for the Log. string expanded = expander.ExpandAllIntoString(this.Condition, this.conditionAttribute); // By design: Not building dependencies. This is what NAnt does too. parentEngine.LoggingServices.LogComment(targetBuildEventContext, "TargetSkippedFalseCondition", this.targetName, this.Condition, expanded); } } else { // This target has not been built yet. So build it! // Change our state to "in progress". TargetParameters will need to be re-calculated if Inputs and Outputs attribute has changed. buildState = BuildState.InProgress; List<string> batchableTargetParameters = GetBatchableTargetParameters(); executionState = new TargetExecutionWrapper(this, taskElementList, batchableTargetParameters, targetElement, expander, targetBuildEventContext); ContinueBuild(buildContext, null); } } break; default: error.VerifyThrow(false, "Build state {0} not handled in Target.Build method", buildState); break; } }
private void OnStatusChanged(BuildState oldState, BuildState newState, DateTimeOffset timeStamp) { var handler = StatusChanged; if (handler != null) handler(this, new StatusChangedEventArgs(oldState, newState, timeStamp)); }
public void Tick() { // Pick a free queue var queue = FindQueues("Ship").FirstOrDefault(); if (queue == null) { AI.Debug("Can't find free queue."); return; } switch (state) { case BuildState.ChooseItem: { if (queue.CurrentItem() != null) { // AI.Debug("VehicleBuilder currentItem != null"); state = BuildState.WaitForProduction; return; } String item = ChooseShip(queue); if (item == null) { state = BuildState.WaitForFeedback; // AI.Debug("No building to choose from to produce"); } else { state = BuildState.WaitForProduction; world.IssueOrder(Order.StartProduction(queue.self, item, 1)); // AI.Debug("Ordering vehicle {0}", item); } break; } case BuildState.WaitForProduction: { var currentBuilding = queue.CurrentItem(); if (currentBuilding == null) { state = BuildState.WaitForFeedback; /*AI.Debug("currentBuilding is null");*/ return; } else if (currentBuilding.Paused) world.IssueOrder(Order.PauseProduction(queue.self, currentBuilding.Item, false)); if (queue.CurrentDone) { state = BuildState.WaitForFeedback; // PlaceStructure(queue, currentBuilding); } break; } case BuildState.WaitForFeedback: { if (AI.ticks % feedbacktime == 0) state = BuildState.ChooseItem; break; } } }
public void Handle(BuildState state) { }
protected void NotFound(string aName) { mExceptionList.Add("Prerequisite '" + aName + "' not found."); mBuildState = BuildState.PrerequisiteMissing; }
/// <summary> /// Builds this target if it has not already been built as part of its parent project. Before we actually execute the /// tasks for this target, though, we first call on all the dependent targets to build themselves. /// This function may throw InvalidProjectFileException /// </summary> internal void Build ( ProjectBuildState buildContext ) { // Depending on the build state, we may do different things. switch (buildState) { case BuildState.InProgress: // In single proc mode if the build state was already "in progress" // and somebody just told us to build ourselves, it means that there is // a loop (circular dependency) in the target dependency graph. In multi // proc mode we need to analyze the dependency graph before we can // tell if there a circular dependency or if two independent chains // of targets happen to need the result of this target. if (parentEngine.Router.SingleThreadedMode || buildContext.ContainsCycle(this.Name)) { ProjectErrorUtilities.VerifyThrowInvalidProject(false, TargetElement, "CircularDependency", targetName); } else { buildContext.CurrentBuildContextState = ProjectBuildState.BuildContextState.WaitingForTarget; this.executionState.AddWaitingBuildContext(buildContext); } break; case BuildState.CompletedSuccessfully: case BuildState.CompletedUnsuccessfully: // If this target has already been built as part of this project, // we're not going to build it again. Just return the result // from when it was built previously. Note: This condition // could really only ever hold true if the user specifically // requested us to build multiple targets and there existed // a direct or indirect dependency relationship between two or // more of those top-level targets. // Note: we aren't really entering the target in question here, so don't use the target // event context. Using the target ID for skipped messages would force us to // cache the individual target IDs for unloaded projects and it's not really worth the trouble. // Just use the parent event context. parentEngine.LoggingServices.LogComment(buildContext.ProjectBuildEventContext, ((buildState == BuildState.CompletedSuccessfully) ? "TargetAlreadyCompleteSuccess" : "TargetAlreadyCompleteFailure"), this.targetName); // Only contexts which are generated from an MSBuild task could need // the outputs of this target, such contexts have a non-null evaluation // request if ((buildState == BuildState.CompletedSuccessfully) && (buildContext.BuildRequest.OutputsByTarget != null && buildContext.NameOfBlockingTarget == null)) { error.VerifyThrow( String.Compare(EscapingUtilities.UnescapeAll(buildContext.NameOfTargetInProgress), this.Name, StringComparison.OrdinalIgnoreCase) == 0, "The name of the target in progress is inconsistent with the target being built"); error.VerifyThrow(targetOutputItems != null, "If the target built successfully, we must have its outputs."); buildContext.BuildRequest.OutputsByTarget[Name] = targetOutputItems.ToArray(); } if (buildContext.NameOfBlockingTarget == null) { buildContext.BuildRequest.ResultByTarget[Name] = buildState; } break; case BuildState.NotStarted: case BuildState.Skipped: { // Always have to create a new context in build as other projects or targets may try and build this target BuildEventContext targetBuildEventContext = new BuildEventContext ( buildContext.ProjectBuildEventContext.NodeId, this.id, buildContext.ProjectBuildEventContext.ProjectContextId, buildContext.ProjectBuildEventContext.TaskId ); Expander expander = new Expander(this.parentProject.evaluatedProperties, this.parentProject.evaluatedItemsByName); // We first make sure no batching was attempted with the target's condition. if (!conditionCheckedForInvalidMetadataReferences) { if (ExpressionShredder.ContainsMetadataExpressionOutsideTransform(this.Condition)) { ProjectErrorUtilities.ThrowInvalidProject(this.conditionAttribute, "TargetConditionHasInvalidMetadataReference", targetName, this.Condition); } conditionCheckedForInvalidMetadataReferences = true; } // If condition is false (based on propertyBag), set this target's state to // "Skipped" since we won't actually build it. if (!Utilities.EvaluateCondition(this.Condition, this.conditionAttribute, expander, null, ParserOptions.AllowProperties | ParserOptions.AllowItemLists, parentEngine.LoggingServices, targetBuildEventContext)) { buildState = BuildState.Skipped; if (buildContext.NameOfBlockingTarget == null) { buildContext.BuildRequest.ResultByTarget[Name] = buildState; } if (!parentEngine.LoggingServices.OnlyLogCriticalEvents) { // Expand the expression for the Log. string expanded = expander.ExpandAllIntoString(this.Condition, this.conditionAttribute); // By design: Not building dependencies. This is what NAnt does too. parentEngine.LoggingServices.LogComment(targetBuildEventContext, "TargetSkippedFalseCondition", this.targetName, this.Condition, expanded); } } else { // This target has not been built yet. So build it! // Change our state to "in progress". TargetParameters will need to be re-calculated if Inputs and Outputs attribute has changed. buildState = BuildState.InProgress; List <string> batchableTargetParameters = GetBatchableTargetParameters(); executionState = new TargetExecutionWrapper(this, taskElementList, batchableTargetParameters, targetElement, expander, targetBuildEventContext); ContinueBuild(buildContext, null); } } break; default: error.VerifyThrow(false, "Build state {0} not handled in Target.Build method", buildState); break; } }
public bool CanHandle(BuildState state) { return(_criteria.IsSatisfied(state.CurrentStatementTrimmed)); }
/// <summary> /// Initializes a persisted target from an existing <Target> element which exists either in the main parent project /// file or one of the imported files. /// </summary> /// <param name="targetElement"></param> /// <param name="project"></param> /// <param name="importedFromAnotherProject"></param> internal Target ( XmlElement targetElement, Project project, bool importedFromAnotherProject ) { // Make sure a valid node has been given to us. error.VerifyThrow(targetElement != null, "Need a valid XML node."); // Make sure this really is the <target> node. ProjectXmlUtilities.VerifyThrowElementName(targetElement, XMakeElements.target); this.targetElement = targetElement; this.parentProject = project; this.parentEngine = project.ParentEngine; this.conditionAttribute = null; this.taskElementList = null; this.importedFromAnotherProject = importedFromAnotherProject; this.buildState = BuildState.NotStarted; this.id = project.ParentEngine.GetNextTargetId(); // The target name and target dependendencies (dependencies on other // targets) are specified as attributes of the <target> element. XmlAttribute returnsAttribute = null; // Loop through all the attributes on the <target> element. foreach (XmlAttribute targetAttribute in targetElement.Attributes) { switch (targetAttribute.Name) { // Process the "condition" attribute. case XMakeAttributes.condition: this.conditionAttribute = targetAttribute; break; // Process the "name" attribute. case XMakeAttributes.name: this.targetName = EscapingUtilities.UnescapeAll(targetAttribute.Value); // Target names cannot contain MSBuild special characters, embedded properties, // or item lists. int indexOfSpecialCharacter = this.targetName.IndexOfAny(XMakeElements.illegalTargetNameCharacters); if (indexOfSpecialCharacter >= 0) { ProjectErrorUtilities.VerifyThrowInvalidProject(false, targetAttribute, "NameInvalid", targetName, targetName[indexOfSpecialCharacter]); } break; // Process the "dependsOnTargets" attribute. case XMakeAttributes.dependsOnTargets: this.dependsOnTargetsAttribute = targetAttribute; break; case XMakeAttributes.inputs: this.inputsAttribute = targetAttribute; recalculateBatchableParameters = true; break; case XMakeAttributes.outputs: this.outputsAttribute = targetAttribute; recalculateBatchableParameters = true; break; // This is only recognized by the new OM: // so that the compat tests keep passing, // ignore it. case XMakeAttributes.keepDuplicateOutputs: break; // This is only recognized by the new OM: // so that the compat tests keep passing, // ignore it. case XMakeAttributes.returns: returnsAttribute = targetAttribute; break; // These are only recognized by the new OM: // while the solution wrapper generator is using // the old OM to parse projects for dependencies, // we must make sure to not fail for these case XMakeAttributes.beforeTargets: case XMakeAttributes.afterTargets: break; default: ProjectXmlUtilities.ThrowProjectInvalidAttribute(targetAttribute); break; } } // Hack to help the 3.5 engine at least pretend to still be able to build on top of // the 4.0 targets. In cases where there is no Outputs attribute, just a Returns attribute, // we can approximate the correct behaviour by making the Returns attribute our "outputs" attribute. if (this.outputsAttribute == null && returnsAttribute != null) { this.outputsAttribute = returnsAttribute; recalculateBatchableParameters = true; } // It's considered an error if a target does not have a name. ProjectErrorUtilities.VerifyThrowInvalidProject((targetName != null) && (targetName.Length > 0), targetElement, "MissingRequiredAttribute", XMakeAttributes.name, XMakeElements.target); this.taskElementList = new ArrayList(); // Process each of the child nodes beneath the <Target>. XmlElement anyOnErrorElement = null; List <XmlElement> childElements = ProjectXmlUtilities.GetValidChildElements(targetElement); foreach (XmlElement childElement in childElements) { bool onErrorOutOfOrder = false; switch (childElement.Name) { case XMakeElements.onError: anyOnErrorElement = childElement; break; default: onErrorOutOfOrder = (anyOnErrorElement != null); this.taskElementList.Add(new BuildTask(childElement, this, this.importedFromAnotherProject)); break; } // Check for out-of-order OnError ProjectErrorUtilities.VerifyThrowInvalidProject(!onErrorOutOfOrder, anyOnErrorElement, "NodeMustBeLastUnderElement", XMakeElements.onError, XMakeElements.target, childElement.Name); } }
public void Handle(BuildState state) { _netlistRemover.Remove(state.NetlistSource); throw new InvalidOperationException("cannot process this line {0} ".FormatWith(state.CurrentStatementTrimmed)); }
public int GetNumberOfBuildsByState(BuildState successState) { return _builds.Where(build => build.BuildSuccessState == successState).Count(); }
public IEnumerable <RevisionData> GenerateElements(IEnumerable <Revision> revisions, int totalRevisions, int startIndex, string tipRev, string inProgressRevision, bool revisionActionsEnabled, bool buildServiceEnabled, string currentUser) { int index = startIndex; foreach (var rev in revisions) { index++; var current = rev.revisionID == tipRev; // Calculate build status BuildState buildState = BuildState.None; int buildFailures = 0; if (rev.buildStatuses != null && rev.buildStatuses.Length > 0) { bool inProgress = false; foreach (CloudBuildStatus buildStatus in rev.buildStatuses) { if (buildStatus.complete) { if (!buildStatus.success) { buildFailures++; } } else { inProgress = true; break; } } if (inProgress) { buildState = BuildState.InProgress; } else if (buildFailures > 0) { buildState = BuildState.Failed; } else { buildState = BuildState.Success; } } else if (current && !buildServiceEnabled) { buildState = BuildState.Configure; } // Calculate the number of changes performed on files and folders (not meta files) var paths = new Dictionary <string, ChangeData>(); foreach (ChangeAction change in rev.entries) { if (change.path.EndsWith(".meta")) { var path = change.path.Substring(0, change.path.Length - 5); // Actions taken on meta files are secondary to any actions taken on the main file if (!paths.ContainsKey(path)) { paths[path] = new ChangeData { path = path, action = change.action } } ; } else { paths[change.path] = new ChangeData { path = change.path, action = change.action }; } } var displayName = (rev.author != currentUser) ? rev.authorName : "You"; var item = new RevisionData { id = rev.revisionID, index = totalRevisions - index + 1, timeStamp = TimeStampToDateTime(rev.timeStamp), authorName = displayName, comment = rev.comment, obtained = rev.isObtained, current = current, inProgress = (rev.revisionID == inProgressRevision), enabled = revisionActionsEnabled, buildState = buildState, buildFailures = buildFailures, changes = paths.Values.Take(k_MaxChangesPerRevision).ToList(), changesTotal = paths.Values.Count, changesTruncated = paths.Values.Count > k_MaxChangesPerRevision }; yield return(item); } }
public void Tick() { // Pick a free queue var queue = ai.world.Queries.WithTrait<ProductionQueue>() .Where(a => a.Actor.Owner == ai.p && a.Trait.Info.Type == category) .Select(a => a.Trait) .FirstOrDefault(); if (queue == null) return; var currentBuilding = queue.CurrentItem(); switch (state) { case BuildState.ChooseItem: { var item = chooseItem(queue); if (item == null) { state = BuildState.WaitForFeedback; lastThinkTick = ai.ticks; } else { BotDebug("AI: Starting production of {0}".F(item.Name)); state = BuildState.WaitForProduction; ai.world.IssueOrder(Order.StartProduction(queue.self, item.Name, 1)); } } break; case BuildState.WaitForProduction: if (currentBuilding == null) return; /* let it happen.. */ else if (currentBuilding.Paused) ai.world.IssueOrder(Order.PauseProduction(queue.self, currentBuilding.Item, false)); else if (currentBuilding.Done) { state = BuildState.WaitForFeedback; lastThinkTick = ai.ticks; /* place the building */ var location = ai.ChooseBuildLocation(currentBuilding); if (location == null) { BotDebug("AI: Nowhere to place {0}".F(currentBuilding.Item)); ai.world.IssueOrder(Order.CancelProduction(queue.self, currentBuilding.Item, 1)); } else { ai.world.IssueOrder(new Order("PlaceBuilding", ai.p.PlayerActor, false) { TargetLocation = location.Value, TargetString = currentBuilding.Item }); } } break; case BuildState.WaitForFeedback: if (ai.ticks - lastThinkTick > feedbackTime) state = BuildState.ChooseItem; break; } }
protected void CheckPrereqs() { Section("Checking Prerequisites"); Echo("Note: This check only prerequisites for building, please see website for full list."); Echo("Checking for x86 run."); if (!AmRunning32Bit()) { mExceptionList.Add("Builder must run as x86"); mBuildState = BuildState.PrerequisiteMissing; } // We assume they have normal .NET stuff if user was able to build the builder... CheckOS(); CheckIfUserKitRunning(); CheckIsVsRunning(); CheckIfBuilderRunning(); switch (App.VsVersion) { case VsVersion.Vs2015: CheckVs2015(); CheckForInstall("Microsoft Visual Studio 2015 SDK - ENU", true); break; default: throw new NotImplementedException(); } //works also without, only close of VMWare is not working! CheckNet35Sp1(); // Required by VMWareLib and other stuff CheckNet403(); CheckForInno(); bool vmWareInstalled = true; bool bochsInstalled = IsBochsInstalled(); if (!CheckForInstall("VMware Workstation", false)) { if (!CheckForInstall("VMware Player", false)) { if (!CheckForInstall("VMwarePlayer_x64", false)) { vmWareInstalled = false; } } } if (!vmWareInstalled && !bochsInstalled) { NotFound("VMWare or Bochs"); } // VIX is installed with newer VMware Workstations (8+ for sure). VMware player does not install it? // We need to just watch this and adjust as needed. //CheckForInstall("VMWare VIX", true); }
public BuildLocator State(BuildState buildState) { _locators.Add(new ApiLocator("state", buildState.ToString().ToUpper())); return(this); }
void CheckForInno() { Echo("Checking for Inno Setup"); using ( var xKey = Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1", false)) { if (xKey == null) { mExceptionList.Add("Cannot find Inno Setup."); mBuildState = BuildState.PrerequisiteMissing; return; } mInnoPath = (string) xKey.GetValue("InstallLocation"); if (string.IsNullOrWhiteSpace(mInnoPath)) { mExceptionList.Add("Cannot find Inno Setup."); mBuildState = BuildState.PrerequisiteMissing; return; } } Echo("Checking for Inno Preprocessor"); if (!File.Exists(Path.Combine(mInnoPath, "ISPP.dll"))) { mExceptionList.Add("Inno Preprocessor not detected."); mBuildState = BuildState.PrerequisiteMissing; return; } }
/// <summary> /// Initializes a persisted target from an existing <Target> element which exists either in the main parent project /// file or one of the imported files. /// </summary> /// <param name="targetElement"></param> /// <param name="project"></param> /// <param name="importedFromAnotherProject"></param> internal Target ( XmlElement targetElement, Project project, bool importedFromAnotherProject ) { // Make sure a valid node has been given to us. error.VerifyThrow(targetElement != null,"Need a valid XML node."); // Make sure this really is the <target> node. ProjectXmlUtilities.VerifyThrowElementName(targetElement, XMakeElements.target); this.targetElement = targetElement; this.parentProject = project; this.parentEngine = project.ParentEngine; this.conditionAttribute = null; this.taskElementList = null; this.importedFromAnotherProject = importedFromAnotherProject; this.buildState = BuildState.NotStarted; this.id = project.ParentEngine.GetNextTargetId(); // The target name and target dependendencies (dependencies on other // targets) are specified as attributes of the <target> element. XmlAttribute returnsAttribute = null; // Loop through all the attributes on the <target> element. foreach (XmlAttribute targetAttribute in targetElement.Attributes) { switch (targetAttribute.Name) { // Process the "condition" attribute. case XMakeAttributes.condition: this.conditionAttribute = targetAttribute; break; // Process the "name" attribute. case XMakeAttributes.name: this.targetName = EscapingUtilities.UnescapeAll(targetAttribute.Value); // Target names cannot contain MSBuild special characters, embedded properties, // or item lists. int indexOfSpecialCharacter = this.targetName.IndexOfAny(XMakeElements.illegalTargetNameCharacters); if (indexOfSpecialCharacter >= 0) { ProjectErrorUtilities.VerifyThrowInvalidProject(false, targetAttribute, "NameInvalid", targetName, targetName[indexOfSpecialCharacter]); } break; // Process the "dependsOnTargets" attribute. case XMakeAttributes.dependsOnTargets: this.dependsOnTargetsAttribute = targetAttribute; break; case XMakeAttributes.inputs: this.inputsAttribute = targetAttribute; recalculateBatchableParameters = true; break; case XMakeAttributes.outputs: this.outputsAttribute = targetAttribute; recalculateBatchableParameters = true; break; // This is only recognized by the new OM: // so that the compat tests keep passing, // ignore it. case XMakeAttributes.keepDuplicateOutputs: break; // This is only recognized by the new OM: // so that the compat tests keep passing, // ignore it. case XMakeAttributes.returns: returnsAttribute = targetAttribute; break; // These are only recognized by the new OM: // while the solution wrapper generator is using // the old OM to parse projects for dependencies, // we must make sure to not fail for these case XMakeAttributes.beforeTargets: case XMakeAttributes.afterTargets: break; default: ProjectXmlUtilities.ThrowProjectInvalidAttribute(targetAttribute); break; } } // Hack to help the 3.5 engine at least pretend to still be able to build on top of // the 4.0 targets. In cases where there is no Outputs attribute, just a Returns attribute, // we can approximate the correct behaviour by making the Returns attribute our "outputs" attribute. if (this.outputsAttribute == null && returnsAttribute != null) { this.outputsAttribute = returnsAttribute; recalculateBatchableParameters = true; } // It's considered an error if a target does not have a name. ProjectErrorUtilities.VerifyThrowInvalidProject((targetName != null) && (targetName.Length > 0), targetElement, "MissingRequiredAttribute", XMakeAttributes.name, XMakeElements.target); this.taskElementList = new ArrayList(); // Process each of the child nodes beneath the <Target>. XmlElement anyOnErrorElement = null; List<XmlElement> childElements = ProjectXmlUtilities.GetValidChildElements(targetElement); foreach (XmlElement childElement in childElements) { bool onErrorOutOfOrder = false; switch (childElement.Name) { case XMakeElements.onError: anyOnErrorElement = childElement; break; default: onErrorOutOfOrder = (anyOnErrorElement != null); this.taskElementList.Add(new BuildTask(childElement, this, this.importedFromAnotherProject)); break; } // Check for out-of-order OnError ProjectErrorUtilities.VerifyThrowInvalidProject(!onErrorOutOfOrder, anyOnErrorElement, "NodeMustBeLastUnderElement", XMakeElements.onError, XMakeElements.target, childElement.Name); } }
protected bool CheckForProduct(string aCheck, bool aCanThrow, string aKey, string aValueName) { Echo("Checking for " + aCheck); string xCheck = aCheck.ToUpper(); string[] xKeys; using (var xKey = Registry.LocalMachine.OpenSubKey(aKey, false)) { xKeys = xKey.GetSubKeyNames(); } foreach (string xSubKey in xKeys) { using (var xKey = Registry.LocalMachine.OpenSubKey(aKey + xSubKey)) { string xValue = (string) xKey.GetValue(aValueName); if (xValue != null && xValue.ToUpper().Contains(xCheck)) { if (mBuildState != BuildState.PrerequisiteMissing) { mBuildState = BuildState.Running; return true; } else return false; } } } if (aCanThrow) { NotFound(aCheck); } return false; }
/// <summary> /// Update the target data structures since the target has completed /// </summary> internal void UpdateTargetStateOnBuildCompletion ( BuildState stateOfBuild, List<BuildItem> targetOutputItemList ) { this.buildState = stateOfBuild; this.targetOutputItems = targetOutputItemList; // Clear the execution state since the build is completed executionState = null; }
public virtual void Update() { if (buildState == BuildState.Constructed) { Tick(); } else if (buildState == BuildState.Destroying) { // Advance destroyed progression destroyTime = Mathf.Max(destroyTime - Time.deltaTime, 0f); if (destroyTime == 0) { buildState = BuildState.Destroyed; if(Destroyed != null) Destroyed(); } } }
protected void CheckNet35Sp1() { Echo("Checking for .NET 3.5 SP1"); bool xInstalled = false; using (var xKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5")) { if (xKey != null) { xInstalled = (int) xKey.GetValue("SP", 0) >= 1; } } if (!xInstalled) { NotFound(".NET 3.5 SP1"); mBuildState = BuildState.PrerequisiteMissing; } }
private void BuildEvents_OnBuildBegin(vsBuildScope scope, vsBuildAction action) { if (action == vsBuildAction.vsBuildActionDeploy) { return; } RegisterLogger(); _currentState = BuildState.InProgress; _buildStartTime = DateTime.Now; _buildFinishTime = null; _buildAction = action; switch (scope) { case vsBuildScope.vsBuildScopeSolution: case vsBuildScope.vsBuildScopeBatch: case vsBuildScope.vsBuildScopeProject: _buildScope = scope; break; case 0: // Scope may be 0 in case of Clean solution, then Start (F5). _buildScope = vsBuildScope.vsBuildScopeSolution; break; default: throw new ArgumentOutOfRangeException("scope"); } if (scope == vsBuildScope.vsBuildScopeProject) { var projContext = _activeProjectContext; switch (projContext.Type) { case vsWindowType.vsWindowTypeSolutionExplorer: ////var solutionExplorer = (UIHierarchy)dte.Windows.Item(Constants.vsext_wk_SProjectWindow).Object; var solutionExplorer = (UIHierarchy)projContext.Object; var items = (Array)solutionExplorer.SelectedItems; switch (items.Length) { case 0: TraceManager.TraceError("Unable to get target projects in Solution Explorer (vsBuildScope.vsBuildScopeProject)"); _buildScopeProject = null; break; case 1: var item = (UIHierarchyItem)items.GetValue(0); _buildScopeProject = (Project)item.Object; break; default: _buildScopeProject = null; break; } break; case vsWindowType.vsWindowTypeDocument: _buildScopeProject = projContext.Project; break; default: throw new InvalidOperationException("Unsupported type of active project context for vsBuildScope.vsBuildScopeProject."); } } _buildCancelled = false; _buildCancelledInternally = false; _buildedProjects.Clear(); lock (_buildingProjectsLockObject) { _buildingProjects.Clear(); } _buildedSolution = null; _buildingSolution = new BuildedSolution(_packageContext.GetDTE().Solution); OnBuildBegin(this, EventArgs.Empty); _buildProcessCancellationToken = new CancellationTokenSource(); Task.Factory.StartNew(BuildEvents_BuildInProcess, _buildProcessCancellationToken.Token, _buildProcessCancellationToken.Token); }
private void buildRuleset(BuildState state, p_Ruleset ruleset) { foreach (var pRule in ruleset.Rules) { buildRule(state, pRule); } }
void CheckVs2015() { Echo("Checking for Visual Studio 2015"); string key = @"SOFTWARE\Microsoft\VisualStudio\14.0"; if (Environment.Is64BitOperatingSystem) key = @"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0"; using (var xKey = Registry.LocalMachine.OpenSubKey(key)) { string xDir = (string) xKey.GetValue("InstallDir"); if (String.IsNullOrWhiteSpace(xDir)) { mExceptionList.Add("Visual Studio 2015 not detected!"); mBuildState = BuildState.PrerequisiteMissing; } } }
public void UpdateStatus(BuildState state, DateTimeOffset timeStamp) { Log.Information("=> DelcomDevice.UpdateStatus"); Log.Information("New state is '{0}'", state); if (profile.HasRestrictedHours) { var currentTime = DateTime.Now; if (currentTime.Hour < profile.StartTime || currentTime.Hour > profile.EndTime) { Log.Information("Outside restricted hours"); lock (PhysicalDevice) { if (PhysicalDevice.IsOpen) { Log.Information("Turning off device"); PhysicalDevice.Close(); } else Log.Information("Ignoring update"); return; } } } lock (PhysicalDevice) { if (!PhysicalDevice.IsOpen) { Log.Information("Turning on device"); PhysicalDevice.Open(); } } Log.Information("Finding profile for state '{0}'", state); var profileState = profile.States.SingleOrDefault(p => p.BuildState == state); if (profileState == null) { Log.Warning("No profile found for state '{0}'", state); PhysicalDevice.Flash(Color.Red); return; } if (profileState.Buzzer && lastCompletedState != state) { // TODO: Make actual buzzer sound configurable Log.Information("Sounding buzzer"); PhysicalDevice.StartBuzzer(100, 2, 20, 20); } switch (state) { case BuildState.Unknown: SetColorBasedOnProfile(profileState, Color.Green, timeStamp); SetColorBasedOnProfile(profileState, Color.Yellow, timeStamp); SetColorBasedOnProfile(profileState, Color.Red, timeStamp); break; case BuildState.Succeeded: SetColorBasedOnProfile(profileState, Color.Green, timeStamp); SetColorBasedOnProfile(profileState, Color.Yellow, timeStamp); SetColorBasedOnProfile(profileState, Color.Red, timeStamp); Log.Information("Setting last completed state to '{0}'", state); lastCompletedState = state; break; case BuildState.Error: case BuildState.Failed: SetColorBasedOnProfile(profileState, Color.Green, timeStamp); SetColorBasedOnProfile(profileState, Color.Yellow, timeStamp); SetColorBasedOnProfile(profileState, Color.Red, timeStamp); Log.Information("Setting last completed state to '{0}'", state); lastCompletedState = state; break; case BuildState.Running: SetColorBasedOnProfile(profileState, Color.Green, timeStamp); SetColorBasedOnProfile(profileState, Color.Yellow, timeStamp); SetColorBasedOnProfile(profileState, Color.Red, timeStamp); break; } lastCompletedState = state != BuildState.Running ? state : lastCompletedState; Log.Information("Setting last update time to '{0}'", timeStamp); lastUpdateTime = timeStamp; }
public static BuildProject Create(BuildState status, string name, string url, string[] breakers, string fixer, DateTime lastBuildTime) { return new BuildProject {BuildStatus = status, Name = name, Url = url, Breakers = breakers, Fixer = fixer, LastBuildTime = lastBuildTime }; }
bool BuildActual (string built_targets_key, out bool executeOnErrors) { bool result = false; executeOnErrors = false; // built targets are keyed by the particular set of global // properties. So, a different set could allow a target // to run again built_targets_key = project.GetKeyForTarget (Name); if (project.ParentEngine.BuiltTargetsOutputByName.ContainsKey (built_targets_key)) { LogTargetSkipped (); return true; } // Push a null/empty batch, effectively clearing it project.PushBatch (null, null); if (!ConditionParser.ParseAndEvaluate (Condition, Project)) { LogMessage (MessageImportance.Low, "Target {0} skipped due to false condition: {1}", Name, Condition); project.PopBatch (); return true; } try { buildState = BuildState.Started; #if NET_4_0 result = BuildDependencies (out executeOnErrors) && BuildBeforeThisTargets (out executeOnErrors) && DoBuild (out executeOnErrors) && // deps & Before targets built fine, do main build BuildAfterThisTargets (out executeOnErrors); #else result = BuildDependencies (out executeOnErrors) && DoBuild (out executeOnErrors); #endif buildState = BuildState.Finished; } catch (Exception e) { LogError ("Error building target {0}: {1}", Name, e.ToString ()); return false; } finally { project.PopBatch (); } ITaskItem[] outputs = (ITaskItem[]) OutputsAsITaskItems.Clone (); foreach (ITaskItem item in outputs) { item.SetMetadata ("MSBuildProjectFile", TargetFile); item.SetMetadata ("MSBuildTargetName", Name); } project.ParentEngine.BuiltTargetsOutputByName [built_targets_key] = outputs; return result; }
/// <summary> /// The method that actually damages the building. /// </summary> /// <param name="damage"></param> /// <returns>Returns true if the building was damaged or false if the building could not be damaged</returns> public override bool Damage(int damage) { if (buildState == BuildState.Constructed) { currentHP = Math.Max(currentHP - damage, 0); if (currentHP == 0) { buildState = BuildState.Destroying; return false; } return true; } else { return false; } }
public void SetBuildState(BuildState __buildState) { _buildState = __buildState; }
public void Tick() { // Pick a free queue var queue = ai.FindQueues( category ).FirstOrDefault(); if (queue == null) return; var currentBuilding = queue.CurrentItem(); switch (state) { case BuildState.ChooseItem: { var item = chooseItem(queue); if (item == null) { state = BuildState.WaitForFeedback; lastThinkTick = ai.ticks; } else { HackyAI.BotDebug("AI: Starting production of {0}".F(item.Name)); state = BuildState.WaitForProduction; ai.world.IssueOrder(Order.StartProduction(queue.self, item.Name, 1)); } } break; case BuildState.WaitForProduction: if (currentBuilding == null) return; /* let it happen.. */ else if (currentBuilding.Paused) ai.world.IssueOrder(Order.PauseProduction(queue.self, currentBuilding.Item, false)); else if (currentBuilding.Done) { state = BuildState.WaitForFeedback; lastThinkTick = ai.ticks; /* place the building */ BuildingType type = BuildingType.Building; if(Rules.Info[currentBuilding.Item].Traits.Contains<AttackBaseInfo>()) type = BuildingType.Defense; else if(Rules.Info[currentBuilding.Item].Traits.Contains<OreRefineryInfo>()) type = BuildingType.Refinery; var location = ai.ChooseBuildLocation(currentBuilding.Item, type); if (location == null) { HackyAI.BotDebug("AI: Nowhere to place {0}".F(currentBuilding.Item)); ai.world.IssueOrder(Order.CancelProduction(queue.self, currentBuilding.Item, 1)); } else { ai.world.IssueOrder(new Order("PlaceBuilding", ai.p.PlayerActor, false) { TargetLocation = location.Value, TargetString = currentBuilding.Item }); } } break; case BuildState.WaitForFeedback: if (ai.ticks - lastThinkTick > HackyAI.feedbackTime) state = BuildState.ChooseItem; break; } }
public Task Start(BuildState state, BuildStatus status) { var tcs = new TaskCompletionSource<byte>(); TrackableWaveChannel stream = null; WasapiOut device = null; try { var fileName = ""; switch (status) { case BuildStatus.Broken: fileName = configuration.Broken; break; case BuildStatus.StillBroken: fileName = configuration.StillBroken; break; case BuildStatus.Fixed: fileName = configuration.Fixed; break; default: throw new ArgumentOutOfRangeException("status"); } if (File.Exists(fileName)) { device = new WasapiOut(AudioClientShareMode.Shared, 100); stream = new TrackableWaveChannel(BuildStream(fileName)); device.Init(stream); device.Play(); stream.Finished += (sender, args) => { tcs.SetResult(0); stream.Dispose(); device.Dispose(); stream = null; device = null; }; } else { var task = tcs.Task; tcs.SetResult(0); return task; } } catch (Exception e) { tcs.SetException(e); if (stream != null) { stream.Dispose(); stream = null; } if (device != null) { device.Dispose(); device = null; } } return tcs.Task; }
/// <summary> /// PUSH the Build to the Gitlab CI Coordinator /// </summary> /// <param name="id">Build ID</param> /// <param name="state">State</param> /// <param name="sTrace">Command output</param> /// <returns></returns> public static bool PushBuild(int id, BuildState state, string sTrace) { Console.WriteLine("[" + DateTime.Now + "] Submitting build " + id + " to coordinator ..."); var body = new StringBuilder(); body.Append("token=").Append(Uri.EscapeDataString(Config.AuthToken)); body.Append("&state="); switch (state) { case BuildState.Queued: body.Append("waiting"); break; case BuildState.Running: body.Append("running"); break; case BuildState.Failed: body.Append("failed"); break; case BuildState.Success: body.Append("success"); break; default: throw new ArgumentOutOfRangeException("state"); } body.Append("&trace="); foreach (string t in sTrace.Split('\n')) body.Append(Uri.EscapeDataString(t)).Append("\n"); HttpStatusCode status; var response = WebAPI.PUT(APIEndpoint + "/builds/" + id + ".json", body.ToString(), out status); return response != null; }
public void Handle(BuildState state) { _orderedHandlers.First(h => h.CanHandle(state)).Handle(state); }