aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--flow-binaries/linux/amd64/libflow.so.1.0bin0 -> 13624 bytes
-rw-r--r--project/Build.scala52
3 files changed, 43 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index 2112789..03cf618 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,7 +15,9 @@ project/plugins/project/
.project
.classpath
.cache
+.history
# Native
*.o
*.so
+!/flow-binaries/*.so
diff --git a/flow-binaries/linux/amd64/libflow.so.1.0 b/flow-binaries/linux/amd64/libflow.so.1.0
new file mode 100644
index 0000000..40bb343
--- /dev/null
+++ b/flow-binaries/linux/amd64/libflow.so.1.0
Binary files differ
diff --git a/project/Build.scala b/project/Build.scala
index feab279..d80e0f4 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -11,7 +11,8 @@ object FlowBuild extends Build {
val Version = "1.0-SNAPSHOT" //version of flow library
val BinaryMajorVersion = 1 //binary major version used to select so's and dlls when publishing (needs to be incremented if API changes are made to flow.h or NativeSerial.java)
val ScalaVersion = "2.10.1"
-
+ //see native settings down below
+
lazy val commonSettings: Seq[Setting[_]] = Seq(
organization := Organization,
version := Version,
@@ -22,8 +23,7 @@ object FlowBuild extends Build {
lazy val runSettings: Seq[Setting[_]] = Seq(
fork := true,
connectInput in run := true)
-
-
+
lazy val main: Project = (
Project("flow-main", file("flow-main"))
settings (commonSettings: _*)
@@ -33,8 +33,8 @@ object FlowBuild extends Build {
Dependencies.ioCore,
Dependencies.ioFile),
compileOrder in Compile := CompileOrder.Mixed,
- resourceGenerators in Compile <+= (resourceManaged in Compile, link in Native in LocalProject("flow-native-linux")) map { (resDir, binary) =>
- val file = resDir / "native" / sys.props("os.name").toLowerCase / sys.props("os.arch").toLowerCase / binary.getName
+ resourceGenerators in Compile <+= (resourceManaged in Compile, link in Native in getOsProject) map { (resDir, binary) =>
+ val file = canonicalBinaryPath(resDir / "native", binary.getName)
IO.copyFile(binary, file)
Seq(file)
}
@@ -50,24 +50,44 @@ object FlowBuild extends Build {
//--- native settings --------------------------------------------------
+
+ def getOsProject = {
+ sys.props("os.name").toLowerCase match {
+ case "linux" => LocalProject("flow-native-linux") //use local project to avoid stackoverflow on cyclic dependencies
+ case _ => throw new Exception("There is no native project defined for your current OS." +
+ " Have a look at the project flow-native-linux to see how to create one yourself. You may ignore this error by commenting " +
+ "the relevant lines in project/Build.scala, however by doing so, compiling native sources may miserably fail!")
+ }
+ }
+
+ def canonicalBinaryPath(base: File, binaryName: String) = {
+ base / sys.props("os.name").toLowerCase / sys.props("os.arch").toLowerCase / binaryName
+ }
+
+ val publishNative = taskKey[File]("Publish native binary compiled on current OS to flow-binaries project so that it may be packaged in a distribution of flow.")
+ val publishNativeImpl = Def.task{
+ val in = (link in Native).value
+ val out = canonicalBinaryPath((baseDirectory in ThisBuild).value / "flow-binaries", in.getName)
+ IO.copyFile(in, out)
+ out
+ }
lazy val commonNativeSettings: Seq[Setting[_]] = Seq(
includeDirectories in Native += file("flow-native") / "shared" / "include",
nativeCompile in Native := ((nativeCompile in Native) dependsOn (compile in Compile in main)).value,
+ publishNative := publishNativeImpl.value,
javahClasspath := Seq((classDirectory in Compile in main).value),
javahClasses := Seq("com.github.jodersky.flow.internal.NativeSerial")) ++ Jni.defaultSettings
- //--- native unix like settings ----------------------------------------
+ //--- native unix-like settings ----------------------------------------
- val UnixBinaryName = "flow"
val UnixBinaryMinorVersion = 0
lazy val unixNativeSettings: Seq[Setting[_]] = commonNativeSettings ++ Seq(
flags in Native := Seq("-fPIC", "-O2"),
- linkFlags in Native ++= Seq("-shared", s"-Wl,-soname,lib${UnixBinaryName}.so.${BinaryMajorVersion}"),
- binaryName in Native := s"lib${UnixBinaryName}.so.${BinaryMajorVersion}.${UnixBinaryMinorVersion}",
- version := s"${BinaryMajorVersion}.${UnixBinaryMinorVersion}-${sys.props("os.name").toLowerCase}-${sys.props("os.arch").toLowerCase}",
+ linkFlags in Native ++= Seq("-shared", s"-Wl,-soname,libflow.so.${BinaryMajorVersion}"),
+ binaryName in Native := s"libflow.so.${BinaryMajorVersion}.${UnixBinaryMinorVersion}",
nativeSource in Native := baseDirectory.value / "src")
lazy val nativeLinux = (
@@ -76,7 +96,17 @@ object FlowBuild extends Build {
settings (
includeDirectories in Native += jdkHome.value / "include" / "linux"
)
- dependsOn (main)
+ dependsOn(main)
)
+ /* stub for native project on a mac, I don't know if this would actually work...
+ lazy val nativeMacOSX = (
+ NativeProject("flow-native-macosx", file("flow-native") / "unix")
+ settings (unixNativeSettings: _*)
+ settings (
+ includeDirectories in Native += jdkHome.value / "include" / "macosx"
+ )
+ dependsOn (main)
+ )*/
+
}