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