Ejemplo n.º 1
0
        private void Parse()
        {
            this.dependencies.Add(this.solutionFile);

            using (StreamReader stream = new StreamReader(IronRootDirectory.PathTo(this.solutionFile)))
            {
                Regex  regex = new Regex(@"Project\([\S]+\)[\s]+=[\s]+([^$]*)", RegexOptions.IgnoreCase);
                string line;

                while ((line = stream.ReadLine()) != null)
                {
                    MatchCollection matches = regex.Matches(line);

                    if (matches.Count > 0)
                    {
                        SourcePath projFile = this.solutionFile.getNewSourcePath(matches[0].Groups[1].Value.Split("\", ".ToCharArray())[5]);
                        ////Console.WriteLine(String.Format("Found project file {0}", projFile.getFilesystemPath()));
                        VSProjectParser proj = new VSProjectParser(projFile);
                        this.dependencies.AddRange(proj.getDependencies());
                        this.outputs.AddRange(proj.getOutputs());
                    }
                }

                stream.Close();
            }
        }
Ejemplo n.º 2
0
        public DafnyTransformBaseVerb(SourcePath dfyroot, string appLabel)
        {
            this.dfyroot  = dfyroot;
            this.appLabel = appLabel;

            IEnumerable <string> roots = getRoots().Select(obj => obj.ToString());
        }
Ejemplo n.º 3
0
        public BootableAppVerb(SourcePath dfyroot, DafnyCCVerb.FramePointerMode useFramePointer, VerificationRequest verificationRequest)
        {
            this.dfyroot             = dfyroot;
            this.verificationRequest = verificationRequest;
            string concreteId = verificationRequest.ToString() + "," + useFramePointer.ToString();

            this.abstractId = new AbstractId(this.GetType().Name, version, dfyroot.ToString(), concrete: concreteId);

            string targetDirectory = Path.Combine(
                BuildEngine.theEngine.getObjRoot(),
                dfyroot.getDirPath(),
                "bootable-" + verificationRequest.ToString());

            this.bootIniFile = new BuildObject(Path.Combine(targetDirectory, "safeos\\boot.ini"));

            // TODO: Create the bootloader verb.

            this.loaderVerb = new IroncladAppVerb(new SourcePath(LOADER_DFY), IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest);
            this.appVerb    = new IroncladAppVerb(dfyroot, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest);

            this.batchVerb = new BatchVerifyVerb(dfyroot, new HashSet <IObligationsProducer>()
            {
                this.appVerb, this.loaderVerb
            }, BatchVerifyVerb.BatchMode.APP);
            this.batchSummaryVerb = new VerificationResultSummaryVerb(this.batchVerb);

            this.loaderCopy        = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.loaderVerb)));
            this.bootloaderCopy    = new BuildObject(Path.Combine(targetDirectory, this.bootloader.getFileName()));
            this.appExecutableCopy = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.appVerb)));
        }
Ejemplo n.º 4
0
        public override IVerbWorker getWorker()
        {
            if (false)
            {
#pragma warning disable 162
                File.WriteAllText(getOutputFile().getFilesystemPath(), "Verification disabled temporarily for debugging");
                return new VerbSyncWorker(new Fresh());
#pragma warning restore 162
            }

            SourcePath boogieExecutable = new SourcePath("tools/Dafny/Boogie.exe", SourcePath.SourceType.sourceTypeTools);

            List<string> args = new List<string>();
            args.Add("/noinfer");
            args.Add("/typeEncoding:m");
            args.Add("/z3opt:ARITH_RANDOM_SEED=1");
            args.Add("/timeLimit:"+timeLimit);
            args.AddRange(getFlags());
            args.Add(bplInput.getRelativePath());

            return new ProcessInvokeAsyncWorker(this,
                    boogieExecutable.getRelativePath(),
                    args.ToArray(),
                    ProcessInvoker.RcHandling.NONZERO_RC_IS_OKAY,
                    getDiagnosticsBase());
        }
Ejemplo n.º 5
0
 public DafnyCCVerb(SourcePath dfyroot, string appLabel, FramePointerMode useFramePointer)
     : base(dfyroot, appLabel)
 {
     this.useFramePointer = useFramePointer;
     this.abstractId = new AbstractId(this.GetType().Name, this.getVersion() + version, dfyroot.ToString(), concrete: useFramePointer.ToString());
     this.dafnyCCBuildExecutableVerb = new VSSolutionVerb(new SourcePath("tools\\DafnyCC\\DafnyCC.sln", SourcePath.SourceType.Tools));
 }
Ejemplo n.º 6
0
        public BatchVerifyVerb(SourcePath batch_file, BatchMode mode, VerificationRequest verificationRequest, DafnyCCVerb.FramePointerMode useFramePointer)
        {
            this.mode = mode;

            this.producers = new HashSet<IObligationsProducer>();
            foreach (string line in File.ReadAllLines(batch_file.getFilesystemPath())) {
                if (line[0] == '#')
                {
                    continue;
                }
                SourcePath src = new SourcePath(line);
                switch (mode) {
                    case BatchMode.DAFNY:
                        if (verificationRequest.verifyMode != VerificationRequest.VerifyMode.Verify)
                        {
                            throw new UserError("BatchVerify DAFNY only supports full verification (but maybe we should add selective?)");
                        }
                        this.producers.Add(new DafnyVerifyTreeVerb(src));
                        break;
                    case BatchMode.APP:
                        this.producers.Add(new IroncladAppVerb(src, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest));
                        break;
                    default:
                        throw new Exception("Unknown batch file type");
                }
            }

            string parameters = mode.ToString() + "," + verificationRequest.ToString();
            outputObject = batch_file.makeLabeledOutputObject(parameters, BATCH_EXTN + VerificationObligationList.VOL_EXTN);
            abstractId = new AbstractId(this.GetType().Name, version, batch_file.ToString(), concrete:parameters);
        }
