Skip to content

Commit

Permalink
Use sbt-native-image
Browse files Browse the repository at this point in the history
  • Loading branch information
InversionSpaces committed Jun 13, 2023
1 parent 2f5e240 commit bcf4c81
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -26,6 +27,8 @@ object Library {
): Int = {
val code = CTypeConversion.toJavaString(codePointer)

LogFormatter.initLogger(Some(scribe.Level.Info))

val result = APICompilation
.compileString(
code,
Expand Down
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16")
addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.4")

0 comments on commit bcf4c81

Please sign in to comment.