sbt plugin¶
sbt-godot-scala-native is the only build dependency a game project declares.
resolvers += "jitpack" at "https://jitpack.io"
addSbtPlugin("com.github.optical002.godot-scala-native" % "sbt-godot-scala-native" % "<version>")
lazy val game = (project in file("."))
.enablePlugins(GodotScalaNativePlugin)
.settings(
scalaVersion := "3.8.1",
godotProjectDir := baseDirectory.value / ".." / "godot"
)
The plugin must be enabled explicitly. It requires and enables Scala Native's
ScalaNativePlugin.
Settings¶
| Key | Type | Default | Meaning |
|---|---|---|---|
godotProjectDir |
File |
none (required) | Godot project root. The library goes to <dir>/.scala/ and the manifest to <dir>/. |
godotEntrySelfTest |
Boolean |
false |
Run the binding's internal self-tests once at scene init. |
godotLibName |
String |
scala-native-gdextension |
Library base name, without the lib prefix or extension. |
godotManifestName |
String |
scala.gdextension |
File name of the generated manifest. |
godotCompatibilityMinimum |
String |
4.2 |
compatibility_minimum written into the manifest. |
godotNativeMode |
String |
releaseFast |
Scala Native build mode: releaseFast, releaseFull, or debug. See Performance. |
Tasks¶
| Task | What it does |
|---|---|
godotBuild |
Runs nativeLink, swaps the library into <godotProjectDir>/.scala/, rewrites the manifest if it changed, and installs the editor plugin on first run. |
godotManifest |
Writes only the .gdextension manifest. |
Use sbt "~godotBuild" to rebuild on every save.
What the plugin configures for you¶
- Binding dependency. It adds
scala-native-gdextensionat the plugin's own version, plus the JitPack resolver. The plugin and the binding always move together. - Scala Native settings. It builds a dynamic library with the Boehm GC,
multithreading disabled, and the optimizer level from
godotNativeMode(releaseFastby default). - Class scanner. On every compile it generates
GeneratedRegistrationsandGeneratedEntryundertarget/src_managed. The GDExtension entry symbol is fixed asgodot_scala_init. - Manifest. It writes a
.gdextensionfile withreloadable = trueand library entries for Linux x86_64, macOS (x86_64 and arm64), and Windows x86_64.
No system threads
Multithreading is forced off because Boehm in multithreaded mode crashes at
extension load on Windows, and Scala Native's default GC corrupts the heap
under Godot's _process. Do not start java.lang.Threads from game code.
Do all work on Godot's main thread.
Generated manifest¶
[configuration]
entry_symbol = "godot_scala_init"
compatibility_minimum = 4.2
reloadable = true
[libraries]
linux.debug.x86_64 = "res://.scala/libscala-native-gdextension.so"
linux.release.x86_64 = "res://.scala/libscala-native-gdextension.so"
macos.debug = "res://.scala/libscala-native-gdextension.dylib"
macos.release = "res://.scala/libscala-native-gdextension.dylib"
windows.debug.x86_64 = "res://.scala/scala-native-gdextension.dll"
windows.release.x86_64 = "res://.scala/scala-native-gdextension.dll"
The manifest is regenerated by the build, so do not edit it by hand. To change it, change the settings above.
Shipping for several platforms¶
Scala Native does not cross-compile. Run godotBuild on each target OS and
collect the libraries into godot/.scala/. The manifest already lists all of
them, and Godot picks the right one at load time.