Using rust as a part of bigger project


#1

Hello,

I’m looking for the best way to use libraries and apps written in rust to be a part of big (multi-language) project. Suppose I have a project with its own build system (we are using OMakefile, but it does not matter), which consists of thousands of files, some of them are auto-generated. The libraries are built and used by other parts of the project. I also want to use some crates from cargo.io (and, probably, create my owns).
the problems, as I see them, are:

  • how to force cargo to rebuild the crate when some static C library has been changed
  • how to force (re)compilation of the crate producing a library that is used by the app written in other language (that is, how to express the fact that an app is dependent of the crate)
  • is there a tool that would extract “extern fn” definitions from rust code to generate .h file to use in C, and vice versa?

Thanks,
Valentyn.


#2

I believe this will be REALLY helpful:
http://doc.crates.io/build-script.html


#3

surely, this is a nice feature, but it is very rust-centric. In our case, there is a whole set of dependencies that need to be satisfied (and some files to be generated) to build the external libraries for a particular rust library. Using build.rs is equivalent to calling external make for each of the libraries to be built (or repeating the logic of Makefiles in the build.rs itself), which is unacceptable.

Actually, what we need is something like OCaml packages that we generate as a part of the build process itself. I think I know how to reproduce this kind of logic with rust libraries, but not with cargo (which is a pity).


#4

There’s always the option of invoking rustc directly rather than cargo for crates that are part of your project, leaving cargo for third party crates.io crates, which presumably don’t themselves need to link against your static C libraries.

rust-bindgen translates from .h to .rs; don’t think a tool currently exists to go the other way around.


#5

yes, that’s what I thought. Probably the only missing feature for me is some kind of
cargo install
command, and an argument (or envvar) to cargo that would allow to specify the path to locally installed rust libraries (like OCAMLPATH setting in OCaml).

Thank you for the link to rust-bindgen.