On 8/17/18 1:37 PM, Jan Beich wrote:
Emilio Cobos Álvarez <[email protected]>
writes:

Hi,

In bug 1478813 (now on inbound), I've added a new toolchain job and
code to install cbindgen[1] via `mach bootstrap`, and it will become a
hard build dependency in the near future.

We use it on the style system to generate C++ structs / enums from the
Rust definitions (as opposed to bindgen[2], which we use for the
opposite thing).

Some downstream questions:

Why bindgen is built as part of Firefox but cbindgen isn't? It's not hard
to package both cbindgen and bindgen but the inconsistency looks ad hoc.

The reason is somewhat nontrivial.

We can run cbindgen the same way as bindgen in theory (in the style system's build script), but the C++ headers it generates need to be available way earlier in the build process (because the headers need to be available for the rest of Gecko).

So using it from build.rs is not an option, because we'd need to move the whole style system build before export (which I suspect wouldn't work because of bindgen, plus it'd be really odd, and it'd slow down the build time a lot I guess).

We could theoretically vendor it and build it ourselves ensuring it's on the host, but as of right now there's no way to build a host rust crate before the export of a header that I know of. We have very limited support for that for C++ [1]. We can only build single-file C++ files and such.

Adding support for general crates.io crates to be built this way and appear somewhere on the objdir seemed way more build system hackery than what I could do in a reasonable timeframe with my limited knowledge of the build system. So requiring the binary to be there was the easiest way I got it to work.

That being said, if some build system peer is able to make something like that work, it'd be easy to switch to it if wanted.

How stable cbindgen output across versions? Would Firefox XY (e.g., ESR68)
still build with a version released a year after (in future)?

I think it should be reasonably stable (as in, existing options usually remain untouched and keep generating the same kind of code).

We can force a locked down version of cbindgen at configure / bootstrap time if needed to ensure it works if it's wanted.

Hope it answers your questions :)

Thanks,

 -- Emilio

[1]: https://searchfox.org/mozilla-central/rev/246f2b4fab2c1a6cca99418bc2e4d73d1102cc38/layout/style/test/moz.build#26
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to