diff options
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | project/FlowBuild.scala | 5 | ||||
-rw-r--r-- | project/nativeFat.scala | 69 |
3 files changed, 75 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 389d80b..81a7a56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,8 @@ Version 2.0 - Use of direct buffers to increase performance when receiving and transmititng data. - Remove need to register to receive incoming data from an operator. A port is now opened by a client who will be the sole actor to receive messages from the operator. -- Migrate native build to makefile (C compiler is not called through sbt anymore). +- Migrate native build to Autotools (C compiler is not called through sbt anymore). - Add debian packaging. -- Drop option for creating fat jars (flow-pack). - Downgrade Akka dependency to 2.2.0, for use with Play! projects. Version 1.2 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 + ) + +} + |