Ejemplo n.º 7
0
        public BootableAppVerb(SourcePath dfyroot, DafnyCCVerb.FramePointerMode useFramePointer, VerificationRequest verificationRequest)
        {
            this.dfyroot = dfyroot;
            this.verificationRequest = verificationRequest;
            string concreteId = verificationRequest.ToString() + "," + useFramePointer.ToString();
            this.abstractId = new AbstractId(this.GetType().Name, version, dfyroot.ToString(), concrete: concreteId);

            string targetDirectory = Path.Combine(
                BuildEngine.theEngine.getObjRoot(),
                dfyroot.getDirPath(),
                "bootable-" + verificationRequest.ToString());
            this.bootIniFile = new BuildObject(Path.Combine(targetDirectory, "safeos\\boot.ini"));

            // TODO: Create the bootloader verb.

            this.loaderVerb = new IroncladAppVerb(new SourcePath(LOADER_DFY), IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest);
            this.appVerb = new IroncladAppVerb(dfyroot, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest);

            this.batchVerb = new BatchVerifyVerb(dfyroot, new HashSet<IObligationsProducer>() { this.appVerb, this.loaderVerb }, BatchVerifyVerb.BatchMode.APP);
            this.batchSummaryVerb = new VerificationResultSummaryVerb(this.batchVerb);

            this.loaderCopy = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.loaderVerb)));
            this.bootloaderCopy = new BuildObject(Path.Combine(targetDirectory, this.bootloader.getFileName()));
            this.appExecutableCopy = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.appVerb)));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the IronfleetAppVerb class.
        /// </summary>
        /// <param name="input">Main dafny file for the application.</param>
        public IronfleetAppVerb(SourcePath input, VerificationRequest verificationRequest, bool releaseBuild = false)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            this.abstractId = new AbstractId(GetType().Name, Version, input.ToString() + verificationRequest.ToString());
            this.input      = input;
            // this.buildVerb = new VSSolutionVerb(new SourcePath(@"src\IronfleetTestDriver\IronfleetTestDriver.sln"), input, releaseBuild);
            this.buildVerb = new VSSolutionVerb(new SourcePath(@"src/IronfleetTestDriver/IronfleetTestDriver.sln"), input, releaseBuild);

            if (verificationRequest.verifyMode == VerificationRequest.VerifyMode.NoVerify)
            {
                this.exeOutput  = this.input.makeOutputObject(UnverifiedExeExt);
                this.verifyVerb = null;
                this.verbs      = new IVerb[] { this.buildVerb };
            }
            else
            {
                this.exeOutput  = this.input.makeOutputObject(VerifiedExeExt);
                this.verifyVerb = new VerificationResultSummaryVerb(new DafnyVerifyTreeVerb(input));
                this.verbs      = new IVerb[] { this.verifyVerb, this.buildVerb };
            }

            this.otherOutputs = new List <BuildObject>();
            var ohs = this.buildVerb.getOutputs().ToList();

            ohs.RemoveAll(o => o.getExtension() == ".exe");
            foreach (var o in ohs)
            {
                this.otherOutputs.Add(RelocateBuildObjectToExeDirectory(o));
            }
        }
