Created
October 13, 2011 04:43
-
-
Save aolshevskiy/1283401 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import classpath._ | |
import Keys._ | |
import com.github.siasia._ | |
import WebPlugin._ | |
object TestBuild extends Build { | |
lazy val natives = SettingKey[Seq[File]]("natives") | |
lazy val nativeLoader = AttributeKey[ClassLoader]("native-loader") | |
def createNativeLoader(state: State, version: String, launcher: xsbti.Launcher, natives: Seq[File], nativeTemp: File) = { | |
val provider = launcher.getScala(version) | |
state.put(nativeLoader, ClasspathUtilities.toLoader(natives, provider.loader, Map(), nativeTemp)) | |
} | |
def scalaInstanceTask = (state, scalaVersion, appConfiguration) map { | |
(state, version, app) => | |
val provider = app.provider.scalaProvider.launcher.getScala(version) | |
val loader = state.get(nativeLoader).get | |
new ScalaInstance(version, loader, provider.libraryJar, provider.compilerJar, (provider.jars.toSet - provider.libraryJar - provider.compilerJar).toSeq, None) | |
} | |
def rootSettings = Seq( | |
natives := Seq( | |
file("/usr/lib/libswt-gtk-3738.so"), | |
file("/usr/lib/libswt-pi-gtk-3738.so"), | |
file("/usr/share/java/swt.jar") | |
), | |
onLoad in GlobalScope <<= (onLoad in GlobalScope, scalaVersion, appConfiguration, natives, taskTemporaryDirectory) { | |
(onLoad, version, app, natives, temp) => | |
(state) => | |
val launcher = app.provider.scalaProvider.launcher | |
onLoad(createNativeLoader(state, version, launcher, natives, temp)) | |
}, | |
scalaInstance <<= scalaInstanceTask, | |
unmanagedJars in Compile <++= (natives) map { ns => ns } | |
) | |
lazy val root = Project("root", file(".")) settings(rootSettings :_*) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment