tree: 393095a69408964c4c34984d36a6b8e6b519867d
  1. addr2line/
  2. adler2/
  3. ahash/
  4. aho_corasick/
  5. android_system_properties/
  6. anstyle/
  7. antlr4rust/
  8. anyhow/
  9. arbitrary_int/
  10. array_init/
  11. autocfg/
  12. backtrace/
  13. base64/
  14. better_any/
  15. bincode/
  16. bincode_derive/
  17. bit_set/
  18. bit_vec/
  19. bitbybit/
  20. bitflags/
  21. bytemuck/
  22. bytemuck_derive/
  23. byteorder/
  24. byteorder_lite/
  25. bytes/
  26. calendrical_calculations/
  27. cc/
  28. cfg_aliases/
  29. cfg_if/
  30. chromium_crates_io/
  31. chrono/
  32. clap/
  33. clap_builder/
  34. clap_lex/
  35. cobs/
  36. codespan_reporting/
  37. const_format/
  38. const_format_proc_macros/
  39. const_panic/
  40. core_foundation_sys/
  41. core_maths/
  42. crc32fast/
  43. ctor/
  44. ctor_proc_macro/
  45. cxx/
  46. cxxbridge_cmd/
  47. cxxbridge_flags/
  48. cxxbridge_macro/
  49. derivre/
  50. diplomat/
  51. diplomat_core/
  52. diplomat_runtime/
  53. displaydoc/
  54. dtor/
  55. dtor_proc_macro/
  56. either/
  57. equivalent/
  58. erased_serde/
  59. fastbloom/
  60. fdeflate/
  61. fend_core/
  62. fixed_decimal/
  63. flate2/
  64. foldhash/
  65. font_types/
  66. fs2/
  67. getrandom/
  68. gimli/
  69. harfrust/
  70. hashbrown/
  71. heck/
  72. hex/
  73. hmac_sha256/
  74. hostname/
  75. iana_time_zone/
  76. icu_calendar/
  77. icu_calendar_data/
  78. icu_capi/
  79. icu_casemap/
  80. icu_casemap_data/
  81. icu_collections/
  82. icu_decimal/
  83. icu_decimal_data/
  84. icu_experimental/
  85. icu_experimental_data/
  86. icu_list/
  87. icu_list_data/
  88. icu_locale/
  89. icu_locale_core/
  90. icu_locale_data/
  91. icu_normalizer/
  92. icu_normalizer_data/
  93. icu_pattern/
  94. icu_plurals/
  95. icu_plurals_data/
  96. icu_properties/
  97. icu_properties_data/
  98. icu_provider/
  99. icu_provider_adapters/
  100. icu_time/
  101. image/
  102. incremental_font_transfer/
  103. indexmap/
  104. itertools/
  105. itoa/
  106. ixdtf/
  107. jiff_tzdb/
  108. jpeg_encoder/
  109. jxl/
  110. jxl_macros/
  111. jxl_simd/
  112. jxl_transforms/
  113. konst/
  114. konst_macro_rules/
  115. lazy_static/
  116. libafl/
  117. libafl_bolts/
  118. libafl_derive/
  119. libc/
  120. libm/
  121. litemap/
  122. llguidance/
  123. lock_api/
  124. log/
  125. mach2/
  126. memchr/
  127. meminterval/
  128. memo_map/
  129. memoffset/
  130. minijinja/
  131. miniz_oxide/
  132. moxcms/
  133. murmur3/
  134. nix/
  135. num_bigint/
  136. num_complex/
  137. num_derive/
  138. num_enum/
  139. num_enum_derive/
  140. num_integer/
  141. num_rational/
  142. num_traits/
  143. object/
  144. once_cell/
  145. ordered_float/
  146. parking_lot/
  147. parking_lot_core/
  148. png/
  149. postcard/
  150. potential_utf/
  151. primal_check/
  152. proc_macro2/
  153. prost/
  154. prost_derive/
  155. pxfm/
  156. qr_code/
  157. quote/
  158. rand_core/
  159. read_fonts/
  160. ref_cast/
  161. ref_cast_impl/
  162. regex/
  163. regex_automata/
  164. regex_lite/
  165. regex_syntax/
  166. resb/
  167. rustc_demangle/
  168. rustc_demangle_capi/
  169. rustfft/
  170. rustversion/
  171. ryu/
  172. safe_arch/
  173. scc/
  174. scopeguard/
  175. sdd/
  176. serde/
  177. serde_core/
  178. serde_derive/
  179. serde_json/
  180. serde_json_lenient/
  181. serial_test/
  182. serial_test_derive/
  183. sfv/
  184. shared_brotli_patch_decoder/
  185. simd_adler32/
  186. siphasher/
  187. skera/
  188. skrifa/
  189. small_ctor/
  190. smallvec/
  191. stable_deref_trait/
  192. static_assertions/
  193. strck/
  194. strength_reduce/
  195. strsim/
  196. strum/
  197. strum_macros/
  198. subtle/
  199. symphonia/
  200. symphonia_bundle_flac/
  201. symphonia_bundle_mp3/
  202. symphonia_codec_pcm/
  203. symphonia_codec_vorbis/
  204. symphonia_common/
  205. symphonia_core/
  206. symphonia_metadata/
  207. symphonia_utils_xiph/
  208. syn/
  209. synstructure/
  210. temporal_capi/
  211. temporal_rs/
  212. termcolor/
  213. thiserror/
  214. thiserror_impl/
  215. timezone_provider/
  216. tinystr/
  217. toktrie/
  218. transpose/
  219. tuple_list/
  220. typed_arena/
  221. typed_builder/
  222. typed_builder_macro/
  223. typed_path/
  224. typeid/
  225. typewit/
  226. tzif/
  227. uds/
  228. unicode_ident/
  229. unicode_width/
  230. unicode_xid/
  231. unty/
  232. utf16_iter/
  233. utf8_iter/
  234. uuid/
  235. version_check/
  236. virtue/
  237. wait_timeout/
  238. wide/
  239. winapi_util/
  240. windows_aarch64_msvc/
  241. windows_i686_msvc/
  242. windows_link/
  243. windows_sys/
  244. windows_targets/
  245. windows_x86_64_msvc/
  246. write16/
  247. write_fonts/
  248. writeable/
  249. xml/
  250. xxhash_rust/
  251. yoke/
  252. yoke_derive/
  253. zerocopy/
  254. zerofrom/
  255. zerofrom_derive/
  256. zeroize/
  257. zeroize_derive/
  258. zerotrie/
  259. zerovec/
  260. zerovec_derive/
  261. zip/
  262. zmij/
  263. zoneinfo64/
  264. zune_core/
  265. zune_jpeg/
  266. .clang-format
  267. DEPS
  268. OWNERS
  269. OWNERS-review-checklist.md
  270. PRESUBMIT.py
  271. README-importing-new-crates.md
  272. README.md
third_party/rust/README.md

Rust third-party code

This directory contains third-party Rust libraries from https://crates.io (and sometimes thin wrappers around them for Chromium interop).

gnrt: Cargo.toml => vendor + BUILD.gn + README.chromium

Third-party libraries from crates.io, depend on Cargo as a build system. Chromium uses gnrt tool to automate

  • Vendoring crates sources into Chromium repository
  • Generating BUILD.gn and README.chromium files based on crate's Cargo.toml.

The tool can be found in //tools/crates/gnrt and is typically invoked using //tools/crates/run_gnrt.py.

Directory structure for third-party crates

The directory structure for a crate “foo” version 3.4.2 is:

//third_party/
    rust/
        foo/
            wrapper/             (optional FFI glue or Chromium integration)
            v3/                  (version 3.4.2 maps to the v3 epoch)
                BUILD.gn         (generated by gnrt gen)
                README.chromium  (generated by gnrt vendor)
        chromium_crates_io/
            vendor/
                foo-v3/  (sources downloaded from crates.io by gnrt vendor)
            patches/
                foo-v3/  (patches automatically applied during gnrt vendor)
                    0001-Some-changes.diff
                    0002-Other-changes.diff
            Cargo.toml        (version and enabled features of "foo")
            Cargo.lock
            gnrt_config.toml  (additional configuration of "foo")

TODO(https://crbug.com/417250983): Patch directory should be epoch-specific.

Most of the files above are managed automatically by gnrt. The only “foo”-specific manually-authored files and directories are:

There are also other, non-crate-specific files such as:

  • //third_party/rust:
    • .md - this doc and other docs
    • OWNERS, PRESUBMIT.py
  • //third_party/rust/chromium_crates_io:
    • BUILD.gn.hbs - template for BUILD.gn files
    • README.chromium.hbs - template for README.chromium files
    • PRESUBMIT.py
    • .py helper scripts used by PRESUBMIT.py and by //tools/crates.
    • Somewhat obsolete cargo vet-support items - we keep supply-chain/audits.toml to preserve Chromium audits that are imported into https://github.com/google/rust-crate-audits/blob/main/sources.list)
    • Various infrastructure pieces to disable auto-formatting of the vendored files (e.g. .gitattributes, .rustfmt.toml, .style.yapf, etc.)

Importing new third-party crates

See //third_party/rust/README-importing-new-crates.md for instructions on how to import a crate from https://crates.io into Chromium.

Updating existing third-party crates

Third-party crates will get updated semi-automatically through the process described in ../tools/crates/create_update_cl.md. If you nevertheless need to manually update a crate to its latest minor or major version, then follow the steps below. To facilitate easier review, we recommend uploading separate patchsets for 1) manual changes, and 2) tool-driven, automated changes.

  1. Change directory to the root src/ dir of Chromium.
  2. Update the versions in //third_party/rust/chromium_crates_io/Cargo.toml.
    • vpython3 ./tools/crates/run_gnrt.py update <crate name>.
    • Under the hood this invokes cargo update and accepts the same command line parameters. In particular, you may need to specify --breaking when working on major version updates.
  3. Download any updated crate's files:
    • ./tools/crates/run_gnrt.py vendor
  4. Add the downloaded files to git:
    • git add -f third_party/rust/chromium_crates_io/vendor
    • The -f is important, as files may be skipped otherwise from a .gitignore inside the crate.
  5. Generate the BUILD.gn files
    • vpython3 ./tools/crates/run_gnrt.py gen
    • Or, directly through (nightly) cargo: cargo run --release --manifest-path tools/crates/gnrt/Cargo.toml --target-dir out/gnrt gen
  6. Add the generated files to git:
    • git add third_party/rust

Writing a wrapper for binding generation

Most Rust libraries will need a more C++-friendly API written on top of them in order to generate C++ bindings to them. The wrapper library can be placed in //third_party/rust/<cratename>/wrapper or at another single place that all C++ goes through to access the library. The CXX is used to generate bindings between C++ and Rust.

See //third_party/rust/serde_json_lenient/v0_1/wrapper/ and //components/qr_code_generator for examples.

See //docs/rust-ffi.md for information on C++/Rust FFI.