TL; DR: Bug 1231764 has landed on mozilla-central; the build system
now invokes cargo to build all the Rust code in m-c. This should
result in a better Rust developer experience, as well as making it
easier to import Rust libraries into m-c.
For gritty details, read on.
If you have new Rust libraries that code in libxul calls directly,
then you should add the appropriate |extern crate| lines in
toolkit/library/rust/lib.rs ("libgkrust"), and those libraries as
dependencies in toolkit/library/rust/Cargo.toml. If you want to call
code in the "e10s" crate, you would add:
extern crate e10s;
to toolkit/library/rust/lib.rs; you would also need to specify the
path to that crate in the dependencies section of
toolkit/library/rust/Cargo.toml:
[dependencies]
e10s = { path = "../../../path/from/srcdir/e10s" }
The e10s crate must also be checked into the tree at the appropriate
path. If the e10s crate depends on any libraries, their sources must
also be checked into the tree, and e10s's Cargo.toml must have |path|
attributes for each of its dependencies. And so on. (This is
somewhat tedious to do on library import, but cargo features are
coming that will do this all automagically. [1]) The build system
should complain if you forget to add |path| attributes; our automation
builds are also using nightly builds of cargo (but not rustc) with
--frozen[2] to ensure that the network doesn't get touched.
Cargo.lock files have also been checked in, so you will need to update
those as well when appropriate.
Crates for unit tests can be added in a similar fashion to the files
in toolkit/library/gtest/rust/.
If your crate has optional features that aren't normally turned on,
you are strongly encouraged to remove dependencies for those features
when importing code so the build system doesn't require that (unused)
code to live in-tree. We currently do not support features for
libgkrust, but the stylo team has expressed interest in this and it
would not be too hard to add.
The build system will check that there's only one copy of a given
crate in a build; this was a deliberate decision to try and avoid code
bloat in libxul. If this turns out to be a serious problem in
practice, we can look into ways of relaxing that check.
Please file bugs if things don't work as you expect, or you have ideas
on how things can work better.
Happy hacking,
-Nathan
[1] https://github.com/rust-lang/cargo/pull/2857
[2] https://github.com/rust-lang/cargo/pull/2811
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform