Skip to content

Commit

Permalink
Add golemScalaOutputDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
danieletorelli committed May 8, 2024
1 parent 8463f5b commit f1f6de3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
17 changes: 15 additions & 2 deletions src/main/scala/cloud/golem/GolemScalaPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@ import sbt.plugins.JvmPlugin

object GolemScalaPlugin extends AutoPlugin {
object autoImport {
lazy val golemScalaWitPath = settingKey[File]("Path to the wit file")
lazy val golemScalaPackageName = settingKey[String]("Package name")
lazy val golemScalaOutputDirectory = SettingKey[File](
"golemScalaOutputDirectory",
"Output directory",
KeyRanks.Invisible
)
lazy val golemScalaWitPath = SettingKey[File](
"golemScalaWitPath",
"Path to the wit file",
KeyRanks.Invisible
)
lazy val golemScalaPackageName = SettingKey[String](
"golemScalaPackageName",
"Package name",
KeyRanks.Invisible
)
lazy val witBindgen =
taskKey[Unit]("Runs golem-scalajs-wit-bindgen to generate WIT bindings")
lazy val component =
Expand Down
3 changes: 3 additions & 0 deletions src/main/scala/cloud/golem/GolemScalaPluginInternal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ private[golem] object GolemScalaPluginInternal {

lazy val baseSettings: Seq[Setting[?]] =
Def.settings(
golemScalaOutputDirectory := (ThisBuild / target).value / "dist",
golemScalaWitPath := (ThisBuild / baseDirectory).value / "wit",
golemScalaPackageName := "main",
witBindgen := {
Expand All @@ -36,6 +37,8 @@ private[golem] object GolemScalaPluginInternal {
lazy val scalaJsSettings: Seq[Setting[?]] =
Def.settings(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) },
Compile / fullLinkJS / scalaJSLinkerOutputDirectory := golemScalaOutputDirectory.value,
Compile / fastLinkJS / scalaJSLinkerOutputDirectory := golemScalaOutputDirectory.value,
libraryDependencies += "cloud.golem" %% "golem-scala-macros" % Versions.macros
)

Expand Down
16 changes: 8 additions & 8 deletions src/sbt-test/golem-scala/example1/test
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
> +clean
> +fullLinkJS
$ exists target/scala-2.12/root-opt/main.js
$ exists target/scala-2.12/root-opt/main.js.map
$ exists target/scala-2.13/root-opt/main.js
$ exists target/scala-2.13/root-opt/main.js.map
$ exists target/dist/main.js
$ exists target/dist/main.js.map
$ exists target/dist/main.js
$ exists target/dist/main.js.map
> +clean
> +fastLinkJS
$ exists target/scala-2.12/root-fastopt/main.js
$ exists target/scala-2.12/root-fastopt/main.js.map
$ exists target/scala-2.13/root-fastopt/main.js
$ exists target/scala-2.13/root-fastopt/main.js.map
$ exists target/dist/main.js
$ exists target/dist/main.js.map
$ exists target/dist/main.js
$ exists target/dist/main.js.map
16 changes: 8 additions & 8 deletions src/sbt-test/golem-scala/example2/test
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
> +clean
> +fullLinkJS
$ exists target/scala-2.12/root-opt/main.js
$ exists target/scala-2.12/root-opt/main.js.map
$ exists target/scala-2.13/root-opt/main.js
$ exists target/scala-2.13/root-opt/main.js.map
$ exists target/dist/main.js
$ exists target/dist/main.js.map
$ exists target/dist/main.js
$ exists target/dist/main.js.map
> +clean
> +fastLinkJS
$ exists target/scala-2.12/root-fastopt/main.js
$ exists target/scala-2.12/root-fastopt/main.js.map
$ exists target/scala-2.13/root-fastopt/main.js
$ exists target/scala-2.13/root-fastopt/main.js.map
$ exists target/dist/main.js
$ exists target/dist/main.js.map
$ exists target/dist/main.js
$ exists target/dist/main.js.map

0 comments on commit f1f6de3

Please sign in to comment.