aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2014-01-15 19:26:00 +0100
committerJakob Odersky <jodersky@gmail.com>2014-01-15 19:52:24 +0100
commit9d1cd57430417c8923b9727542608ac34008fa27 (patch)
treeecbd0cc42ee2b29779397ba471527a56b16507fa
parent25f3fc727a10f65470981089eed26837c3f246fc (diff)
downloadakka-serial-9d1cd57430417c8923b9727542608ac34008fa27.tar.gz
akka-serial-9d1cd57430417c8923b9727542608ac34008fa27.tar.bz2
akka-serial-9d1cd57430417c8923b9727542608ac34008fa27.zip
implement fat jar generation
-rw-r--r--.gitignore2
-rw-r--r--project/FlowBuild.scala23
-rw-r--r--project/nativefat.scala43
3 files changed, 58 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 03cf618..5575b91 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,4 +20,4 @@ project/plugins/project/
# Native
*.o
*.so
-!/flow-binaries/*.so
+*.jnilib
diff --git a/project/FlowBuild.scala b/project/FlowBuild.scala
index fcf4d10..9ef9dd1 100644
--- a/project/FlowBuild.scala
+++ b/project/FlowBuild.scala
@@ -37,12 +37,14 @@ object FlowBuild extends Build {
publishLocal := ()
)
)
+
lazy val flow: Project = (
Project("flow", file("flow"))
settings (commonSettings: _*)
settings (JniDefaults.settings: _*)
settings (NativeDefaults.settings: _*)
+ settings (NativeFatDefaults.settings: _*)
settings (selectHost().settings: _*)
settings(
nativeIncludeDirectories += (sourceDirectory in Compile).value / "native" / "include",
@@ -56,14 +58,6 @@ object FlowBuild extends Build {
Dependencies.ioFile)
)
)
-
- lazy val samplesTerminal = (
- Project("flow-samples-terminal", file("flow-samples") / "flow-samples-terminal")
- settings(commonSettings: _*)
- settings(runSettings: _*)
- dependsOn(flow)
- )
-
//the current operating system used to run the native compile
trait Host{ def settings: Seq[Setting[_]] }
@@ -73,6 +67,7 @@ object FlowBuild extends Build {
val compiler = "gcc"
val linker = compiler
val cFlags = Seq("-O2", "-fPIC")
+
val linkerFlags = Seq("-shared", s"-Wl,-soname,libflow.so.${NativeMajorVersion}")
val binary = s"libflow.so"
@@ -130,5 +125,15 @@ object FlowBuild extends Build {
nativeLink := osError
)
}
- }
+ }
+
+
+ lazy val samplesTerminal = (
+ Project("flow-samples-terminal", file("flow-samples") / "flow-samples-terminal")
+ settings(commonSettings: _*)
+ settings(runSettings: _*)
+ dependsOn(flow)
+ )
+
+
}
diff --git a/project/nativefat.scala b/project/nativefat.scala
new file mode 100644
index 0000000..0cdf636
--- /dev/null
+++ b/project/nativefat.scala
@@ -0,0 +1,43 @@
+import sbt._
+import Keys._
+import NativeKeys._
+import java.io.File
+import scala.collection.mutable.HashSet
+
+object NativeFatKeys {
+ val packageFat = taskKey[File]("Create a fat jar containing native binaries.")
+ val packageFatSuffix = settingKey[String]("Suffix to add to name of fat jar.")
+ val packageFatUnmanaged = settingKey[File]("Directory containing any pre-compiled native binaries.")
+}
+
+object NativeFatDefaults {
+ import NativeFatKeys._
+
+ val mappingsImpl = Def.task {
+ val links = nativeLink.value
+ val unamanagedDir = packageFatUnmanaged.value
+
+ val managed: Seq[(File, String)] = for ( (build, binary) <- links.toSeq) yield {
+ binary -> ("native/" + build.name + "/" + binary.name)
+ }
+
+ val unmanaged: Seq[(File, String)] = for (file <- (unamanagedDir ** "*").get; if file.isFile) yield {
+ file -> ("native/" + (file relativeTo unamanagedDir).get.getPath)
+ }
+
+ managed ++ unmanaged
+ }
+
+ def settings = sbt.Defaults.packageTaskSettings(packageFat, sbt.Defaults.packageBinMappings) ++
+ Seq(
+ packageFatSuffix := "-fat",
+ packageFatUnmanaged := baseDirectory.value / "lib_native",
+ products in packageFat := (products in Compile).value,
+ artifact in packageFat := {
+ val prev = (artifact in packageBin).value
+ prev.copy(name = prev.name + packageFatSuffix.value)
+ },
+ mappings in packageFat ++= mappingsImpl.value
+ )
+
+} \ No newline at end of file