Ejemplo n.º 9
0
        public override IVerbWorker getWorker(WorkingDirectory workingDirectory)
        {
            // First expand our Dafny source file to inline all its includes.
            this.expandedSource = this.input.getNewSourcePath("ExpandedSource.dfy");
            DafnyIncludes dafnyIncludes = new DafnyIncludes();

            dafnyIncludes.ExpandDafny(workingDirectory, this.input, this.expandedSource);

            // Call Dafny.exe to compile Dafny source to CSharp target.
            var args = new[] { "/noVerify", "/spillTargetCode:1", "/compile:2", "/ironDafny", this.expandedSource.getRelativePath() };

            Console.WriteLine("expanded source: " + this.expandedSource.getRelativePath());
            ////Logger.WriteLine("arguments: " + String.Join(" ", args));
            return
                (new ProcessInvokeAsyncWorker(
                     workingDirectory,
                     this,
                     DafnyExecutableDependencies.getDafnyExecutable().getRelativePath(),
                     args,
                     ProcessExitCodeHandling.NonzeroIsFailure,
                     getDiagnosticsBase(),
                     returnStandardOut: true,   // REVIEW: Doesn't appear to be needed.
                     returnStandardError: true, // REVIEW: Doesn't appear to be needed.
                     allowCloudExecution: true));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Gets a list of the include files included in the given Dafny source file.
        /// </summary>
        /// <param name="dfysource">Source file to extract include file names from.</param>
        /// <returns>List of include file BuildObjects.</returns>
        public IEnumerable <BuildObject> getIncludes(BuildObject dfysource)
        {
            List <BuildObject> outlist = new List <BuildObject>();

            using (TextReader tr = BuildEngine.theEngine.Repository.OpenRead(dfysource))
            {
                while (true)
                {
                    string line = tr.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    Match match = this.includeRegex.Match(line);
                    int   count = 0;
                    while (match.Success)
                    {
                        string     includedPath = match.Groups[1].ToString();
                        string     gluedPath    = Path.Combine(dfysource.getDirPath(), includedPath);
                        SourcePath sp           = new SourcePath(gluedPath);
                        outlist.Add(sp);
                        count += 1;
                        match  = match.NextMatch(); // That would be unexpected!
                    }

                    Util.Assert(count <= 1);
                }
            }

            ////Logger.WriteLine(String.Format("{0} includes {1} things", dfysource.getFilesystemPath(), outlist.Count));
            return(outlist);
        }
Ejemplo n.º 11
0
        public BatchVerifyVerb(SourcePath batch_file, BatchMode mode, VerificationRequest verificationRequest, DafnyCCVerb.FramePointerMode useFramePointer)
        {
            this.mode = mode;

            this.producers = new HashSet<IObligationsProducer>();
            foreach (string line in File.ReadAllLines(IronRootDirectory.PathTo(batch_file)))
            {
                if (line.Equals("") || line[0] == '#')
                {
                    continue;
                }

                SourcePath src = new SourcePath(line);
                switch (mode)
                {
                    case BatchMode.DAFNY:
                        if (verificationRequest.verifyMode != VerificationRequest.VerifyMode.Verify)
                        {
                            throw new UserError("BatchVerify DAFNY only supports full verification (but maybe we should add selective?)");
                        }

                        this.producers.Add(new DafnyVerifyTreeVerb(src));
                        break;
                    case BatchMode.APP:
                        this.producers.Add(new IroncladAppVerb(src, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest));
                        break;
                    default:
                        throw new Exception("Unknown batch file type");
                }
            }

            string parameters = mode.ToString() + "," + verificationRequest.ToString();
            this.outputObject = batch_file.makeLabeledOutputObject(parameters, BATCH_EXTN + VerificationObligationList.VOL_EXTN);
            this.abstractId = new AbstractId(this.GetType().Name, version, batch_file.ToString(), concrete: parameters);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the IronfleetAppVerb class.
        /// </summary>
        /// <param name="input">Main dafny file for the application.</param>
        public IronfleetAppVerb(SourcePath input, VerificationRequest verificationRequest, bool releaseBuild = false)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            this.abstractId = new AbstractId(GetType().Name, Version, input.ToString() + verificationRequest.ToString());
            this.input = input;
            this.buildVerb = new VSSolutionVerb(new SourcePath(@"src\IronfleetTestDriver\IronfleetTestDriver.sln"), input, releaseBuild);

            if (verificationRequest.verifyMode == VerificationRequest.VerifyMode.NoVerify)
            {
                this.exeOutput = this.input.makeOutputObject(UnverifiedExeExt);
                this.verifyVerb = null;
                this.verbs = new IVerb[] { this.buildVerb };
            }
            else
            {
                this.exeOutput = this.input.makeOutputObject(VerifiedExeExt);
                this.verifyVerb = new VerificationResultSummaryVerb(new DafnyVerifyTreeVerb(input));
                this.verbs = new IVerb[] { this.verifyVerb, this.buildVerb };
            }

            this.otherOutputs = new List<BuildObject>();
            var ohs = this.buildVerb.getOutputs().ToList();
            ohs.RemoveAll(o => o.getExtension() == ".exe");
            foreach (var o in ohs)
            {
                this.otherOutputs.Add(RelocateBuildObjectToExeDirectory(o));
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets a list of the include files included in the given Dafny source file.
        /// </summary>
        /// <param name="dfysource">Source file to extract include file names from.</param>
        /// <returns>List of include file BuildObjects.</returns>
        public IEnumerable<BuildObject> getIncludes(BuildObject dfysource)
        {
            List<BuildObject> outlist = new List<BuildObject>();
            using (TextReader tr = BuildEngine.theEngine.Repository.OpenRead(dfysource))
            {
                while (true)
                {
                    string line = tr.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    Match match = this.includeRegex.Match(line);
                    int count = 0;
                    while (match.Success)
                    {
                        string includedPath = match.Groups[1].ToString();
                        string gluedPath = Path.Combine(dfysource.getDirPath(), includedPath);
                        SourcePath sp = new SourcePath(gluedPath);
                        outlist.Add(sp);
                        count += 1;
                        match = match.NextMatch();  // That would be unexpected!
                    }

                    Util.Assert(count <= 1);
                }
            }

            ////Logger.WriteLine(String.Format("{0} includes {1} things", dfysource.getFilesystemPath(), outlist.Count));
            return outlist;
        }
Ejemplo n.º 14
0
 public DafnyCCVerb(SourcePath dfyroot, string appLabel, FramePointerMode useFramePointer)
     : base(dfyroot, appLabel)
 {
     this.useFramePointer            = useFramePointer;
     this.abstractId                 = new AbstractId(this.GetType().Name, this.getVersion() + version, dfyroot.ToString(), concrete: useFramePointer.ToString());
     this.dafnyCCBuildExecutableVerb = new VSSolutionVerb(new SourcePath("tools\\DafnyCC\\DafnyCC.sln", SourcePath.SourceType.Tools));
 }
Ejemplo n.º 15
0
        public override IVerbWorker getWorker(WorkingDirectory workingDirectory)
        {
            // TODO: We shouldn't be using absolute paths to any of these things.
            // Change this to allow VS and SDKs to be installed anywhere.
            string linker     = @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe";
            string vc_lib_dir = @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib";
            string sdk_dir    = @"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86";
            string kernel_lib = @"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\kernel32.Lib";

            string     standalone_support_lib = getStandaloneLib().getRelativePath();
            SourcePath zero1 = new SourcePath("tools\\scripts\\zero.obj", SourcePath.SourceType.Tools);
            SourcePath zero2 = new SourcePath("tools\\scripts\\zero2.obj", SourcePath.SourceType.Tools);

            // TODO: Fail more gracefully?  Or better yet, move these into iron/tools.
            if (!Directory.Exists(vc_lib_dir))
            {
                throw new FileNotFoundException("Missing Visual C++ library directory: " + vc_lib_dir);
            }

            if (!Directory.Exists(sdk_dir) || !File.Exists(kernel_lib))
            {
                throw new FileNotFoundException("Missing Windows SDK libraries: " + sdk_dir + ", " + kernel_lib + @". Try installing the Windows SDK from: \\research\Root\Products\Developers\Windows Driver Kit 8.1");
            }

            // TODO: Unpack/generate these automatically.
            // TODO: Brian, we're really not going to want to cache these big, empty sources. Or compress? All big (>10MB) files.
            // are mostly zeros.
            if (!File.Exists(IronRootDirectory.PathTo(zero1)) || !File.Exists(IronRootDirectory.PathTo(zero2)))
            {
                throw new FileNotFoundException("Missing object files of zeroes: " + zero1 + ", " + zero2 + ".  Try running: tools\\scripts\\build-standalone-init.sh");
            }

            List <string> args = new List <string>()
            {
                "/DEBUG", "/subsystem:console", "/LARGEADDRESSAWARE", "/fixed"
            };

            args.Add(objFile.getRelativePath());
            args.Add(zero1.getRelativePath());
            args.Add(zero2.getRelativePath());
            args.Add(standalone_support_lib);
            args.Add(@"""" + kernel_lib + @"""");
            args.Add("\"/libpath:" + vc_lib_dir + '"');
            args.Add("\"/libpath:" + sdk_dir + '"');
            args.Add("/out:" + outputObject.getRelativePath());
            args.Add("/entry:" + this.entryPoint);
            args.Add("/base:" + this.baseAddr);
            args.Add("/PDB:" + this.getPdb());

            return(new ProcessInvokeAsyncWorker(
                       workingDirectory,
                       this,
                       linker,
                       args.ToArray(),
                       ProcessExitCodeHandling.NonzeroIsFailure,
                       getDiagnosticsBase(),
                       allowAbsoluteExe: true,
                       allowAbsoluteArgs: true));
        }
Ejemplo n.º 16
0
        public DafnyTransformBaseVerb(SourcePath dfyroot, string appLabel)
        {
            this.dfyroot = dfyroot;
            this.appLabel = appLabel;

            // REVIEW: This is never used by anything.  Remove?
            IEnumerable<string> roots = this.getRoots().Select(obj => obj.ToString());
        }
Ejemplo n.º 17
0
        public DafnyTransformBaseVerb(SourcePath dfyroot, string appLabel)
        {
            this.dfyroot  = dfyroot;
            this.appLabel = appLabel;

            // REVIEW: This is never used by anything.  Remove?
            IEnumerable <string> roots = this.getRoots().Select(obj => obj.ToString());
        }
Ejemplo n.º 18
0
 static SourcePath getDafnyExecutable()
 {
     //- TODO this should eventually be a BuildObject from *building* the executable.
     if (_dafnyExecutable == null)
     {
         _dafnyExecutable = new SourcePath("tools/Dafny/Dafny.exe", SourcePath.SourceType.sourceTypeTools);
     }
     return(_dafnyExecutable);
 }
Ejemplo n.º 19
0
        ////private string outputPath = null;
        /// <summary>
        /// Initializes a new instance of the VSProjectParser class.
        /// </summary>
        /// <param name="projectFile">Visual Studio project file to parse.</param>
        public VSProjectParser(SourcePath projectFile)
        {
            this.projectFile = projectFile;
            this.Parse();

            CustomManifestParser cm = new CustomManifestParser(this.projectFile);
            this.dependencies.UnionWith(cm.getDependencies());
            this.outputs.UnionWith(cm.getOutputs());
        }
Ejemplo n.º 20
0
        public VSProjectParser(SourcePath projectFile)
        {
            _projectFile = projectFile;
            _parse();

            CustomManifestParser cm = new CustomManifestParser(_projectFile);
            _dependencies.UnionWith(cm.getDependencies());
            _outputs.UnionWith(cm.getOutputs());
        }
Ejemplo n.º 21
0
        private static SourcePath getBoogieExecutable()
        {
            // TODO this should eventually be a BuildObject from *building* the executable.
            if (BoogieVerb.boogieExecutable == null)
            {
                BoogieVerb.boogieExecutable = new SourcePath("tools\\Dafny\\Boogie.exe", SourcePath.SourceType.Tools);
            }

            return(BoogieVerb.boogieExecutable);
        }
        public static SourcePath getDafnyExecutable()
        {
            // TODO this should eventually be a BuildObject from *building* the executable.
            if (dafnyExecutable == null)
            {
                dafnyExecutable = new SourcePath("tools\\Dafny\\Dafny.exe", SourcePath.SourceType.Tools);
            }

            return dafnyExecutable;
        }
Ejemplo n.º 23
0
        private static SourcePath getNmakeExecutable()
        {
            // TODO this should eventually be a BuildObject from *building* the executable.
            if (nmakeExecutable == null)
            {
                nmakeExecutable = new SourcePath("tools\\nmake\\nmake.exe", SourcePath.SourceType.Tools);
            }

            return(nmakeExecutable);
        }
Ejemplo n.º 24
0
 public EntryStitcherVerb(IContextGeneratingVerb context, string appLabel)
 {
     this.appLabel = appLabel;
     this.context = context;
     this.entryImpInput = new SourcePath("src\\Checked\\Nucleus\\Main\\Entry.imp.beat");
     SourcePath mainBeatSrc = new SourcePath("src\\Checked\\Nucleus\\Main\\Main.ifc.beat");
     this.mainBeatVerb = new BeatVerb(context, mainBeatSrc, appLabel);
     this.genericStitch = new SourcePath("src\\Trusted\\Spec\\Entry.ifc.basm.stitch");
     this.appSpecificStitch = new SourcePath(string.Format("src\\Trusted\\Spec\\{0}\\AppRequirements.ifc.stitch", appLabel));
 }
Ejemplo n.º 25
0
        public static SourcePath getDafnyExecutable()
        {
            // TODO this should eventually be a BuildObject from *building* the executable.
            if (dafnyExecutable == null)
            {
                dafnyExecutable = new SourcePath("tools\\Dafny\\Dafny.exe", SourcePath.SourceType.Tools);
            }

            return(dafnyExecutable);
        }
Ejemplo n.º 26
0
        ////private string outputPath = null;

        /// <summary>
        /// Initializes a new instance of the VSProjectParser class.
        /// </summary>
        /// <param name="projectFile">Visual Studio project file to parse.</param>
        public VSProjectParser(SourcePath projectFile)
        {
            this.projectFile = projectFile;
            this.Parse();

            CustomManifestParser cm = new CustomManifestParser(this.projectFile);

            this.dependencies.UnionWith(cm.getDependencies());
            this.outputs.UnionWith(cm.getOutputs());
        }
Ejemplo n.º 27
0
        public override IVerbWorker getWorker(WorkingDirectory workingDirectory)
        {
            // TODO: We shouldn't be using absolute paths to any of these things.
            // Change this to allow VS and SDKs to be installed anywhere.
            string linker = @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe";
            string vc_lib_dir = @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib";
            string sdk_dir = @"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86";
            string kernel_lib = @"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\kernel32.Lib";

            string standalone_support_lib = getStandaloneLib().getRelativePath();
            SourcePath zero1 = new SourcePath("tools\\scripts\\zero.obj", SourcePath.SourceType.Tools);
            SourcePath zero2 = new SourcePath("tools\\scripts\\zero2.obj", SourcePath.SourceType.Tools);

            // TODO: Fail more gracefully?  Or better yet, move these into iron/tools.
            if (!Directory.Exists(vc_lib_dir))
            {
                throw new FileNotFoundException("Missing Visual C++ library directory: " + vc_lib_dir);
            }

            if (!Directory.Exists(sdk_dir) || !File.Exists(kernel_lib))
            {
                throw new FileNotFoundException("Missing Windows SDK libraries: " + sdk_dir + ", " + kernel_lib + @". Try installing the Windows SDK from: \\research\Root\Products\Developers\Windows Driver Kit 8.1");
            }

            // TODO: Unpack/generate these automatically.
            // TODO: Brian, we're really not going to want to cache these big, empty sources. Or compress? All big (>10MB) files.
            // are mostly zeros.
            if (!File.Exists(IronRootDirectory.PathTo(zero1)) || !File.Exists(IronRootDirectory.PathTo(zero2)))
            {
                throw new FileNotFoundException("Missing object files of zeroes: " + zero1 + ", " + zero2 + ".  Try running: tools\\scripts\\build-standalone-init.sh");
            }

            List<string> args = new List<string>() { "/DEBUG", "/subsystem:console", "/LARGEADDRESSAWARE", "/fixed" };
            args.Add(objFile.getRelativePath());
            args.Add(zero1.getRelativePath());
            args.Add(zero2.getRelativePath());
            args.Add(standalone_support_lib);
            args.Add(@"""" + kernel_lib + @"""");
            args.Add("\"/libpath:" + vc_lib_dir + '"');
            args.Add("\"/libpath:" + sdk_dir + '"');
            args.Add("/out:" + outputObject.getRelativePath());
            args.Add("/entry:" + this.entryPoint);
            args.Add("/base:" + this.baseAddr);
            args.Add("/PDB:" + this.getPdb());

            return new ProcessInvokeAsyncWorker(
                workingDirectory,
                this,
                linker,
                args.ToArray(),
                ProcessExitCodeHandling.NonzeroIsFailure,
                getDiagnosticsBase(),
                allowAbsoluteExe: true,
                allowAbsoluteArgs: true);
        }
Ejemplo n.º 28
0
        public EntryStitcherVerb(IContextGeneratingVerb context, string appLabel)
        {
            this.appLabel = appLabel;
            this.context  = context;
            entryImpInput = new SourcePath("src/Checked/Nucleus/Main/Entry.imp.beat");
            SourcePath mainBeatSrc = new SourcePath("src/Checked/Nucleus/Main/Main.ifc.beat");

            mainBeatVerb      = new BeatVerb(context, mainBeatSrc, appLabel);
            genericStitch     = new SourcePath("src/Trusted/Spec/Entry.ifc.basm.stitch");
            appSpecificStitch = new SourcePath(String.Format("src/Trusted/Spec/{0}/AppRequirements.ifc.stitch", appLabel));
        }
Ejemplo n.º 29
0
        public EntryStitcherVerb(IContextGeneratingVerb context, string appLabel)
        {
            this.appLabel      = appLabel;
            this.context       = context;
            this.entryImpInput = new SourcePath("src\\Checked\\Nucleus\\Main\\Entry.imp.beat");
            SourcePath mainBeatSrc = new SourcePath("src\\Checked\\Nucleus\\Main\\Main.ifc.beat");

            this.mainBeatVerb      = new BeatVerb(context, mainBeatSrc, appLabel);
            this.genericStitch     = new SourcePath("src\\Trusted\\Spec\\Entry.ifc.basm.stitch");
            this.appSpecificStitch = new SourcePath(string.Format("src\\Trusted\\Spec\\{0}\\AppRequirements.ifc.stitch", appLabel));
        }
Ejemplo n.º 30
0
        public DafnyCompileOneVerb(SourcePath input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            this.abstractId         = new AbstractId(GetType().Name, Version, input.ToString());
            this.input              = input;
            this.output             = input.makeOutputObject(CSharpExt);
            this.transitiveDepsVerb = new DafnyTransitiveDepsVerb(input);
            this.verbs              = new IVerb[] { this.transitiveDepsVerb };
        }
Ejemplo n.º 31
0
        public DafnyCompileOneVerb(SourcePath input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            this.abstractId = new AbstractId(GetType().Name, Version, input.ToString());
            this.input = input;
            this.output = input.makeOutputObject(CSharpExt);
            this.transitiveDepsVerb = new DafnyTransitiveDepsVerb(input);
            this.verbs = new IVerb[] { this.transitiveDepsVerb };
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Helper function for ExpandDafny method.
        /// </summary>
        /// <param name="input">Next include file to visit.</param>
        /// <returns>True if the given file wasn't already included, false otherwise.</returns>
        private bool ExpandDafnyRecurse(SourcePath input)
        {
            // Only visit each unique include file once.
            // Note that SourcePaths (like all BuildObjects) have normalized file paths.
            string inputPath = input.getRelativePath();

            if (this.visited.Contains(inputPath))
            {
                return(false);
            }
            else
            {
                this.visited.Add(inputPath);
            }

            using (TextReader reader = new StreamReader(this.workingDirectory.PathTo(input)))
            {
                while (true)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        return(true);
                    }

                    Match match = this.includeRegex.Match(line);
                    if (match.Success)
                    {
                        // This is an "include" line.  Find the included object.
                        string     includedPath = match.Groups[1].ToString();
                        string     gluedPath    = Path.Combine(input.getDirPath(), includedPath);
                        SourcePath nextInclude  = new SourcePath(gluedPath);
                        string     nextPath     = nextInclude.getRelativePath();

                        // Recurse on the new include file.
                        this.outputWriter.WriteLine("//- Begin include {0} (from {1})", nextPath, inputPath);
                        if (!this.ExpandDafnyRecurse(nextInclude))
                        {
                            this.outputWriter.WriteLine("//- Already included {0}", nextPath);
                        }

                        this.outputWriter.WriteLine("//- End include {0} (from {1})", nextPath, inputPath);
                    }
                    else
                    {
                        // This isn't an "include" line.  Write it to our output.
                        this.outputWriter.WriteLine(line);
                    }
                }
            }
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Initializes a new instance of the VSSolutionVerb class.
        /// </summary>
        /// <param name="solutionFile">Solution file to build.</param>
        /// <param name="optionalDafnyInput">Optional dafny-derived-CSharp dependency.</param>
        public VSSolutionVerb(SourcePath solutionFile, SourcePath optionalDafnyInput = null, bool releaseBuild = false)
        {
            this.solutionFile = solutionFile;
            this.abstractId   = new AbstractId(this.GetType().Name, VSSolutionVerb.Version, this.solutionFile.ToString());
            this.releaseBuild = releaseBuild;

            // Parse the solution file (and project files contained in the solution).
            this.solutionParser = new VSSolutionParser(this.solutionFile);

            this.outputPathSuffix = Path.Combine(BuildEngine.theEngine.getObjRoot(), this.solutionFile.getDirPath());

            if (optionalDafnyInput != null)
            {
                this.dafnyCompileOneVerb = new DafnyCompileOneVerb(optionalDafnyInput);
            }
        }
        IEnumerable <SourcePath> getTrustedBoogieAxioms()
        {
            OrderPreservingSet <SourcePath> result = new OrderPreservingSet <SourcePath>();
            AnnotationScanner anns = new AnnotationScanner(basmInput);

            foreach (string[] annotation in anns.getAnnotations(AddBoogieAxiomAnnotation))
            {
                string     module      = annotation[1];
                SourcePath trustedPath = new SourcePath(Path.Combine(
                                                            BuildEngine.theEngine.getSrcRoot(),
                                                            BuildEngine.VerveTrustedSpecDir,
                                                            module + BoogieVerb.BPL_EXTN));
                result.Add(trustedPath);
            }
            return(result);
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Initializes a new instance of the VSSolutionVerb class.
        /// </summary>
        /// <param name="solutionFile">Solution file to build.</param>
        /// <param name="optionalDafnyInput">Optional dafny-derived-CSharp dependency.</param>
        public VSSolutionVerb(SourcePath solutionFile, SourcePath optionalDafnyInput = null, bool releaseBuild = false)
        {
            this.solutionFile = solutionFile;
            this.abstractId = new AbstractId(this.GetType().Name, VSSolutionVerb.Version, this.solutionFile.ToString());
            this.releaseBuild = releaseBuild;

            // Parse the solution file (and project files contained in the solution).
            this.solutionParser = new VSSolutionParser(this.solutionFile);

            this.outputPathSuffix = Path.Combine(BuildEngine.theEngine.getObjRoot(), this.solutionFile.getDirPath());

            if (optionalDafnyInput != null)
            {
                this.dafnyCompileOneVerb = new DafnyCompileOneVerb(optionalDafnyInput);
            }
        }
Ejemplo n.º 36
0
        public override IVerbWorker getWorker()
        {
            string     linker                 = @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe";
            string     vc_lib_dir             = @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib";
            string     sdk_dir                = @"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86";
            string     kernel_lib             = @"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\kernel32.Lib";
            string     standalone_support_lib = getStandaloneLib().getRelativePath();
            SourcePath zero1 = new SourcePath("tools/scripts/zero.obj", SourcePath.SourceType.sourceTypeTools);
            SourcePath zero2 = new SourcePath("tools/scripts/zero2.obj", SourcePath.SourceType.sourceTypeTools);

            //- TODO: Fail more gracefully?  Or better yet, move these into iron/tools
            if (!Directory.Exists(vc_lib_dir))
            {
                throw new FileNotFoundException("Missing Visual C++ library directory: " + vc_lib_dir);
            }

            if (!Directory.Exists(sdk_dir) || !File.Exists(kernel_lib))
            {
                throw new FileNotFoundException("Missing Windows SDK libraries: " + sdk_dir + ", " + kernel_lib + @". Try installing the Windows SDK from: \\research\Root\Products\Developers\Windows Driver Kit 8.1");
            }

            //- TODO: Unpack/generate these automatically
            if (!File.Exists(zero1.getFilesystemPath()) || !File.Exists(zero2.getFilesystemPath()))
            {
                throw new FileNotFoundException("Missing object files of zeroes: " + zero1 + ", " + zero2 + ".  Try running: tools/scripts/build-standalone-init.sh");
            }

            List <string> args = new List <string>()
            {
                "/DEBUG", "/subsystem:console", "/LARGEADDRESSAWARE", "/fixed"
            };

            args.Add(objFile.getRelativePath());
            args.Add(zero1.getRelativePath());
            args.Add(zero2.getRelativePath());
            args.Add(standalone_support_lib);
            args.Add(@"""" + kernel_lib + @"""");
            args.Add("\"/libpath:" + vc_lib_dir + '"');
            args.Add("\"/libpath:" + sdk_dir + '"');
            args.Add("/out:" + outputObject.getRelativePath());
            args.Add("/entry:" + entryPoint);
            args.Add("/base:" + baseAddr);
            args.Add("/PDB:" + getPdb());

            return(new ProcessInvokeAsyncWorker(this,
                                                linker, args.ToArray(), ProcessInvoker.RcHandling.NONZERO_RC_IS_FAILURE, getDiagnosticsBase(), allowAbsoluteExe: true, allowAbsoluteArgs: true));
        }
Ejemplo n.º 37
0
        public NmakeVerb(SourcePath makefile)
        {
            this.makefile = makefile;
            this.abstractId = new AbstractId(this.GetType().Name, version, this.makefile.ToString());

            // Generate output path.
            this.outputPath = ".";
            int depth = this.makefile.getDirPath().Split(@"\/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length;
            for (int i = 0; i < depth; i++)
            {
                this.outputPath = Path.Combine(this.outputPath, "..");
            }

            this.outputPathSuffix = Path.Combine(BuildEngine.theEngine.getObjRoot(), this.makefile.getDirPath());
            this.outputPath = Path.Combine(this.outputPath, this.outputPathSuffix);
            this.customManifest = new CustomManifestParser(this.makefile);
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Expand a dafny source file to include all of its includes inline.
        /// </summary>
        /// <param name="workingDirectory">Temporary working directory to use.</param>
        /// <param name="input">Source build object.</param>
        /// <param name="output">Where to create build object for expanded source file.</param>
        public void ExpandDafny(WorkingDirectory workingDirectory, SourcePath input, SourcePath output)
        {
            // Prepare the output stream.
            using (TextWriter outWriter = new StreamWriter(workingDirectory.PathTo(output)))
            {
                // Stash away a few things for use by our recursive helper function.
                this.workingDirectory = workingDirectory;
                this.outputWriter     = outWriter;
                this.visited          = new HashSet <string>();

                // Recursively expand the initial Dafny source file to inline all of its includes.
                this.ExpandDafnyRecurse(input);
            }

            // Cache the output file in the Repository.
            BuildEngine.theEngine.Repository.Store(workingDirectory, output, new Fresh());
        }
Ejemplo n.º 39
0
        public NmakeVerb(SourcePath makefile)
        {
            this.makefile   = makefile;
            this.abstractId = new AbstractId(this.GetType().Name, version, this.makefile.ToString());

            // Generate output path.
            this.outputPath = ".";
            int depth = this.makefile.getDirPath().Split(@"\/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length;

            for (int i = 0; i < depth; i++)
            {
                this.outputPath = Path.Combine(this.outputPath, "..");
            }

            this.outputPathSuffix = Path.Combine(BuildEngine.theEngine.getObjRoot(), this.makefile.getDirPath());
            this.outputPath       = Path.Combine(this.outputPath, this.outputPathSuffix);
            this.customManifest   = new CustomManifestParser(this.makefile);
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Gets information about an object in this repository.
        /// Will add missing source objects to the repository as needed.
        /// </summary>
        /// <param name="obj">The object to look up.</param>
        /// <returns>Information about the object.</returns>
        /// <remarks>
        /// Returns null if obj isn't in this run's cache.
        /// Cannot return value.disposition==Stale, I guess?
        /// </remarks>
        private RepositoryEntry GetValue(BuildObject obj)
        {
            if (this.entries.ContainsKey(obj))
            {
                return(this.entries[obj]);
            }
            else
            {
                SourcePath src = obj as SourcePath;
                if (src != null)
                {
                    // Special case to get local source files into the
                    // repository (and the item cache).
                    // REVIEW: Should we require that source files are explicitly added?
                    try
                    {
                        // Complain if someone uses tabs or non-CRLF line endings in a source file.
                        // Visual Studio is pretty insistent on using tabs in solution (.sln) files, so we let it.
                        if ((src.Type == SourcePath.SourceType.Src) && (src.getExtension() != ".sln"))
                        {
                            if (!Util.CheckSourceFileForBadCharacters(IronRootDirectory.PathTo(obj)))
                            {
                                throw new SourceConfigurationError("Bad characters (tabs?) or non-CRLF line endings in source file " + obj.getRelativePath());
                            }
                        }

                        string hash = Util.hashFilesystemPath(IronRootDirectory.PathTo(obj));
                        this.itemCache.StoreItemFromFile(ItemCacheContainer.Sources, hash, IronRootDirectory.PathTo(obj));
                        this.Add(obj, new Fresh(), hash, null);
                    }
                    catch (IOException)
                    {
                        throw new SourceConfigurationError("Cannot find source path " + obj.getRelativePath());
                    }

                    return(this.entries[obj]);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 41
0
        private void parseCustomManifest(SourcePath basePath)
        {
            SourcePath manifest = basePath.getNewSourcePath("nubuild-manifest.txt");

            this.dependencies.Add(manifest);

            using (StreamReader stream = new StreamReader(IronRootDirectory.PathTo(manifest)))
            {
                string origline;

                while ((origline = stream.ReadLine()) != null)
                {
                    string line = origline.Trim();

                    if (line.Length == 0)
                    {
                        continue;
                    }

                    if (line.Substring(0, 1) == "#")
                    {
                        continue;
                    }

                    string[] parts = line.Split();

                    if (parts.Length != 2)
                    {
                        throw new UserError(string.Format("{0}: badly formed manifest line {1}", IronRootDirectory.PathTo(manifest), origline));
                    }

                    if ("output".Equals(parts[0]))
                    {
                        this.outputs.Add(new BuildObject(Path.Combine(basePath.getDirPath(), parts[1])));
                    }
                    else if ("dependency".Equals(parts[0]))
                    {
                        this.dependencies.Add(basePath.getNewSourcePath(parts[1]));
                    }
                }
            }
        }
Ejemplo n.º 42
0
        public VSSolutionVerb(SourcePath solutionFile)
        {
            _solutionFile = solutionFile;
            _abstractId   = new AbstractId(this.GetType().Name, version, _solutionFile.ToString());

            //- Parse the solution file
            _solutionParser = new VSSolutionParser(_solutionFile);

            //- Generate output path
            _outputPath = ".";
            int depth = _solutionFile.getDirPath().Split(@"\/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length;

            for (int i = 0; i < depth; i++)
            {
                _outputPath = Path.Combine(_outputPath, "..");
            }

            _outputPathSuffix = Path.Combine(BuildEngine.theEngine.getObjRoot(), _solutionFile.getDirPath());
            _outputPath       = Path.Combine(_outputPath, _outputPathSuffix);
        }
Ejemplo n.º 43
0
        private void parseCustomManifest(SourcePath basePath)
        {
            SourcePath manifest = basePath.getNewSourcePath("nubuild-manifest.txt");
            this.dependencies.Add(manifest);

            using (StreamReader stream = new StreamReader(IronRootDirectory.PathTo(manifest)))
            {
                string origline;

                while ((origline = stream.ReadLine()) != null)
                {
                    string line = origline.Trim();

                    if (line.Length == 0)
                    {
                        continue;
                    }

                    if (line.Substring(0, 1) == "#")
                    {
                        continue;
                    }

                    string[] parts = line.Split();

                    if (parts.Length != 2)
                    {
                        throw new UserError(string.Format("{0}: badly formed manifest line {1}", IronRootDirectory.PathTo(manifest), origline));
                    }

                    if ("output".Equals(parts[0]))
                    {
                        this.outputs.Add(new BuildObject(Path.Combine(basePath.getDirPath(), parts[1])));
                    }
                    else if ("dependency".Equals(parts[0]))
                    {
                        this.dependencies.Add(basePath.getNewSourcePath(parts[1]));
                    }
                }
            }
        }
Ejemplo n.º 44
0
        public override IVerbWorker getWorker(WorkingDirectory workingDirectory)
        {
            // First expand our Dafny source file to inline all its includes.
            this.expandedSource = this.input.getNewSourcePath("ExpandedSource.dfy");
            DafnyIncludes dafnyIncludes = new DafnyIncludes();
            dafnyIncludes.ExpandDafny(workingDirectory, this.input, this.expandedSource);

            // Call Dafny.exe to compile Dafny source to CSharp target.
            var args = new[] { "/noVerify", "/spillTargetCode:1", "/compile:2", "/ironDafny", this.expandedSource.getRelativePath() };
            Console.WriteLine("expanded source: " + this.expandedSource.getRelativePath());
            ////Logger.WriteLine("arguments: " + String.Join(" ", args));
            return
                new ProcessInvokeAsyncWorker(
                    workingDirectory,
                    this,
                    DafnyExecutableDependencies.getDafnyExecutable().getRelativePath(),
                    args,
                    ProcessExitCodeHandling.NonzeroIsFailure,
                    getDiagnosticsBase(),
                    returnStandardOut: true,  // REVIEW: Doesn't appear to be needed.
                    returnStandardError: true,  // REVIEW: Doesn't appear to be needed.
                    allowCloudExecution: true);
        }
Ejemplo n.º 45
0
 public CustomManifestParser(SourcePath basePath)
 {
     this.parseCustomManifest(basePath);
 }
Ejemplo n.º 46
0
        /// <summary>
        /// Expand a dafny source file to include all of its includes inline.
        /// </summary>
        /// <param name="workingDirectory">Temporary working directory to use.</param>
        /// <param name="input">Source build object.</param>
        /// <param name="output">Where to create build object for expanded source file.</param>
        public void ExpandDafny(WorkingDirectory workingDirectory, SourcePath input, SourcePath output)
        {
            // Prepare the output stream.
            using (TextWriter outWriter = new StreamWriter(workingDirectory.PathTo(output)))
            {
                // Stash away a few things for use by our recursive helper function.
                this.workingDirectory = workingDirectory;
                this.outputWriter = outWriter;
                this.visited = new HashSet<string>();

                // Recursively expand the initial Dafny source file to inline all of its includes.
                this.ExpandDafnyRecurse(input);
            }

            // Cache the output file in the Repository.
            BuildEngine.theEngine.Repository.Store(workingDirectory, output, new Fresh());
        }
Ejemplo n.º 47
0
 public DafnyVerifyTreeVerb(SourcePath root)
 {
     this.displayRoot = root;
     this.obligations = root.makeOutputObject(DFYTREE_EXTN + VerificationObligationList.VOL_EXTN);
     this.abstractId = new AbstractId(this.GetType().Name, version, root.ToString());
 }
Ejemplo n.º 48
0
        /// <summary>
        /// Helper function for ExpandDafny method.
        /// </summary>
        /// <param name="input">Next include file to visit.</param>
        /// <returns>True if the given file wasn't already included, false otherwise.</returns>
        private bool ExpandDafnyRecurse(SourcePath input)
        {
            // Only visit each unique include file once.
            // Note that SourcePaths (like all BuildObjects) have normalized file paths.
            string inputPath = input.getRelativePath();
            if (this.visited.Contains(inputPath))
            {
                return false;
            }
            else
            {
                this.visited.Add(inputPath);
            }

            using (TextReader reader = new StreamReader(this.workingDirectory.PathTo(input)))
            {
                while (true)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        return true;
                    }

                    Match match = this.includeRegex.Match(line);
                    if (match.Success)
                    {
                        // This is an "include" line.  Find the included object.
                        string includedPath = match.Groups[1].ToString();
                        string gluedPath = Path.Combine(input.getDirPath(), includedPath);
                        SourcePath nextInclude = new SourcePath(gluedPath);
                        string nextPath = nextInclude.getRelativePath();

                        // Recurse on the new include file.
                        this.outputWriter.WriteLine("//- Begin include {0} (from {1})", nextPath, inputPath);
                        if (!this.ExpandDafnyRecurse(nextInclude))
                        {
                            this.outputWriter.WriteLine("//- Already included {0}", nextPath);
                        }

                        this.outputWriter.WriteLine("//- End include {0} (from {1})", nextPath, inputPath);
                    }
                    else
                    {
                        // This isn't an "include" line.  Write it to our output.
                        this.outputWriter.WriteLine(line);
                    }
                }
            }
        }
Ejemplo n.º 49
0
        private static SourcePath getBoogieExecutable()
        {
            // TODO this should eventually be a BuildObject from *building* the executable.
            if (BoogieVerb.boogieExecutable == null)
            {
                BoogieVerb.boogieExecutable = new SourcePath("tools\\Dafny\\Boogie.exe", SourcePath.SourceType.Tools);
            }

            return BoogieVerb.boogieExecutable;
        }
Ejemplo n.º 50
0
 public DafnySpecVerb(SourcePath dfyroot, string appLabel)
     : base(dfyroot, appLabel)
 {
     this.abstractId = new AbstractId(this.GetType().Name, this.getVersion() + version, dfyroot.ToString());
     this.dafnySpecBuildExecutableVerb = new VSSolutionVerb(new SourcePath("tools\\DafnySpec\\DafnySpec.sln", SourcePath.SourceType.Tools));
 }
Ejemplo n.º 51
0
        public IroncladAppVerb(SourcePath dfyroot, TARGET target, DafnyCCVerb.FramePointerMode framePointerMode, VerificationRequest verificationRequest)
        {
            this.dfyroot = dfyroot;

            // TODO this is the only #define we support just yet, so I'm stuffing it in here.
            // We'll need to plumb more carefully when we want to add x64.
            if (dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last().Equals("AppLoader"))
            {
                this.poundDefines = new PoundDefines(new string[] { "AppLoader" });
            }
            else
            {
                this.poundDefines = PoundDefines.empty();
            }

            this.verificationRequest = verificationRequest;
            this.abstractId = new AbstractId(
                this.GetType().Name,
                version,
                dfyroot.ToString(),
                this.poundDefines,
                concrete: string.Format(
                    "{0},{1},{2}",
                    target,
                    framePointerMode.ToString(),
                    verificationRequest.ToString()));
            this.appLabel = dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last();
            this.dafnyspecVerb = new DafnySpecVerb(dfyroot, this.appLabel);
            this.dafnyccVerb = new DafnyCCVerb(dfyroot, this.appLabel, framePointerMode);

            bool isLoader = dfyroot.getRelativePath().Equals(BootableAppVerb.LOADER_DFY);

            // NB we keep dafnyccVerb as the lowest-priority context, so that our hand-written
            // beat impls will override its output.
            IContextGeneratingVerb contextWithDafny = new ConcatContextVerb(
                BuildEngine.theEngine.getVerveContextVerb(this.poundDefines),
                new VerbOutputsContextVerb(this.dafnyspecVerb, false),
                new VerbOutputsContextVerb(this.dafnyccVerb, true),
                this.poundDefines);
            this.stitcherVerb = new EntryStitcherVerb(contextWithDafny, this.appLabel);
            IContextGeneratingVerb contextWithDafnyAndEntry = new ConcatContextVerb(
                new VerbOutputsContextVerb(this.stitcherVerb, false),
                contextWithDafny,
                this.poundDefines);

            BuildObject entryImpObj = this.stitcherVerb.getEntryImpOutput();
            BoogieAsmLinkVerb entryVerb = new BoogieAsmLinkVerb(contextWithDafnyAndEntry, entryImpObj);
            if (target == TARGET.BARE_METAL)
            {
                MasmVerb masmVerb = new MasmVerb(entryVerb);
                this.linkerVerb = new LinkerVerb(masmVerb, isLoader);
            }
            else if (target == TARGET.WINDOWS)
            {     // Rewrite the asm that comes out of entryVerb before linking it
                AsmRewriterVerb rewriter = new AsmRewriterVerb(entryVerb);
                MasmVerb masmVerb = new MasmVerb(rewriter);
                this.linkerVerb = new WinLinkerVerb(masmVerb, isLoader);
            }

            BoogieAsmVerificationObligationListVerb bavolVerb =
                new BoogieAsmVerificationObligationListVerb(contextWithDafnyAndEntry, entryImpObj, verificationRequest);

            this.verifyResultsVerb = new VerificationResultSummaryVerb(bavolVerb);

            this.srcObject = this.linkerVerb.getUntrustedExe();
            if (verificationRequest.isComplete())
            {
                this.exeObject = dfyroot.makeOutputObject(TRUSTED_EXE_EXTN);
                this.outputObject = this.exeObject;
            }
            else
            {
                this.exeObject = this.srcObject;
                this.outputObject = dfyroot.makeVirtualObject(UNVERIFIED_SENTINEL_EXTENSION);
            }
        }
Ejemplo n.º 52
0
 public DafnySpecVerb(SourcePath dfyroot, string appLabel)
     : base(dfyroot, appLabel)
 {
     this.abstractId = new AbstractId(this.GetType().Name, this.getVersion() + version, dfyroot.ToString());
     this.dafnySpecBuildExecutableVerb = new VSSolutionVerb(new SourcePath("tools\\DafnySpec\\DafnySpec.sln", SourcePath.SourceType.Tools));
 }
Ejemplo n.º 53
0
        private IEnumerable<SourcePath> getTrustedBoogieAxioms()
        {
            OrderPreservingSet<SourcePath> result = new OrderPreservingSet<SourcePath>();
            AnnotationScanner anns = new AnnotationScanner(basmInput);
            foreach (string[] annotation in anns.getAnnotations(AddBoogieAxiomAnnotation))
            {
                string module = annotation[1];
                SourcePath trustedPath = new SourcePath(Path.Combine(
                    BuildEngine.theEngine.getSrcRoot(),
                    BuildEngine.VerveTrustedSpecDir,
                    module + BoogieVerb.BPL_EXTN));
                result.Add(trustedPath);
            }

            return result;
        }
Ejemplo n.º 54
0
 public DafnyVerifyOneVerb(SourcePath dfysource)
 {
     this.dfysource = dfysource;
     this.abstractId = new AbstractId(this.GetType().Name, version, dfysource.ToString());                
 }
Ejemplo n.º 55
0
        private static SourcePath getNmakeExecutable()
        {
            // TODO this should eventually be a BuildObject from *building* the executable.
            if (nmakeExecutable == null)
            {
                nmakeExecutable = new SourcePath("tools\\nmake\\nmake.exe", SourcePath.SourceType.Tools);
            }

            return nmakeExecutable;
        }
Ejemplo n.º 56
0
 public VSSolutionParser(SourcePath solutionFile)
 {
     this.solutionFile = solutionFile;
     this.Parse();
 }