/// <summary>
        /// Mark a verb as completed, and adjust our schedule accordingly.
        /// </summary>
        /// <param name="verb">The verb that completed.</param>
        /// <param name="disp">The disposition of the verb's execution.</param>
        private void verbIsComplete(IVerb verb, Disposition disp)
        {
            ////Say(string.Format("  {0} is complete: {1}", verb, dbgDisposition));
            ////if (disp is Failed)
            ////{
            ////    // Failures can be hard to debug, since they don't leave any
            ////    // output in nuobj/. So report these even if they aren't
            ////    // built this run.
            ////    emitRealtimeReport(verb, disp);
            ////}

            // Invariant: all of this verb's objs are non-Stale.
            foreach (BuildObject obj in verb.getOutputs())
            {
                ////Say(string.Format("  waking {0}", obj));
                IEnumerable <IVerb> wokenSet = this.waitIndex.awaken(obj);
                ////foreach (IVerb wokenVerb in wokenSet)
                ////{
                ////    //Say(string.Format("  {0} woken", wokenVerb));
                ////}
                this.nextVerbs.UnionWith(wokenSet);
            }

            this.emitRealtimeReport(verb, disp);

            this.requiredVerbs.Remove(verb);
            this.completedVerbs.Add(verb);
        }
        static public ResultSummaryRecord readXml(XmlReader xr)
        {
            Util.Assert(xr.Name.Equals(_xml_tag));

            bool isVerificationTimeout = false;

            Boolean.TryParse(
                xr.GetAttribute(_IsVerificationTimeout_attr), out isVerificationTimeout);

            xr.ReadToFollowing(Disposition._xml_tag);
            Disposition d = Disposition.readXml(xr);

            List <BuildObjectValuePointer> lbovp = new List <BuildObjectValuePointer>();

            while (xr.Read())
            {
                if (xr.NodeType == XmlNodeType.EndElement)
                {
                    Util.Assert(xr.Name.Equals(_xml_tag));
                    break;
                }
                else if (xr.NodeType == XmlNodeType.Element)
                {
                    if (xr.Name.Equals(BuildObjectValuePointer._xml_tag))
                    {
                        lbovp.Add(BuildObjectValuePointer.readXml(xr));
                    }
                    else
                    {
                        throw new Exception("Unknown xml tag " + xr.Name);
                    }
                }
            }
            return(new ResultSummaryRecord(d, lbovp, isVerificationTimeout));
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the ResultSummaryRecord class.
 /// </summary>
 /// <param name="verb">
 /// The verb whose execution this is the result of.
 /// </param>
 /// <param name="disposition">
 /// The disposition of the verb execution.
 /// </param>
 /// <param name="outputs">
 /// The build objects that were produced by this verb execution.
 /// </param>
 internal ResultSummaryRecord(
     IVerb verb,
     Disposition disposition,
     IEnumerable <BuildObjectValuePointer> outputs)
     : this(verb, disposition, outputs, false)
 {
 }
        public override Presentation getRealtimePresentation(Disposition d)
        {
            if (d is Failed)
            {
                return base.getRealtimePresentation(d);
            }

            VerificationResult vr = VerificationResult.fromXmlFile(this.getOutputFile());
            PresentationBuilder pr = new PresentationBuilder();
            pr.startLine();
            pr.color(
                vr.pass ? Presentation.GREEN : Presentation.RED,
                string.Format(
                    "{0} {1} {2,5:0.0}s",
                    ////getSource().getRelativePath(),
                this.getAbstractIdentifier(),
                    vr.pass ? "Success" : "Fail",
                    vr.cpuTime));
            pr.endLine();
            if (!vr.pass)
            {
                foreach (VerificationMessage msg in vr.getMessages())
                {
                    pr.pre(msg.Message);
                }
            }

            return pr.fix();
        }
 /// <summary>
 /// Initializes a new instance of the ResultSummaryRecord class.
 /// </summary>
 /// <param name="verb">
 /// The verb whose execution this is the result of.
 /// </param>
 /// <param name="disposition">
 /// The disposition of the verb execution.
 /// </param>
 /// <param name="outputs">
 /// The build objects that were produced by this verb execution.
 /// </param>
 internal ResultSummaryRecord(
     IVerb verb,
     Disposition disposition,
     IEnumerable<BuildObjectValuePointer> outputs)
     : this(verb, disposition, outputs, false)
 {
 }
 public ResultSummaryRecord(
     Disposition disposition,
     IEnumerable <BuildObjectValuePointer> outputs,
     bool isVerificationTimeout)
 {
     Init(null, disposition, outputs, isVerificationTimeout);
 }
 /// <summary>
 /// Initializes a new instance of the ResultSummaryRecord class.
 /// </summary>
 /// <param name="disposition">
 /// The disposition of the verb execution.
 /// </param>
 /// <param name="outputs">
 /// The build objects that were produced by this verb execution.
 /// </param>
 /// <param name="isVerificationTimeout">
 /// Whether this result is a verification timeout.
 /// </param>
 internal ResultSummaryRecord(
     Disposition disposition,
     IEnumerable<BuildObjectValuePointer> outputs,
     bool isVerificationTimeout)
     : this(null, disposition, outputs, isVerificationTimeout)
 {
 }
Exemple #8
0
        void verbIsComplete(IVerb verb, Disposition disp, BlessingRequest blessingRequest)
        {
            emitRealtimeReport(verb, disp);

            //-Say(String.Format("  {0} is complete: {1}", verb, dbgDisposition));
            //-if (disp is Failed)
            //-{
            //-
            //-
            //-
            //-    emitRealtimeReport(verb, disp);
            //-}

            //- invariant: all of this verb's objs are non-Stale.
            foreach (BuildObject obj in verb.getOutputs())
            {
                if (blessingRequest == BlessingRequest.Bless)
                {
                    nuObjContents.blessGeneral(obj, disp);
                }
                //-Say(String.Format("  waking {0}", obj));
                IEnumerable <IVerb> wokenSet = waitIndex.awaken(obj);
                //-foreach (IVerb wokenVerb in wokenSet)
                //-{
                //-
                //-}
                nextVerbs.UnionWith(wokenSet);
            }
            requiredVerbs.Remove(verb);
            completedVerbs.Add(verb);
        }
Exemple #9
0
        public override Presentation getRealtimePresentation(Disposition d)
        {
            if (d is Failed)
            {
                return(base.getRealtimePresentation(d));
            }
            VerificationResult  vr = VerificationResult.fromXmlFile(getOutputFile().getFilesystemPath());
            PresentationBuilder pr = new PresentationBuilder();

            pr.startLine();
            pr.color(
                vr.pass ? Presentation.GREEN : Presentation.RED,
                String.Format("{0} {1} {2,5:0.0}s",
                              //-getSource().getRelativePath(),
                              this.getAbstractIdentifier(),
                              (vr.pass ? "Success" : "Fail"), vr.cpuTime));
            pr.endLine();
            if (!vr.pass)
            {
                foreach (VerificationMessage msg in vr.getMessages())
                {
                    pr.pre(msg.message);
                }
            }
            return(pr.fix());
        }
Exemple #10
0
        /// <summary>
        /// Reads a build object from the local filesystem and stores it in the
        /// cache.
        /// </summary>
        /// <param name="workingDirectory">
        /// Private directory for verb execution.
        /// </param>
        /// <param name="obj">The build object to store in the cache.</param>
        /// <param name="disposition">
        /// Disposition of verb which created this object (if known).
        /// </param>
        /// <returns>A BuildObjectValuePointer describing the object.</returns>
        public BuildObjectValuePointer Store(WorkingDirectory workingDirectory, BuildObject obj, Disposition disposition)
        {
            string contentHash = Util.hashFilesystemPath(workingDirectory.PathTo(obj));
            this.itemCache.StoreItemFromFile(ItemCacheContainer.Objects, contentHash, workingDirectory.PathTo(obj));
            this.Add(obj, disposition, contentHash, null);

            return new BuildObjectValuePointer(contentHash, obj.getRelativePath());
        }
        /// <summary>
        /// Logs output regarding a verb's execution disposition.
        /// </summary>
        /// <param name="verb">The verb in question.</param>
        /// <param name="disposition">Disposition of the verb execution.</param>
        private void emitRealtimeReport(IVerb verb, Disposition disposition)
        {
            Presentation     pr    = verb.getRealtimePresentation(disposition);
            ASCIIPresentater ascii = new ASCIIPresentater();

            pr.format(ascii);
            Logger.Write(ascii.ToString());
        }
        public override Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
        {
            if (!(disposition is Failed))
            {
                File.WriteAllText(workingDirectory.PathTo(this.getOutputFile()), stdout);
            }

            return disposition;
        }
Exemple #13
0
        /// <summary>
        /// Completes a task (verb run).
        /// </summary>
        /// <remarks>
        /// Note that for Async verb workers, this method runs on a separate thread.
        /// </remarks>
        /// <param name="verb">The verb which was run.</param>
        /// <param name="worker">The verb's worker.</param>
        private void completeTask(IVerb verb, IVerbWorker worker)
        {
            this.taskCompletionsLock.AcquireWriterLock(Timeout.Infinite);
            Disposition    disp = worker.Complete();
            TaskCompletion tc   = new TaskCompletion(worker.GetWorkingDirectory(), verb, disp);

            this.taskCompletions.Add(tc);
            this.completionEvent.Set();
            this.taskCompletionsLock.ReleaseWriterLock();
        }
Exemple #14
0
        void completeTask(IVerb verb, IVerbWorker worker)
        {
            taskCompletionsLock.AcquireWriterLock(Timeout.Infinite);
            Disposition    disp = worker.complete();
            TaskCompletion tc   = new TaskCompletion(verb, disp);

            taskCompletions.Add(tc);
            completionEvent.Set();
            taskCompletionsLock.ReleaseWriterLock();
        }
Exemple #15
0
        void blessInternal(BuildObject obj, string hashIfKnown, Disposition disp, VirtualContents contents)
        {
            Util.Assert(!theCache.ContainsKey(obj));    //- I don't think we should ever write the same file twice in one run.
            string hash = hashIfKnown;

            if (hash == null && disp is Fresh && !(obj is VirtualBuildObject))
            {
                hash = _hasher.hash(obj.getFilesystemPath());
            }
            theCache[obj] = new NuObjValue(hash, disp, contents);
        }
Exemple #16
0
        private void processTaskCompletions(List <AsyncRunner.TaskCompletion> taskCompletions)
        {
            foreach (AsyncRunner.TaskCompletion tc in taskCompletions)
            {
                //- We may record a Failure if the verb didn't output
                //- everything it promised to.
                Disposition recordedDisposition = recordResult(tc.verb, tc.disposition);

                Say(String.Format("  {0} completed with disposition {1}", tc.verb, tc.disposition));
            }
            //- Waking process may have shaken some verbs loose for us to evaluate next time around.
        }
        public ResultSummaryRecord(
            IVerb verb,
            Disposition disposition,
            IEnumerable <BuildObjectValuePointer> outputs)
        {
            bool isVerificationTimeout = false;

            if (verb != null && verb is IRejectable)
            {
                isVerificationTimeout = ((IRejectable)verb).resultWasVerificationTimeout();
            }
            Init(verb, disposition, outputs, isVerificationTimeout);
        }
        private void Init(
            IVerb verb,
            Disposition disposition,
            IEnumerable <BuildObjectValuePointer> outputs,
            bool isVerificationTimeout)

        {
            this._verb                  = verb;
            this._disposition           = disposition;
            this._outputs               = new List <BuildObjectValuePointer>(outputs);
            this._isVerificationTimeout = isVerificationTimeout;
            if (_verb is IRejectable)
            {
                _isVerificationTimeout = ((IRejectable)_verb).resultWasVerificationTimeout();
            }
        }
Exemple #19
0
        /// <summary>
        /// Initializes a new instance of the ResultSummaryRecord class.
        /// </summary>
        /// <param name="verb">
        /// The verb whose execution this is the result of.
        /// </param>
        /// <param name="disposition">
        /// The disposition of the verb execution.
        /// </param>
        /// <param name="outputs">
        /// The build objects that were produced by this verb execution.
        /// </param>
        /// <param name="isRejectableFailure">
        /// Whether this result is a rejectable failure.
        /// </param>
        internal ResultSummaryRecord(
            IVerb verb,
            Disposition disposition,
            IEnumerable <BuildObjectValuePointer> outputs,
            bool isRejectableFailure)
        {
            this.verb                = verb;
            this.disposition         = disposition;
            this.outputs             = new List <BuildObjectValuePointer>(outputs);
            this.isRejectableFailure = isRejectableFailure;

            IRejectable rejectableVerb = verb as IRejectable;

            if (rejectableVerb != null)
            {
                this.isRejectableFailure = rejectableVerb.resultWasRejectableFailure();
            }
        }
Exemple #20
0
        //- Called by tool when we want a short (one-line)
        //- summary for showing in-progress results.
        public virtual Presentation getRealtimePresentation(Disposition d)
        {
            PresentationBuilder pr = new PresentationBuilder();

            pr.startLine();
            pr.color(
                d is Fresh ? Presentation.GREEN : Presentation.RED,
                ToString() + " " + d.ToString());
            pr.endLine();
            if (d is Failed)
            {
                //- This isn't a verification failure, a tool itself broke.
                //- Provide that report.
                foreach (string m in d.getMessages())
                {
                    pr.pre(Presentation.abbreviateLines(m));
                }
            }
            return(pr.fix());
        }
        /// <summary>
        /// Add information about an object to the Repository.
        /// </summary>
        /// <param name="obj">The object to add.</param>
        /// <param name="disposition">
        /// Disposition of the verb which created this object.
        /// </param>
        /// <param name="hash">Hash of the object's contents.</param>
        /// <param name="contents">Contents of the object (if virtual).</param>
        private void Add(BuildObject obj, Disposition disposition, string hash, VirtualContents contents)
        {
            // Every object in the repository should either have a hash value
            // or virtual contents, but not both.
            Util.Assert((string.IsNullOrEmpty(hash) && contents != null) ||
                        (!string.IsNullOrEmpty(hash) && (contents == null)));

            // Check to see if the object is already in this repository.
            if (this.entries.ContainsKey(obj))
            {
                // We shouldn't be adding conflicting information for
                // the same object during the same build run.
                RepositoryEntry entry = this.entries[obj];
                Util.Assert(entry.Disposition.GetType() == disposition.GetType());
                Util.Assert(entry.Hash.Equals(hash, StringComparison.Ordinal));
                Util.Assert(entry.VirtualContents == contents);

                // Don't replace existing entry with equivalent.
                return;
            }

            this.entries[obj] = new RepositoryEntry(disposition, hash, contents);
        }
Exemple #22
0
 public void blessGeneral(BuildObject obj, Disposition disp)
 {
     if (obj is VirtualBuildObject)
     {
         if (disp is Fresh)
         {
             //- The object is fresh, so the verb ran its Execute
             //- method and squirted the results into theCache;
             //- this call is from the scheduler cleaning up,
             //- and we can ignore it.
             Util.Assert(theCache.ContainsKey(obj));
             Util.Assert(theCache[obj].disp is Fresh);
         }
         else
         {
             Util.Assert(disp is Failed);
             storeVirtual(obj, disp, null);
         }
     }
     else
     {
         bless(obj, null, disp);
     }
 }
 public override Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
 {
     // No cleanup to do.
     return(disposition);
 }
Exemple #24
0
        /// <summary>
        /// Add information about an object to the Repository.
        /// </summary>
        /// <param name="obj">The object to add.</param>
        /// <param name="disposition">
        /// Disposition of the verb which created this object.
        /// </param>
        /// <param name="hash">Hash of the object's contents.</param>
        /// <param name="contents">Contents of the object (if virtual).</param>
        private void Add(BuildObject obj, Disposition disposition, string hash, VirtualContents contents)
        {
            // Every object in the repository should either have a hash value
            // or virtual contents, but not both.
            Util.Assert((string.IsNullOrEmpty(hash) && contents != null) ||
                (!string.IsNullOrEmpty(hash) && (contents == null)));

            // Check to see if the object is already in this repository.
            if (this.entries.ContainsKey(obj))
            {
                // We shouldn't be adding conflicting information for
                // the same object during the same build run.
                RepositoryEntry entry = this.entries[obj];
                Util.Assert(entry.Disposition.GetType() == disposition.GetType());
                Util.Assert(entry.Hash.Equals(hash, StringComparison.Ordinal));
                Util.Assert(entry.VirtualContents == contents);

                // Don't replace existing entry with equivalent.
                return;
            }

            this.entries[obj] = new RepositoryEntry(disposition, hash, contents);
        }
Exemple #25
0
 /// <summary>
 /// Logs output regarding a verb's execution disposition.
 /// </summary>
 /// <param name="verb">The verb in question.</param>
 /// <param name="disposition">Disposition of the verb execution.</param>
 private void emitRealtimeReport(IVerb verb, Disposition disposition)
 {
     Presentation pr = verb.getRealtimePresentation(disposition);
     ASCIIPresentater ascii = new ASCIIPresentater();
     pr.format(ascii);
     Logger.Write(ascii.ToString());
 }
Exemple #26
0
 public virtual Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
 {
     return disposition;
 }
        public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
        {
            if (disposition is Failed)
            {
                return disposition;
            }

            HashSet<string> createdFiles = new HashSet<string>(Directory.GetFiles(workingDirectory.PathTo(this.getAbsDestPath())).Select(path => Path.GetFileName(path)));
            HashSet<string> expectedFiles = new HashSet<string>(this.getOutputs().Select(obj => obj.getFileName()));

            // DafnyCC/DafnySpec process a big batch of files together. Did we correctly understand what it did?
            if (!createdFiles.SetEquals(expectedFiles))
            {
                // REVIEW: These are never used by anything.  Remove?
                bool dummy = createdFiles.SetEquals(expectedFiles);
                int missing = expectedFiles.Except(createdFiles).Count();
                int extra = createdFiles.Except(expectedFiles).Count();

                string msg = "Missing files: " + string.Join(",", expectedFiles.Except(createdFiles)) + "\n" +
                    "  Extra files: " + string.Join(",", createdFiles.Except(expectedFiles));
                return new Failed(msg);
            }

            // Propagate the NuBuild annotations.
            foreach (InOutMapping mapping in this.getInOutMappings())
            {
                if (mapping.dfysource != null
                    && this.transformFilterAccepts(mapping.dfysource))
                {
                    AnnotationScanner.transferAnnotations(
                        workingDirectory, mapping.dfysource, mapping.basmIfc, BoogieAsmDepBase.CommentSymbol);
                    AnnotationScanner.transferAnnotations(
                        workingDirectory, mapping.dfysource, mapping.basmImp, BoogieAsmDepBase.CommentSymbol);
                }
            }

            return new Fresh();
        }
Exemple #28
0
        /// <summary>
        /// Mark a verb as completed, and adjust our schedule accordingly.
        /// </summary>
        /// <param name="verb">The verb that completed.</param>
        /// <param name="disp">The disposition of the verb's execution.</param>
        private void verbIsComplete(IVerb verb, Disposition disp)
        {
            ////Say(string.Format("  {0} is complete: {1}", verb, dbgDisposition));
            ////if (disp is Failed)
            ////{
            ////    // Failures can be hard to debug, since they don't leave any
            ////    // output in nuobj/. So report these even if they aren't
            ////    // built this run.
            ////    emitRealtimeReport(verb, disp);
            ////}

            // Invariant: all of this verb's objs are non-Stale.
            foreach (BuildObject obj in verb.getOutputs())
            {
                ////Say(string.Format("  waking {0}", obj));
                IEnumerable<IVerb> wokenSet = this.waitIndex.awaken(obj);
                ////foreach (IVerb wokenVerb in wokenSet)
                ////{
                ////    //Say(string.Format("  {0} woken", wokenVerb));
                ////}
                this.nextVerbs.UnionWith(wokenSet);
            }

            this.emitRealtimeReport(verb, disp);

            this.requiredVerbs.Remove(verb);
            this.completedVerbs.Add(verb);
        }
        /// <summary>
        /// Adds the output objects from a cached verb execution to the
        /// repository, and ensures they are present in the item cache.
        /// </summary>
        /// <param name="verb">The verb whose outputs to add.</param>
        /// <param name="resultRecord">
        /// The result summary record of the verb execution.
        /// </param>
        /// <remarks>
        /// Call only when output objects are known to be cached
        /// (i.e. because FetchResult returned non-Stale).
        /// REVIEW: This function probably shouldn't be in this file.
        /// It does something similar for cached verb results that
        /// the scheduler's recordResult method does for new verb
        /// executions.  Move this there and/or refactor?
        /// </remarks>
        public void AddVerbResults(IVerb verb, ResultSummaryRecord resultRecord)
        {
            if (this.alreadyAddedVerbs.Contains(verb))
            {
                // We only need to add a cached verb execution's outputs once.
                return;
            }

            Disposition disposition = resultRecord.Disposition;

            // REVIEW: In the below, some of these IEnumerables should be
            // HashSets, and the HashSet should be a simple List.

            // Create a collection of the potential outputs.
            IEnumerable <BuildObject> outputs        = verb.getOutputs();
            IEnumerable <BuildObject> failureOutputs = verb.getFailureOutputs();

            outputs = outputs.Concat(failureOutputs);
            Dictionary <string, BuildObject> potentialOutputs = new Dictionary <string, BuildObject>();

            foreach (BuildObject obj in outputs)
            {
                potentialOutputs.Add(obj.getRelativePath(), obj);
            }

            // Compare the actual outputs with the potential outputs,
            // and add the actual ones to the repository.
            HashSet <BuildObject> recorded = new HashSet <BuildObject>();

            foreach (BuildObjectValuePointer actualOutput in resultRecord.Outputs)
            {
                if (potentialOutputs.ContainsKey(actualOutput.RelativePath))
                {
                    BuildObject obj = potentialOutputs[actualOutput.RelativePath];
                    // TODO: Verify that the object exists in the item cache!
                    this.AddObject(obj, disposition, actualOutput.ObjectHash);
                    recorded.Add(obj);

                    // Store a copy of this verb output as a file in the real nuobj directory.
                    Util.Assert(actualOutput.RelativePath.StartsWith(BuildEngine.theEngine.getObjRoot(), StringComparison.Ordinal));
                    this.itemCache.FetchItemToFile(ItemCacheContainer.Objects, actualOutput.ObjectHash, IronRootDirectory.PathTo(actualOutput.RelativePath));
                }
                else
                {
                    // Complain if we find interloping outputs.
                    throw new Exception("Distressing: some actual verb outputs aren't in the verb's list of potential outputs");
                }
            }

            // Create a collection of missing outputs.
            IEnumerable <BuildObject> unrecorded = outputs.Except(recorded).Except(failureOutputs);

            // For non-Failed verb runs, complain if all expected outputs don't
            // show up in the actual outputs.
            Util.Assert(unrecorded.Count() == 0 || disposition is Failed);

            // For cached verb runs with permanent failures (i.e. disposition
            // is Failed), we want to mark all of the expected outputs as Failed
            // even if no corresponding actual output was produced during the
            // failed verb run.
            foreach (BuildObject obj in unrecorded)
            {
                this.AddObject(obj, disposition, null);
            }

            // Remember that we've already added this verb's outputs.
            this.alreadyAddedVerbs.Add(verb);
        }
Exemple #30
0
 /// <summary>
 /// Initializes a new instance of the TaskCompletion class.
 /// </summary>
 /// <param name="workingDirectory">
 /// The private working directory the task executed in.
 /// </param>
 /// <param name="verb">
 /// The verb whose completion this instance describes.
 /// </param>
 /// <param name="disposition">
 /// The disposition of this task.
 /// </param>
 public TaskCompletion(WorkingDirectory workingDirectory, IVerb verb, Disposition disposition)
 {
     this.workingDirectory = workingDirectory;
     this.verb = verb;
     this.disposition = disposition;
 }
Exemple #31
0
        public virtual Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
        {
            if (!(disposition is Failed))
            {
                // Check that the executable isn't too large.
                long exeSize = new FileInfo(workingDirectory.PathTo(this.outputObject)).Length;

                if (exeSize > this.maxExeSize)
                {
                    return new Failed("Executable too big");
                }
            }

            return disposition;
        }
 /// <summary>
 /// Add information about a virtual object to the Repository,
 /// including its contents.
 /// </summary>
 /// <param name="obj">The object in question.</param>
 /// <param name="disposition">
 /// Disposition of the verb which created this object.
 /// </param>
 /// <param name="contents">Contents of the object.</param>
 public void StoreVirtual(BuildObject obj, Disposition disposition, VirtualContents contents)
 {
     Util.Assert(obj is VirtualBuildObject);
     this.Add(obj, disposition, null, contents);
 }
        public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
        {
            var dis = disposition;

            string cSharpPath = Path.ChangeExtension(workingDirectory.PathTo(this.expandedSource), CSharpExt);
            if (!File.Exists(cSharpPath))
            {
                // Dafny has a bug where compilation fails but result code is still 0.
                dis = new Failed();
            }

            if (dis is Fresh)
            {
                this.RewriteCSharpFile(cSharpPath, workingDirectory.PathTo(this.output));
            }

            return dis;
        }
Exemple #34
0
        //- Contract: call only when output objects are known to be cached
        //- (because fetchResult returned non-Stale).
        public void fetchOutputObjects(IVerb verb, IEnumerable <BuildObjectValuePointer> values, Disposition disp)
        {
            if (this.alreadyFetchedVerbs.Contains(verb))
            {
                return;
            }

            IEnumerable <BuildObject> objects     = verb.getOutputs();
            IEnumerable <BuildObject> failureObjs = verb.getFailureOutputs();

            objects = objects.Concat(failureObjs);
            Dictionary <string, BuildObject> objectDict = new Dictionary <string, BuildObject>();

            foreach (BuildObject obj in objects)
            {
                objectDict.Add(obj.getRelativePath(), obj);
            }

            HashSet <BuildObject> recorded = new HashSet <BuildObject>();

            foreach (BuildObjectValuePointer value in values)
            {
                if (objectDict.ContainsKey(value.relativePath))
                {
                    BuildObject obj = objectDict[value.relativePath];
                    obj.prepareObjDirectory();
                    this.fetchObject(value, obj);
                    nuObjectContents.bless(obj, value.objectHash, disp);
                    recorded.Add(obj);
                }
                else
                {
                    throw new Exception("Distressing: some BOVPs aren't in obj.getOutputs");
                }
            }

            IEnumerable <BuildObject> unrecorded = objects.Except(recorded).Except(failureObjs);

            Util.Assert(unrecorded.Count() == 0 || disp is Failed);
            foreach (BuildObject obj in unrecorded)
            {
                nuObjectContents.bless(obj, null, disp);
            }

            this.alreadyFetchedVerbs.Add(verb);
        }
Exemple #35
0
        void main(string[] cmdline_args)
        {
            string[] all_args = fetchConfigArgs().Concat(cmdline_args).ToArray();
            logNubuildInvocation(all_args);
            try
            {
                parseArgs(all_args);
            }
            catch (UserError err)
            {
                usage(err.Message);
            }

            BuildEngine.theEngine.ItemCache  = GetItemCache();
            BuildEngine.theEngine.Repository = new Repository(BuildEngine.theEngine.ItemCache);
            if (this.useCloudExecution)
            {
                if (!this.useCloudCache)
                {
                    usage("Cloud Execution requires Cloud Cache!");
                }

                BuildEngine.theEngine.CloudReportQueueName = Path.GetRandomFileName().Substring(0, 8);
                // BuildEngine.theEngine.CloudExecutionQueue = new CloudExecutionQueue(BuildEngine.theEngine.CloudReportQueueName);
                Logger.WriteLine("Using cloud report queue name: " + BuildEngine.theEngine.CloudReportQueueName);
            }

            Scheduler scheduler = new Scheduler(jobParallelism);

            scheduler.addTargetVerbs(verbs);

            ////try
            ////{
            scheduler.parallelSchedule();
            ////}
            ////catch (Exception ex)
            ////{
            ////    scheduler.dbgDisplayCounts();
            ////    throw;
            ////}

            IEnumerable <BuildObject> targets = scheduler.getTargets();

            BuildObject outputTarget = null;

            if (targets.Count() > 0)
            {
                outputTarget = targets.First();
            }
            else
            {
                Logger.WriteLine("No targets requested.");
            }

            if (targets.Count() > 1)
            {
                // TODO need a better story for relaying failure results. Right now
                // they get stuck in the results cache, but don't appear where we
                // can find them. Emit to a log, or to files in nuobj?
                Logger.WriteLine("Multiple targets build. First result follows.");
            }

            if (outputTarget != null)
            {
                Disposition d = scheduler.getObjectDisposition(outputTarget);
                if (d is Fresh)
                {
                    ASCIIPresentater ascii = new ASCIIPresentater();
                    IVerb            verb  = scheduler.getParent(outputTarget);
                    verb.getPresentation().format(ascii);
                    Logger.Write(ascii.ToString());

                    if (this.html_output != null)
                    {
                        HTMLPresentater html = new HTMLPresentater();
                        verb.getPresentation().format(html);

                        try
                        {
                            using (StreamWriter sw = new StreamWriter(this.html_output))
                            {
                                sw.Write(html.ToString());
                            }
                        }
                        catch (Exception e)
                        {
                            Logger.WriteLine("Failed to write html output to file: " + html_output);
                            Logger.WriteLine("Exception was: " + e);
                        }
                    }
                }
                else
                {
                    Logger.WriteLine("Build failed.");
                    foreach (string msg in d.getMessages())
                    {
                        Logger.Write(msg);
                    }
                }
            }
            else if (targets.Count() == 0)
            {
                Logger.WriteLine("No targets requested.");
            }
            else
            {
                Logger.WriteLine("Multiple targets built. Look for results in nuobj/.");
            }

            // -
            // We have to explicitly ask the BackgroundWorker thread to exit
            // as it will prevent the process from exiting until it does.
            // -
            this.backgroundWorker.StopWork();

            // -
            // Report what the background worker accomplished during this run.
            // -
            this.backgroundWorker.WaitForCompletion();
            Logger.WriteLine(string.Format("Background Worker completed {0} work items out of {1} queued.",
                                           this.backgroundWorker.GetWorkItemsPerformed,
                                           this.backgroundWorker.GetWorkItemsQueued));
            if (this.backgroundWorker.GetWorkItemsFailed != 0)
            {
                Logger.WriteLine(string.Format(
                                     "{0} work item procedures failed (threw an exception).",
                                     this.backgroundWorker.GetWorkItemsFailed));
            }
        }
Exemple #36
0
 /// <summary>
 /// Add information about an object to the Repository.
 /// The object path must be under the object root.
 /// </summary>
 /// <param name="obj">The object in question.</param>
 /// <param name="disposition">
 /// Disposition of the verb which created this object.
 /// </param>
 /// <param name="hash">Hash of the object's contents.</param>
 public void AddObject(BuildObject obj, Disposition disposition, string hash)
 {
     Util.Assert(obj.getRelativePath().StartsWith(BuildEngine.theEngine.getObjRoot(), StringComparison.Ordinal));
     this.Add(obj, disposition, hash, null);
 }
 /// <summary>
 /// Add information about an object to the Repository.
 /// The object path must be under the object root.
 /// </summary>
 /// <param name="obj">The object in question.</param>
 /// <param name="disposition">
 /// Disposition of the verb which created this object.
 /// </param>
 /// <param name="hash">Hash of the object's contents.</param>
 public void AddObject(BuildObject obj, Disposition disposition, string hash)
 {
     Util.Assert(obj.getRelativePath().StartsWith(BuildEngine.theEngine.getObjRoot(), StringComparison.Ordinal));
     this.Add(obj, disposition, hash, null);
 }
Exemple #38
0
 /// <summary>
 /// Add information about a virtual object to the Repository,
 /// including its contents.
 /// </summary>
 /// <param name="obj">The object in question.</param>
 /// <param name="disposition">
 /// Disposition of the verb which created this object.
 /// </param>
 /// <param name="contents">Contents of the object.</param>
 public void StoreVirtual(BuildObject obj, Disposition disposition, VirtualContents contents)
 {
     Util.Assert(obj is VirtualBuildObject);
     this.Add(obj, disposition, null, contents);
 }
Exemple #39
0
 public override Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
 {
     // No cleanup to do.
     return disposition;
 }
        /// <summary>
        /// Initializes a new instance of the ResultSummaryRecord class.
        /// </summary>
        /// <param name="verb">
        /// The verb whose execution this is the result of.
        /// </param>
        /// <param name="disposition">
        /// The disposition of the verb execution.
        /// </param>
        /// <param name="outputs">
        /// The build objects that were produced by this verb execution.
        /// </param>
        /// <param name="isRejectableFailure">
        /// Whether this result is a rejectable failure.
        /// </param>
        internal ResultSummaryRecord(
            IVerb verb,
            Disposition disposition,
            IEnumerable<BuildObjectValuePointer> outputs,
            bool isRejectableFailure)
        {
            this.verb = verb;
            this.disposition = disposition;
            this.outputs = new List<BuildObjectValuePointer>(outputs);
            this.isRejectableFailure = isRejectableFailure;

            IRejectable rejectableVerb = verb as IRejectable;
            if (rejectableVerb != null)
            {
                this.isRejectableFailure = rejectableVerb.resultWasRejectableFailure();
            }
        }
        public override Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
        {
            if (!(disposition is Failed))
            {
                File.WriteAllText(workingDirectory.PathTo(this.getOutputFile()), stdout);
            }

            return(disposition);
        }
Exemple #42
0
        // Called by tool when we want a short (one-line)
        // summary for showing in-progress results.
        public virtual Presentation getRealtimePresentation(Disposition d)
        {
            PresentationBuilder pr = new PresentationBuilder();
            pr.startLine();
            pr.color(
                d is Fresh ? Presentation.GREEN : Presentation.RED,
                this.ToString() + " " + d.ToString());
            pr.endLine();
            if (d is Failed)
            {
                // This isn't a verification failure, a tool itself broke.
                // Provide that report.
                foreach (string m in d.getMessages())
                {
                    pr.pre(Presentation.abbreviateLines(m));
                }
            }

            return pr.fix();
        }
 public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
 {
     VerificationResult vr = new VerificationResult(
         this.dfysource.getRelativePath(),
         cpuTimeSeconds,
         stdout,
         stderr,
         new VerificationResultDafnyParser());
     vr.addBasicPresentation();
     vr.toXmlFile(workingDirectory.PathTo(this.getOutputFile()));
     this.setWasRejectableFailure(!vr.pass);
     return disposition;
 }
Exemple #44
0
 public TaskCompletion(IVerb verb, Disposition disposition)
 {
     this.verb        = verb;
     this.disposition = disposition;
 }
Exemple #45
0
 public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
 {
     VerificationResult vr = new VerificationResult(
         bplInput.getRelativePath(),
         cpuTimeSeconds,
         stdout,
         stderr,
         new VerificationResultBoogieParser());
     vr.addBasicPresentation();
     vr.toXmlFile(workingDirectory.PathTo(getOutputFile()));
     setWasRejectableFailure(vr.wasOnlyTimeouts());
     return disposition;
 }
        public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
        {
            VerificationResult vr = new VerificationResult(
                this.dfysource.getRelativePath(),
                cpuTimeSeconds,
                stdout,
                stderr,
                new VerificationResultDafnyParser());

            vr.addBasicPresentation();
            vr.toXmlFile(workingDirectory.PathTo(this.getOutputFile()));
            this.setWasRejectableFailure(!vr.pass);
            return(disposition);
        }
 public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
 {
     postprocess(workingDirectory);
     return disposition;
 }
Exemple #48
0
        public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
        {
            if (disposition is Fresh)
            {
                BeatExtensions.propagatePrivateImports(workingDirectory, this.contextVerb, this.beatobj, this.outputFile());

                // And then propagate the NuBuild annotations, too.
                AnnotationScanner.transferAnnotations(
                    workingDirectory,
                    this.beatobj,
                    this.outputFile(),
                    BoogieAsmDepBase.CommentSymbol);
            }

            return(disposition);
        }
Exemple #49
0
 /// <summary>
 /// Initializes a new instance of the RepositoryEntry class.
 /// </summary>
 /// <param name="disposition">
 /// Disposition of the verb that created this object.
 /// </param>
 /// <param name="hash">Hash of the object's contents.</param>
 /// <param name="virtualContents">
 /// Computed value of the object (if virtual, null otherwise).
 /// </param>
 public RepositoryEntry(Disposition disposition, string hash, VirtualContents virtualContents)
 {
     this.hash = hash;
     this.disposition = disposition;
     this.virtualContents = virtualContents;
 }
 public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
 {
     return(disposition);
 }
 /// <summary>
 /// Initializes a new instance of the RepositoryEntry class.
 /// </summary>
 /// <param name="disposition">
 /// Disposition of the verb that created this object.
 /// </param>
 /// <param name="hash">Hash of the object's contents.</param>
 /// <param name="virtualContents">
 /// Computed value of the object (if virtual, null otherwise).
 /// </param>
 public RepositoryEntry(Disposition disposition, string hash, VirtualContents virtualContents)
 {
     this.hash            = hash;
     this.disposition     = disposition;
     this.virtualContents = virtualContents;
 }
Exemple #52
0
        public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
        {
            if (disposition is Fresh)
            {
                BeatExtensions.propagatePrivateImports(workingDirectory, this.contextVerb, this.beatobj, this.outputFile());

                // And then propagate the NuBuild annotations, too.
                AnnotationScanner.transferAnnotations(
                    workingDirectory,
                    this.beatobj,
                    this.outputFile(),
                    BoogieAsmDepBase.CommentSymbol);
            }

            return disposition;
        }
        /// <summary>
        /// Reads a build object from the local filesystem and stores it in the
        /// cache.
        /// </summary>
        /// <param name="workingDirectory">
        /// Private directory for verb execution.
        /// </param>
        /// <param name="obj">The build object to store in the cache.</param>
        /// <param name="disposition">
        /// Disposition of verb which created this object (if known).
        /// </param>
        /// <returns>A BuildObjectValuePointer describing the object.</returns>
        public BuildObjectValuePointer Store(WorkingDirectory workingDirectory, BuildObject obj, Disposition disposition)
        {
            string contentHash = Util.hashFilesystemPath(workingDirectory.PathTo(obj));

            this.itemCache.StoreItemFromFile(ItemCacheContainer.Objects, contentHash, workingDirectory.PathTo(obj));
            this.Add(obj, disposition, contentHash, null);

            return(new BuildObjectValuePointer(contentHash, obj.getRelativePath()));
        }