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?
Specify Non-Standard Source Folder
2.8k views Asked by Woodrow Barlow At
1
To manually set the path to your
lib.rsyou can create a[lib]section in yourCargo.tomland setpathtosrc/rust/lib.rs. The relevant Documentation can be found here: http://doc.crates.io/manifest.html#configuring-a-targetFor the output, you can set the environment variable
CARGO_TARGET_DIRtoout. Relevant documentation can be found here: http://doc.crates.io/config.html#environment-variablesOr you can create a
.cargo/configfile (also atoml-file, but no file extension) and add a[build]section with the keytarget-dirset toout. Relevant documentation can be found here: http://doc.crates.io/config.html#configuration-keys