Use sbt-native-image

This commit is contained in:
InversionSpaces 2023-06-13 16:51:11 +00:00 committed by Nick Pavlov
parent e56f5df835
commit eebb35fa55
3 changed files with 9 additions and 3 deletions

View File

@ -214,18 +214,20 @@ lazy val compiler = crossProject(JVMPlatform, JSPlatform)
lazy val `compiler-native-lib` = project
.in(file("compiler-native-lib"))
.enablePlugins(GraalVMNativeImagePlugin)
.enablePlugins(NativeImagePlugin)
.settings(commons: _*)
.settings(
Compile / mainClass := Some("aqua.compiler.Library"),
graalVMNativeImageOptions ++= Seq(
nativeImageVersion := "22.1.0",
nativeImageOptions ++= Seq(
"--verbose",
"--no-fallback",
"--shared", // Produce shared library
"--initialize-at-run-time=aqua.logging.LogFormatter$"
// Uncomment next lines to use llvm backend
// and obtain bitcode files
// "-H:CompilerBackend=llvm",
// "-H:TempDirectory=temp", // Directory with bc files
"--shared" // Produce shared library
)
)
.dependsOn(`aqua-api`.jvm)

View File

@ -10,6 +10,7 @@ import cats.effect.unsafe.implicits.global
import aqua.api.{APICompilation, AquaAPIConfig}
import aqua.backend.api.APIBackend
import aqua.logging.LogFormatter
// This is neede for @static to work in object
class Library {}
@ -26,6 +27,8 @@ object Library {
): Int = {
val code = CTypeConversion.toJavaString(codePointer)
LogFormatter.initLogger(Some(scribe.Level.Info))
val result = APICompilation
.compileString(
code,

View File

@ -2,4 +2,5 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.5")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.15.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.4")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0")