1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-14 14:46:43 +02:00
comprehensive-rust/src/chromium/adding-third-party-crates.md
Adrian Taylor 7f469fb2c7
Add Chromium section (#1479)
This is a contribution of a Chromium section for Comprehensive Rust.

---------

Co-authored-by: Nicole L <dlegare.1001@gmail.com>
Co-authored-by: Martin Geisler <martin@geisler.net>
2023-11-27 18:21:19 +00:00

1.1 KiB

Adding third party crates

Rust libraries are called "crates" and are found at crates.io. It's very easy for Rust crates to depend upon one another. So they do!

Property C++ library Rust crate
Build system Lots Consistent - Cargo.toml
Typical library size Large-ish Small
Transitive dependencies Few Lots

For a Chromium engineer, this has pros and cons:

  • All crates use a common build system so we can automate their inclusion into Chromium...
  • ... but, crates typically have transitive dependencies, so you will likely have to bring in multiple libraries.

We'll discuss:

  • How to put a crate in the Chromium source code tree
  • How to make gn build rules for it
  • How to audit its source code for sufficient safety.
All of the things in the table on this slide are generalizations, and counter-examples can be found. But in general it's important for students to understand that most Rust code depends on other Rust libraries, because it's easy to do so, and that this has both benefits and costs.