project cleaning

This commit is contained in:
vms 2019-10-11 02:01:25 +03:00
parent fab3563928
commit 1521833eed
5 changed files with 48 additions and 24 deletions

View File

@ -24,7 +24,7 @@ rustup: &rustup
- run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2019-09-23
~/.cargo/bin/rustup toolchain install nightly-2019-09-23 # in case some other toolchain was already installed
~/.cargo/bin/rustup target add wasm32-unknown-unknown --toolchain nightly-2019-09-23
~/.cargo/bin/cargo install cross
version: 2
jobs:

View File

@ -1,19 +1,22 @@
import SbtCommons._
import ch.jodersky.sbt.jni.plugins.JniPackage.autoImport._
name := "frank"
commons
skip in publish := false // skip the root project to be published
/* Projects */
lazy val `vm-rust` = (project in file("src/main/rust/"))
lazy val `vm-rust` = (project in file("src/main/rust"))
.settings(
skip in publish := true,
compileFrankVMSettings()
)
lazy val `vm-llamadb` = (project in file("src/it/resources/llamadb"))
.settings(
skip in publish := true,
downloadLlamadb()
)
@ -31,23 +34,7 @@ lazy val `vm-scala` = (project in file("."))
scodecCore,
mockito
),
enableNativeCompilation := false,
resourceGenerators in Compile += Def.task {
val managedResource = s"${(resourceManaged in Compile).value}/native"
val darwin_lib = new File(managedResource + "/x86_64-darwin/libfrank.dylib")
val linux_lib = new File(managedResource + "/linux_x86_64/libfrank.so")
IO.copyFile(
new File(s"${file("").getAbsolutePath}/src/main/rust/target/release/libfrank.dylib"),
darwin_lib
)
IO.copyFile(
new File(s"${file("").getAbsolutePath}/src/main/rust/target/x86_64-unknown-linux-gnu/release/libfrank.so"),
linux_lib
)
Seq(darwin_lib, linux_lib)
}.taskValue,
nativeResourceSettings(),
assemblyJarName in assembly := "frank.jar",
assemblyMergeStrategy in assembly := SbtCommons.mergeStrategy.value,
test in assembly := {},

View File

@ -2,9 +2,11 @@ import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport.headerLicense
import de.heikoseeberger.sbtheader.License
import org.scalafmt.sbt.ScalafmtPlugin.autoImport.scalafmtOnCompile
import sbt.Keys.{javaOptions, _}
import sbt.{Def, addCompilerPlugin, _}
import java.io.File
import sbt.{Def, IO, addCompilerPlugin, _}
import sbtassembly.AssemblyPlugin.autoImport.assemblyMergeStrategy
import sbtassembly.{MergeStrategy, PathList}
import bintray.BintrayKeys._
import scala.sys.process._
@ -24,7 +26,11 @@ object SbtCommons {
startYear := Some(2019),
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt")),
headerLicense := Some(License.ALv2("2019", organizationName.value)),
resolvers += Resolver.bintrayRepo("fluencelabs", "releases"),
publishMavenStyle := true,
scalafmtOnCompile := true,
bintrayOrganization := Some("fluencelabs"),
bintrayRepository := "releases",
resolvers ++= Seq(Resolver.bintrayRepo("fluencelabs", "releases"), Resolver.sonatypeRepo("releases")),
scalafmtOnCompile := true,
// see good explanation https://gist.github.com/djspiewak/7a81a395c461fd3a09a6941d4cd040f2
scalacOptions ++= Seq("-Ypartial-unification", "-deprecation"),
@ -59,6 +65,7 @@ object SbtCommons {
val projectRoot = file("").getAbsolutePath
val frankFolder = s"$projectRoot/src/main/rust"
val localCompileCmd = s"cargo +$rustToolchain build --manifest-path $frankFolder/Cargo.toml --release --lib"
// TODO: cross build with manifest path doesn't work - so it needs to explicitly change a directory
val crossCompileCmd = s"cd $frankFolder ; cross build --target x86_64-unknown-linux-gnu --release --lib"
assert((localCompileCmd !) == 0, "Frank VM native compilation failed")
@ -79,6 +86,36 @@ object SbtCommons {
.value
)
def nativeResourceSettings(): Seq[Def.Setting[_]] =
Seq(
resourceGenerators in Compile += Def.task {
val managedResource = s"${(resourceManaged in Compile).value}/native"
val darwinLib = new File(managedResource + "/x86_64-darwin/libfrank.dylib")
val linuxLib = new File(managedResource + "/linux_x86_64/libfrank.so")
IO.copyFile(
new File(s"${file("").getAbsolutePath}/src/main/rust/target/x86_64-unknown-linux-gnu/release/libfrank.so"),
linuxLib
)
System.getProperty("os.name").toLowerCase match {
case os if os.contains("linux") => linuxLib :: Nil
case os if os.contains("mac") => {
IO.copyFile(
new File(s"${file("").getAbsolutePath}/src/main/rust/target/release/libfrank.dylib"),
darwinLib
)
linuxLib :: darwinLib :: Nil
}
case os {
new RuntimeException(s"$os is unsupported, only *nix and MacOS OS are supported now")
Nil
}
}
}.taskValue
)
def downloadLlamadb(): Seq[Def.Setting[_]] =
Seq(
publishArtifact := false,

View File

@ -7,3 +7,5 @@ addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
addSbtPlugin("ch.jodersky" % "sbt-jni" % "1.3.4")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")

View File

@ -64,8 +64,6 @@ trait WasmVm {
}
object WasmVm {
val javaLibPath: String = System.getProperty("java.library.path")
println(s"java.library.path = $javaLibPath")
/**
* Main method factory for building VM.