https://github.com/ralpha/dfhack_rust_plugin
Proof of concept DFHack plugin in Rust
https://github.com/ralpha/dfhack_rust_plugin
Last synced: 5 months ago
JSON representation
Proof of concept DFHack plugin in Rust
- Host: GitHub
- URL: https://github.com/ralpha/dfhack_rust_plugin
- Owner: ralpha
- License: mit
- Created: 2020-05-04T01:58:12.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-04T02:06:01.000Z (about 6 years ago)
- Last Synced: 2025-07-27T15:53:32.258Z (11 months ago)
- Language: CMake
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rust in DFHack
This is an example project to show that Rust can be used in the [DFHack](https://github.com/DFHack/dfhack) C++ codebase.
This project is a plugin for DFHack.
Output from plugin:
```
[DFHack]# hellorust
Hello World from C++
From rust: Hello World, Rust here!!
From rust: 17
[DFHack]#
```
# Build
Step 1: Add or link the whole content of the repo in the `DFHack/dfhack/plugins` folder of you dfhack source code.

Step 2: Edit the `CMakeLists.custom.txt` file and add the line: `add_subdirectory(DFHack_Rust_plugin)` at the end.
This is the name of the folder. It will find the `CMakeLists.txt` file in that folder.
Step 3: Build DFhack as you always do. For example:
```
cd ./build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE:string=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=../../df_linux_0.47.04;
ninja install
```
More info about compiling DFHack: https://docs.dfhack.org/en/stable/docs/Compile.html
Step 4: Execute dfhack so it opens dwarf fortress. Example `./dfhack`
Step 5: Run in the DFHack terminal: `hellorust`
It should output this:
```
[DFHack]# hellorust
Hello World from C++
From rust: Hello World, Rust here!!
From rust: 17
[DFHack]#
```
It works :)
# Troubleshooting
If you change the Rust code it might, as it did for me not recompile if there are changes make to the files.
You might have to recompile rust yourself.
Move to the `dfplugin_test` folder and use `cargo build` and `cargo build --release` to update the dev and release build.
If that does not work try: `cargo build --lib` and `cargo build --lib --release`