I am writing a multi-language project (a Java library which loads and calls Rust functions through the FFI), and so I want to divide my code files up a little bit. Rather than just putting everything in src
, I've made folders src/rust
and src/java
. How can I tell Cargo that my lib.rs
file (and all of my other source files) is in src/rust
rather than src
? Additionally, how can I tell it to output to out/rust
rather than target
?
To manually set the path to your lib.rs
you can create a [lib]
section in your Cargo.toml
and set path
to src/rust/lib.rs
. The relevant Documentation can be found here: http://doc.crates.io/manifest.html#configuring-a-target
For the output, you can set the environment variable CARGO_TARGET_DIR
to out
. Relevant documentation can be found here: http://doc.crates.io/config.html#environment-variables
Or you can create a .cargo/config
file (also a toml
-file, but no file extension) and add a [build]
section with the key target-dir
set to out
. Relevant documentation can be found here: http://doc.crates.io/config.html#configuration-keys
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With