Wednesday, August 15, 2012

Building a stand-alone scalalib.dll for .net convenience

Following up on the previous post -- making a single dll scala runtime goes as follows

  1. Download and expand IKVM 7 into folder
  2. Copy the contents of the bin subfolder into a folder .\scala-out
  3. Copy scalalib.dll and forkjoin.dll into that same .\scala-out folder
  4. Install ILMerge if not already available
  5. Run this command (assuming powershell prompt)
    & 'C:\Program Files\Microsoft\ILMerge\ILMerge.exe' /closed /allowDup /t:library /targetplatform:"v4,c:\windows\Microsoft.NET\Framework\v4.0.30319" /out:scalalib.dll .\scala-out\scalalib.dll .\scala-out\forkjoin.dll  .\scala-out\IKVM.OpenJDK.Charsets.dll .\scala-out\IKVM.Runtime.JNI.dll .\scala-out\IKVM.OpenJDK.Text.dll .\scala-out\IKVM.OpenJDK.Beans.dll .\scala-out\IKVM.OpenJDK.XML.API.dll .\scala-out\IKVM.Reflection.dll .\scala-out\IKVM.Runtime.dll .\scala-out\IKVM.OpenJDK.Management.dll .\scala-out\IKVM.OpenJDK.Corba.dll .\scala-out\IKVM.OpenJDK.Core.dll
    and wait until done (takes ~3GB memory, so 64-bit systems only)
  6. Observe that some of those referenced assemblies aren't actually in the IKVM subset that the scalacompiler.exe drop bundles
  7. Build helloworld.exe as before and co-locate it with the new 33Mb scalalib.dll that resulted from all the grinding
  8. It just works™

Hopefully the real deal will bundle something like this -- ideally also strong-named (but hey, you can do that with Mono.Cecil to rewrite that file and the assemblies you link against it).

P.S. If you have .net 4.5 on your machine, change the target platform as indicated here.

PP.S. The runtime has a dependency on the native code ikvm-native-win32-x64.dll and ikvm-native-win32-x86.dll from the IKVM download, though I'm not sure where from the depths of IKVM you may hit those.

Post a Comment