Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify Non-Standard Source Folder

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?

like image 334
Woodrow Barlow Avatar asked Jun 18 '15 17:06

Woodrow Barlow


1 Answers

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

like image 176
oli_obk Avatar answered Oct 04 '22 19:10

oli_obk