From eebb35fa558febedc2f03a71d90d0a9bf16b2403 Mon Sep 17 00:00:00 2001 From: InversionSpaces Date: Tue, 13 Jun 2023 16:51:11 +0000 Subject: [PATCH] Use sbt-native-image --- build.sbt | 8 +++++--- .../src/main/scala/aqua/compiler/Library.scala | 3 +++ project/plugins.sbt | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 4cbd2459..889161b3 100644 --- a/build.sbt +++ b/build.sbt @@ -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) diff --git a/compiler-native-lib/src/main/scala/aqua/compiler/Library.scala b/compiler-native-lib/src/main/scala/aqua/compiler/Library.scala index 14985917..6a808690 100644 --- a/compiler-native-lib/src/main/scala/aqua/compiler/Library.scala +++ b/compiler-native-lib/src/main/scala/aqua/compiler/Library.scala @@ -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, diff --git a/project/plugins.sbt b/project/plugins.sbt index 7044eb9b..d7360d4d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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")