aboutsummaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2014-04-18 13:57:44 +0200
committerJakob Odersky <jodersky@gmail.com>2014-04-18 13:57:44 +0200
commit7e92a73f8b306ded5c875cd2366f73deeeaade59 (patch)
tree2f0444e2540b0787902379d1c3b145e194bf5dd6 /project
parentdd8b3b9b5095035d35ea4e5f0dcd69cbb99ca448 (diff)
downloadakka-serial-7e92a73f8b306ded5c875cd2366f73deeeaade59.tar.gz
akka-serial-7e92a73f8b306ded5c875cd2366f73deeeaade59.tar.bz2
akka-serial-7e92a73f8b306ded5c875cd2366f73deeeaade59.zip
start re-implementing fat jar build
Diffstat (limited to 'project')
-rw-r--r--project/FlowBuild.scala5
-rw-r--r--project/nativeFat.scala69
2 files changed, 74 insertions, 0 deletions
diff --git a/project/FlowBuild.scala b/project/FlowBuild.scala
index cce9ea3..e7a21d7 100644
--- a/project/FlowBuild.scala
+++ b/project/FlowBuild.scala
@@ -2,6 +2,7 @@ import sbt._
import Keys._
import JniKeys._
import UniqueVersionKeys._
+import NativeKeys._
object FlowBuild extends Build {
@@ -70,6 +71,10 @@ object FlowBuild extends Build {
compileOrder in Compile := CompileOrder.Mixed,
libraryDependencies += Dependencies.akkaActor
)
+ settings(NativeDefaults.settings: _*)
+ settings(
+ nativeBuildDirectory := (baseDirectory in ThisBuild).value / "flow-native"
+ )
)
lazy val samplesTerminal = (
diff --git a/project/nativeFat.scala b/project/nativeFat.scala
new file mode 100644
index 0000000..55df06d
--- /dev/null
+++ b/project/nativeFat.scala
@@ -0,0 +1,69 @@
+import sbt._
+import Keys._
+import java.io.File
+
+object NativeKeys {
+
+ val nativeBuildDirectory = settingKey[File]("Directory containing native build scripts.")
+ val nativeTarget = settingKey[File]("Target directory to store native artifacts.")
+
+ val nativeBuild = taskKey[File]("Invoke native build.")
+
+ val nativePackUnmanaged = settingKey[File]("")
+}
+
+object NativeDefaults {
+ import NativeKeys._
+
+ val nativeBuildImpl = Def.task {
+ val log = streams.value.log
+ val build = nativeBuildDirectory.value
+ val target = nativeTarget.value
+
+ val configure = Process(
+ "./configure " +
+ "--prefix=" + target.getAbsolutePath + " " +
+ "--libdir=" + target.getAbsolutePath,
+ Some(build))
+
+ val make = Process("make", build)
+
+ val makeInstall = Process("make install", build)
+
+ val ev = configure #&& make #&& makeInstall ! log
+ if (ev != 0)
+ throw new RuntimeException(s"Building native library failed.")
+
+ (target ** ("*.la")).get.foreach(_.delete())
+
+ target
+ }
+
+
+ val mappingsImpl = Def.task {
+ val files = (nativeBuild.value ** "*").get
+ val unamanagedDir = nativePackUnmanaged.value
+
+ val managed: Seq[(File, String)] = for (file <- files; if file.isFile) yield {
+ file -> ("native/" + (file relativeTo nativeTarget.value).get.getPath)
+ }
+
+ val unmanaged: Seq[(File, String)] = for (file <- (unamanagedDir ** "*").get; if file.isFile) yield {
+ file -> ("native/" + (file relativeTo unamanagedDir).get.getPath)
+ }
+
+ managed ++ unmanaged
+ }
+
+ def os = System.getProperty("os.name").toLowerCase.filter(_ != ' ')
+ def arch = System.getProperty("os.arch").toLowerCase
+
+ val settings: Seq[Setting[_]] = Seq(
+ nativeTarget := target.value / "native" / (os + "-" + arch),
+ nativeBuild := nativeBuildImpl.value,
+ nativePackUnmanaged := baseDirectory.value / "lib_native",
+ mappings in (Compile, packageBin) ++= mappingsImpl.value
+ )
+
+}
+