diff options
author | lorch <lorch@epfl.ch> | 2008-04-22 09:06:05 +0000 |
---|---|---|
committer | lorch <lorch@epfl.ch> | 2008-04-22 09:06:05 +0000 |
commit | c3b7c00d1e8a1233a741c33f5ac2e584b548a89d (patch) | |
tree | bfcb97e425b9a385387f027a516947d604451450 /src | |
parent | 6af6ce11308ba6e6757365a390ad38c4a29cd23f (diff) | |
download | scala-c3b7c00d1e8a1233a741c33f5ac2e584b548a89d.tar.gz scala-c3b7c00d1e8a1233a741c33f5ac2e584b548a89d.tar.bz2 scala-c3b7c00d1e8a1233a741c33f5ac2e584b548a89d.zip |
Fixed #521: MSIL should support separate compil...
Fixed #521: MSIL should support separate compilation
- The output directory must be specified by "-d" (default: ".") There is
- a new switch -Xkeep-msil-files (default: false). This switch must be
- explicitly enabled if you want to keep the generated .msil files
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/Settings.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala | 26 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index 9665a8bf00..ec94b79799 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -102,6 +102,7 @@ class Settings(error: String => Unit) { val assemname = StringSetting ("-Xassem", "file", "Name of the output assembly (only relevant with -target:msil)", "").dependsOn(target, "msil") val assemrefs = StringSetting ("-Xassem-path", "path", "List of assemblies referenced by the program (only relevant with -target:msil)", ".").dependsOn(target, "msil") + val keepMsilFiles = BooleanSetting ("-Xkeep-msil-files", "Keep .msil files after calling ilasm").dependsOn(target, "msil").hideToIDE val Xchecknull = BooleanSetting ("-Xcheck-null", "Emit warning on selection of nullable reference") val noassertions = BooleanSetting ("-Xdisable-assertions", "Generate no assertions and assumptions") val Xexperimental = BooleanSetting ("-Xexperimental", "Enable experimental extensions") diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 73597b6976..0a522f7948 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -51,7 +51,6 @@ abstract class GenMSIL extends SubComponent { classes.values foreach codeGenerator.createTypeBuilder classes.values foreach codeGenerator.createClassMembers - try { classes.values foreach codeGenerator.genClass } finally { @@ -217,12 +216,13 @@ abstract class GenMSIL extends SubComponent { var assemName: String = _ var firstSourceName = "" var outDir: File = _ + var moduleName: String = _ def initAssembly() { assemName = settings.assemname.value - if (assemName == "") { + if (assemName == "") { if (entryPoint != null) { assemName = msilName(entryPoint.enclClass) // remove the $ at the end (from module-name) @@ -238,18 +238,16 @@ abstract class GenMSIL extends SubComponent { if (assemName.endsWith(".il")) assemName = assemName.substring(0, assemName.length()-3) val f: File = new File(assemName) - outDir = f.getParentFile() assemName = f.getName() } - if (outDir == null) - outDir = new File(".") + outDir = new File(settings.outdir.value) val assemblyName = new AssemblyName() assemblyName.Name = assemName massembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName) - val moduleName = assemName + (if (entryPoint == null) ".dll" else ".exe") + moduleName = assemName + (if (entryPoint == null) ".dll" else ".exe") // filename here: .dll or .exe (in both parameters), second: give absolute-path mmodule = massembly.DefineDynamicModule(moduleName, new File(outDir, moduleName).getAbsolutePath()) @@ -450,18 +448,22 @@ abstract class GenMSIL extends SubComponent { code.Emit(OpCodes.Ret) } createTypes() - val filename = new File(outDir, assemName + ".msil").getPath() if (settings.debug.value) - log("Output file name: " + filename) + log("Output path: " + outDir.getPath) try { - massembly.Save(filename) + massembly.Save(outDir.getPath) val ilasm = Properties.msilILasm if (ilasm != "") { - val cmd = ilasm + " " + filename + val generatedFiles = List.fromArray(massembly.GetGeneratedFiles) + val cmd = ilasm + " " + (if(entryPoint == null) "/dll" else "/exe") + " /output:" + moduleName + " " + generatedFiles.mkString(" ") if (settings.debug.value) log("Executing command: " + cmd) try { - Runtime.getRuntime().exec(cmd) + val p = Runtime.getRuntime().exec(cmd) + p.waitFor() // wait until ilasm is done + if(!settings.keepMsilFiles.value) { + generatedFiles.foreach(f => new File(f).delete()) + } } catch { case _ => Console.println("Cannot run command: " + cmd) @@ -469,7 +471,7 @@ abstract class GenMSIL extends SubComponent { } } } catch { - case _: Error => abort("Could not save file " + filename) + case _: Error => abort("Could not save files in " + outDir.getPath) } } |