Code Monkey home page Code Monkey logo

dfhack_rust_plugin's Introduction

Rust in DFHack

This is an example project to show that Rust can be used in the 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. Showing the DFHack_Rust_plugin folder next to the diggingInvaders folder and others

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

dfhack_rust_plugin's People

Contributors

ralpha avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.