Just to set your expectations first:
- Only bundling for Windows and Linux is currently supported
- You must host your own build server
- 
 The build server provides no sandboxing or security against malicious extensions The build server provides no sandboxing or security against malicious extensions
Hey all! I’ve been working on a way to make use of Rust in native extensions for a while and it’s now in a state that I consider to be ready for release! This project is split up into a few different parts:
- defold-rs - Rust bindings to dmSDK and test project for new bindings
- defold-rs-extender - Custom build server
- defold-rs-template - Rust port of the native extension template
It works the same way as regular C/C++ extensions: everything is done on the build server and you only need the standard Defold editor to build games. For writing Rust code, you’ll want to use VSCode (or your favorite LSP-compatible IDE) with rust-analyzer installed.
These extensions are full Cargo projects. The main benefit being that you can use any of the Rust libraries on crates.io in your Defold game just by listing them in your Cargo.toml. Theoretically, you could even write a game with the Bevy game engine and embed it into a Defold project!
Getting started
- Download and run the build server
- The process is (mostly) the same as normal
 
- Make a copy of the template project
- In the editor, set File > Preferences > Extensions > Build Serverto the URL of the build server- This should be http://localhost:9000if you’re running the server on your computer
 
- This should be 
- Open up /myextension/src(the folder containingCargo.toml) in your IDE of choice
- Once you’re done writing your extension, just press build in Defold as always
- Rust extensions will take much longer to build at first than C++, since it needs to compile several dependencies for the bindings
 
Project Status
Supported Platforms
- 
 Windows Windows
- 
 Linux Linux
- 
 macOS macOS
- 
 HTML5 HTML5
- 
 iOS iOS
- 
 Android Android
- 
 PS4/PS5 PS4/PS5
- 
 Nintendo Switch Nintendo Switch- Rust actually supports compiling for Switch, but it doesn’t include the standard library
 
Features
- 
 Template project Template project
- 
dmSDK bindings
- 
 Extension and Lua module registering Extension and Lua module registering
- 
 Crate documentation Crate documentation
- 
 Complete API coverage Complete API coverage
- 
 Handle multiple versions of Defold Handle multiple versions of Defold
 
- 
- 
Build server
- 
 Compile and link Cargo projects Compile and link Cargo projects
- 
 Cache artifacts between builds Cache artifacts between builds
- 
 Sandbox build-time code Sandbox build-time code- 
cargo-rubberandsccacheare good examples
 
- 
- 
 Public instance Public instance- Not likely to happen, at least not one hosted by me
 
 
- 
 After
  After 

 
 
 britzl:
 britzl: Potota:
 Potota: 
 
 .
 . ) . I’m also pretty happy with how the conversion from pointers to structs went as it was something I thought about early on in the project but didn’t know how to do. Since I make absolutely no guarantees about backwards compatibility, expect to see more of that coming to current and future modules!
) . I’m also pretty happy with how the conversion from pointers to structs went as it was something I thought about early on in the project but didn’t know how to do. Since I make absolutely no guarantees about backwards compatibility, expect to see more of that coming to current and future modules!