tree: 07594ffbd6bb77780692a48474a659e85701d91f
  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. extended/
  60. fastbloom/
  61. fdeflate/
  62. fend_core/
  63. fixed_decimal/
  64. flate2/
  65. foldhash/
  66. font_types/
  67. fs2/
  68. getrandom/
  69. gimli/
  70. harfrust/
  71. hashbrown/
  72. heck/
  73. hex/
  74. hmac_sha256/
  75. hostname/
  76. iana_time_zone/
  77. icu_calendar/
  78. icu_calendar_data/
  79. icu_capi/
  80. icu_casemap/
  81. icu_casemap_data/
  82. icu_collections/
  83. icu_decimal/
  84. icu_decimal_data/
  85. icu_experimental/
  86. icu_experimental_data/
  87. icu_list/
  88. icu_list_data/
  89. icu_locale/
  90. icu_locale_core/
  91. icu_locale_data/
  92. icu_normalizer/
  93. icu_normalizer_data/
  94. icu_pattern/
  95. icu_plurals/
  96. icu_plurals_data/
  97. icu_properties/
  98. icu_properties_data/
  99. icu_provider/
  100. icu_provider_adapters/
  101. icu_time/
  102. image/
  103. incremental_font_transfer/
  104. indexmap/
  105. itertools/
  106. itoa/
  107. ixdtf/
  108. jiff_tzdb/
  109. jpeg_encoder/
  110. jxl/
  111. jxl_macros/
  112. jxl_simd/
  113. jxl_transforms/
  114. konst/
  115. konst_macro_rules/
  116. lazy_static/
  117. libafl/
  118. libafl_bolts/
  119. libafl_derive/
  120. libc/
  121. libm/
  122. litemap/
  123. llguidance/
  124. lock_api/
  125. log/
  126. mach2/
  127. memchr/
  128. meminterval/
  129. memo_map/
  130. memoffset/
  131. minijinja/
  132. miniz_oxide/
  133. moxcms/
  134. murmur3/
  135. nix/
  136. num_bigint/
  137. num_complex/
  138. num_derive/
  139. num_enum/
  140. num_enum_derive/
  141. num_integer/
  142. num_rational/
  143. num_traits/
  144. object/
  145. once_cell/
  146. ordered_float/
  147. parking_lot/
  148. parking_lot_core/
  149. png/
  150. postcard/
  151. potential_utf/
  152. primal_check/
  153. proc_macro2/
  154. prost/
  155. prost_derive/
  156. pxfm/
  157. qr_code/
  158. quote/
  159. rand_core/
  160. read_fonts/
  161. ref_cast/
  162. ref_cast_impl/
  163. regex/
  164. regex_automata/
  165. regex_lite/
  166. regex_syntax/
  167. resb/
  168. rustc_demangle/
  169. rustc_demangle_capi/
  170. rustfft/
  171. rustversion/
  172. ryu/
  173. safe_arch/
  174. scc/
  175. scopeguard/
  176. sdd/
  177. serde/
  178. serde_core/
  179. serde_derive/
  180. serde_json/
  181. serde_json_lenient/
  182. serial_test/
  183. serial_test_derive/
  184. sfv/
  185. shared_brotli_patch_decoder/
  186. simd_adler32/
  187. siphasher/
  188. skera/
  189. skrifa/
  190. small_ctor/
  191. smallvec/
  192. stable_deref_trait/
  193. static_assertions/
  194. strck/
  195. strength_reduce/
  196. strsim/
  197. strum/
  198. strum_macros/
  199. subtle/
  200. symphonia/
  201. symphonia_bundle_flac/
  202. symphonia_bundle_mp3/
  203. symphonia_codec_pcm/
  204. symphonia_codec_vorbis/
  205. symphonia_common/
  206. symphonia_core/
  207. symphonia_format_isomp4/
  208. symphonia_format_mkv/
  209. symphonia_format_ogg/
  210. symphonia_format_riff/
  211. symphonia_metadata/
  212. symphonia_utils_xiph/
  213. syn/
  214. synstructure/
  215. temporal_capi/
  216. temporal_rs/
  217. termcolor/
  218. thiserror/
  219. thiserror_impl/
  220. timezone_provider/
  221. tinystr/
  222. toktrie/
  223. transpose/
  224. tuple_list/
  225. typed_arena/
  226. typed_builder/
  227. typed_builder_macro/
  228. typed_path/
  229. typeid/
  230. typewit/
  231. tzif/
  232. uds/
  233. unicode_ident/
  234. unicode_width/
  235. unicode_xid/
  236. unty/
  237. utf16_iter/
  238. utf8_iter/
  239. uuid/
  240. version_check/
  241. virtue/
  242. wait_timeout/
  243. wide/
  244. winapi_util/
  245. windows_aarch64_msvc/
  246. windows_i686_msvc/
  247. windows_link/
  248. windows_sys/
  249. windows_targets/
  250. windows_x86_64_msvc/
  251. write16/
  252. write_fonts/
  253. writeable/
  254. xml/
  255. xxhash_rust/
  256. yoke/
  257. yoke_derive/
  258. zerocopy/
  259. zerofrom/
  260. zerofrom_derive/
  261. zeroize/
  262. zeroize_derive/
  263. zerotrie/
  264. zerovec/
  265. zerovec_derive/
  266. zip/
  267. zmij/
  268. zoneinfo64/
  269. zune_core/
  270. zune_jpeg/
  271. .clang-format
  272. DEPS
  273. OWNERS
  274. OWNERS-review-checklist.md
  275. PRESUBMIT.py
  276. README-importing-new-crates.md
  277. 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 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.