public override IVerbWorker getWorker() { List <string> arguments = new List <string>(); arguments.Add("/dafnycc"); arguments.Add("/z3opt:ARITH_RANDOM_SEED=1"); arguments.Add("/compile:0"); arguments.Add("/timeLimit:30"); arguments.Add("/noCheating:1"); foreach (string[] ann in new AnnotationScanner(dfysource).getAnnotations(ADDDAFNYFLAG_LABEL)) { if (ann.Length != 2) { throw new SourceConfigurationError("Expected exactly 1 argument to " + ADDDAFNYFLAG_LABEL); } arguments.Add(ann[1]); } arguments.Add(dfysource.getRelativePath()); return(new ProcessInvokeAsyncWorker(this, getDafnyExecutable().getRelativePath(), arguments.ToArray(), ProcessInvoker.RcHandling.NONZERO_RC_IS_OKAY, getDiagnosticsBase())); }
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()); }
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)); }
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); }
/// <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); } } } }
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)); }
private void _parse() { _dependencies.Add(_projectFile); using (XmlTextReader reader = new XmlTextReader(_projectFile.getFilesystemPath())) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (String.Compare(reader.Name, "Compile") == 0) { _dependencies.Add(_projectFile.getNewSourcePath(reader.GetAttribute("Include"))); } else if (String.Compare(reader.Name, "PropertyGroup") == 0) { _parseOutput(reader); } } } reader.Close(); } if (_outputType != null && _assemblyName != null) //- && _outputPath != null) { string path = Path.Combine(_projectFile.getDirPath(), String.Format("{0}.{1}", _assemblyName, outputTypeToExtension(_outputType))); //-Console.WriteLine("{0}: generating {1}", _projectFile.getRelativePath(), path); _outputs.Add(new BuildObject(path)); } else { throw new UserError(String.Format("Project {0} doesn't seem to have output specification in the expected format", _projectFile.getRelativePath())); } }
/// <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); } } } }
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); } }