diff options
author | 2011-12-19 15:34:13 -0800 | |
---|---|---|
committer | 2011-12-19 15:34:13 -0800 | |
commit | d0cd1faa2c6805596817f8f70e84707ea4226454 (patch) | |
tree | 506a3986fb17ad3bf3fe412a6251f166ebe8474a /Source/DafnyDriver/DafnyDriver.cs | |
parent | 24ccf275b190b71b671e1884a58e83fe0976f4d3 (diff) |
Dafny: compile to .exe only if there is a Main method; otherwise, compile to a .dll
Diffstat (limited to 'Source/DafnyDriver/DafnyDriver.cs')
-rw-r--r-- | Source/DafnyDriver/DafnyDriver.cs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Source/DafnyDriver/DafnyDriver.cs b/Source/DafnyDriver/DafnyDriver.cs index c7a929b8..062af148 100644 --- a/Source/DafnyDriver/DafnyDriver.cs +++ b/Source/DafnyDriver/DafnyDriver.cs @@ -222,11 +222,15 @@ namespace Microsoft.Dafny var provider = CodeDomProvider.CreateProvider("CSharp");
var cp = new System.CodeDom.Compiler.CompilerParameters();
cp.GenerateExecutable = true;
- // TODO: an improvement would be to generate a .dll if there is no Main method
- cp.OutputAssembly = Path.ChangeExtension(dafnyProgramName, "exe");
+ if (compiler.HasMain(dafnyProgram)) {
+ cp.OutputAssembly = Path.ChangeExtension(dafnyProgramName, "exe");
+ cp.CompilerOptions = "/debug";
+ } else {
+ cp.OutputAssembly = Path.ChangeExtension(dafnyProgramName, "dll");
+ cp.CompilerOptions = "/debug /target:library";
+ }
cp.GenerateInMemory = false;
cp.ReferencedAssemblies.Add("System.Numerics.dll");
- cp.CompilerOptions = "/debug";
var cr = provider.CompileAssemblyFromSource(cp, csharpProgram);
if (cr.Errors.Count == 0) {
|