Fuchsia uses third-party Rust crates. They are placed in
//third-party/rust_crates/vendor. This set of crates is based on the dependencies listed in
//third_party/rust_crates/Cargo.toml. If you don't find a crate that you want to use, you may bring that into Fuchsia.
Roughly, it is a 3-step process.
Pay attention to transitive dependencies: A third-party crate may depend on other third-party crates. List all the new crates that end up with being brought in, in the OSRB review. For OSRB, follow the instructions under the “Process for 3rd Party Hosted Code” section in this document.
Note, one needs to get OSRB approval first before uploading a CL for review.
third_party/rust_crates/Cargo.tomlfor the crate you want to add.
fx update-rustc-third-partyThis will download all crates listed in
rust_crates/Cargo.tomlas well as their dependencies, place them in the
vendordirectory, and update
. Prerequisite: on Linux,pkg-config` needs to be installed.
fx set core.x64 && fx build
fx update-rustc-crate-map --output third_party/rust_crates/crate_map.jsonThis will update
crate_map.jsonwith information about the Rust crates available for each target (Fuchsia and host). Note that this step uses information from the build step - make sure that the build for the
third_partyfolder has succeeded first before running this command. This would be part of the
fx buildyou are expected to run in the previous step.
If the project requires importing a new third-party crate to handle functionality related to Unicode and internationalization, prefer crates from the UNIC project when available.
The following non-UNIC crates are already vendored and are grandfathered, but we will aim to migrate to UNIC equivalents when possible.
We should encourage upstream dependencies to migrate to UNIC as well.
UNIC crates have distinct advantages over other crates:
UNIC crates are developed in a single repo, with shared common code and a single version scheme.
UNIC crates are generated from a consistent set of Unicode data files.
The UNIC project is aiming for comprehensive feature coverage, to be like ICU for Rust. If the project succeeds, our dependencies on unrelated Unicode crates should be reduced over time.