From efbca75cc0f1a85fc76058c52c6fd656312c2438 Mon Sep 17 00:00:00 2001
From: Philippe Suter <philippe.suter@gmail.com>
Date: Mon, 21 Jun 2010 15:08:16 +0000
Subject: [PATCH] now creates the script properly.

---
 project/build/funcheck.scala | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/project/build/funcheck.scala b/project/build/funcheck.scala
index ea79831c4..86484ef09 100644
--- a/project/build/funcheck.scala
+++ b/project/build/funcheck.scala
@@ -1,13 +1,39 @@
 import sbt._
 
-class FunCheckProject(info: ProjectInfo) extends ParentProject(info) {
+class FunCheckProject(info: ProjectInfo) extends ParentProject(info) with FileTasks {
   override def outputDirectoryName = "bin"
   override def dependencyPath      = "lib"
   override def shouldCheckOutputDirectories = false
+
   lazy val purescala = project(".", "PureScala Definitions", new PureScalaProject(_))
   lazy val plugin    = project(".", "FunCheck Plugin", new PluginProject(_), purescala)
   lazy val multisets = project(".", "Multiset Solver", new MultisetsProject(_), plugin, purescala)
 
+  val scriptPath: Path = "." / "scalac-funcheck"
+
+  lazy val all = fileTask(scriptPath :: Nil)(allActions) dependsOn(plugin.`package`) describedAs("Compile everything and produce a script file.")
+
+  def allActions: Option[String] = {
+    val nl = System.getProperty("line.separator")
+    val f = scriptPath.asFile
+    val fw = new java.io.FileWriter(f)
+    fw.write("#!/bin/sh" + nl)
+    fw.write("LD_LIBRARY_PATH=" + ("." / "lib-bin").absolutePath + " \\" + nl)
+    fw.write("java \\" + nl)
+    val libStr = (buildLibraryJar.absolutePath).toString
+    fw.write("    -Dscala.home=" + libStr.substring(0, libStr.length-21) + " \\" + nl)
+    fw.write("    -classpath \\" + nl)
+    fw.write("    " + buildLibraryJar.absolutePath + ":")
+    fw.write(buildCompilerJar.absolutePath + ":")
+    fw.write(purescala.jarPath.absolutePath + ":")
+    fw.write(plugin.jarPath.absolutePath + ":")
+    fw.write(("lib" / "z3.jar").absolutePath + " \\" + nl)
+    fw.write("  scala.tools.nsc.Main -Xplugin:" + plugin.jarPath.absolutePath + " $@" + nl)
+    fw.close
+    f.setExecutable(true)
+    None
+  }
+
   sealed abstract class PersonalizedProject(info: ProjectInfo) extends DefaultProject(info) {
     override def dependencyPath = "lib"
     override def outputDirectoryName = "bin" 
@@ -24,6 +50,8 @@ class FunCheckProject(info: ProjectInfo) extends ParentProject(info) {
     override def mainScalaSourcePath = "src" / "funcheck"
     override def unmanagedClasspath = super.unmanagedClasspath +++ purescala.jarPath
     override def mainResourcesPath   = "resources" / "funcheck"
+
+
   }
   class MultisetsProject(info: ProjectInfo) extends PersonalizedProject(info) {
     override def outputPath = "bin" / "multisets"
-- 
GitLab