1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
|
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This file configures how to generate GN rules for third-party Rust crates.
#
# `[crate.foo]` sections below can configure generation of `BUILD.gn` and/or
# `README.chromium` by specifying the following options:
#
# allow_first_party_usage: If false, the crate should not be visible to first
# party code even though it is present in the Cargo.toml file. It defaults to
# true. Use this if you need to control features for a crate that is only
# meant for use as a transitive dependency of third-party crates.
# e.g. allow_first_party_usage = false
#
# ban_features: A list of crate features that are disallowed in Chromium.
# Typically `ban_features` is used when a crate-feature-gated code failed or
# hasn't gone through a security audit.
#
# build_script_outputs: A list of file paths, rooted from where the BUILD.gn
# file is located, of files generated by the crate's build script.
# e.g. build_script_outputs = [ "crate/src/gen/gen_stuff.rs" ]
#
# extra_input_roots: A list of additional arbitrary files and/or directories
# that are part of the crate (these need to be listed as `inputs` in the
# generated `BUILD.gn`). An example scenario that needs `extra_input_roots`
# is when a crate uses `include_str!` to include `README.md` as a doc
# comment.
#
# extra_src_roots: A list of additional Rust sources that come from outside of
# the crate's `src` directory (these need to be added to `sources` in the
# generated `BUILD.gn`). An example scenario that needs `extra_src_roots` is
# when a crate uses generated code via `include!("../generated/foo.rs")`.
#
# group: One of 'safe', 'sandbox', or 'test. This indicates where the library
# is allowed to be used and where its GN rules will be written.
#
# The group of least privilege is inherited by a crate C from all crates that
# depend on C transitively. For crates listed in Cargo.toml, and not depended
# on by other crates, the default is 'safe'.
# TODO(danakj): The default should probably be 'sandbox'?
#
# 'safe': The library satisfies the rule-of-2 and can be used in any process.
# 'sandbox': The library does not satisfy the rule-of-2 and must be used in
# a sandboxed process such as the renderer or a utility process.
# 'test': The library is only used in tests.
#
# license: The name of the license. This should normally be populated from the
# crate's Cargo.toml, but it can be specified to override it.
#
# license_files: A list of license files, relative to the crate's root.
# This is normally found automatically based on convention, but it can be
# specified to override it. A license file is expected for all shipped
# libraries.
#
# security_critical: A boolean that overrides if the crate is marked security-
# critical in the README.chromium. It defaults to true if the crate is not in
# the 'test' group/.
#
# shipped: A boolean that overrides if the crate is marked shipped in the
# README.chromium. It defaults to true if the crate is not in the 'test'
# group.
#
# bin_targets: A list of binary target names to cover. This list is empty by
# default, which means that the default generated `BUILD.gn` will only cover
# the library target (if any) of the package.
#
# Additional, less commonly needed options can also be discovered by reading
# the doc comments in `//tools/crates/gnrt/lib/config.rs` (e.g. `CrateConfig`'s
# fields correspond to per-crate options like `extra_input_roots`).
[gn]
build_file_template = "BUILD.gn.hbs"
readme_file_template = "README.chromium.hbs"
removed_cargo_template = "removed_Cargo.toml.hbs"
removed_librs_template = "removed_lib.rs.hbs"
[vet]
config_template = "vet_config.toml.hbs"
[resolve]
root = "chromium"
# These crates are dependencies in some configurations, but we don't use them.
remove_crates = [
# C/C++ dependencies must be explicitly writting in GN rules somehow.
'cc',
'link-cplusplus',
'shlex',
# minimal-lexical is unsound see https://crrev.com/c/4977110 for more info.
# It is a dependency of nom, but not actually used.
'minimal-lexical',
# Windows targets that we do not ever target.
'windows_aarch64_gnullvm',
'windows_i686_gnu',
'windows_i686_gnullvm',
'windows_x86_64_gnu',
'windows_x86_64_gnullvm',
# Behind a feature that we do not enable.
'wasi'
]
[crate.anyhow]
group = 'test'
[crate.bstr]
ban_features = [
# The unicode feature is not audited for UB-Risk-2.
'unicode'
]
[crate.bytes]
group = 'test'
[crate.bytemuck]
extra_kv = { configs_to_remove = [
# This allows using `std::simd` helpers, which are needed by first-party code.
'//build/config/compiler:disallow_unstable_features',
] }
[crate.clap]
# These files are included from source files and are thus required as part of
# building the crate.
extra_input_roots = ['../README.md']
extra_src_roots = ['../examples']
[crate.clap_builder]
extra_input_roots = ['../README.md']
[crate.codespan-reporting]
# TODO(https://crbug.com/369075726): Remove this exception.
no_license_file_tracked_in_crbug_369075726 = true
[crate.cxx]
remove_deps = ['cc', 'link-cplusplus']
# This removes the use of cc, and disables the `build_with_cargo` cfg which
# also removes the use of link-cplusplus.
remove_build_rs = true
[crate.cxxbridge-cmd]
shipped = false
bin_targets = ["cxxbridge"]
[crate.fdeflate.extra_kv]
# Web tests (aka WPT tests, also formerly known as Layout Tests) require fast
# PNG encoding and decoding even in Debug builds. See
# https://crbug.com/396419181.
configs_to_remove = ['//build/config/compiler:default_optimization']
configs_to_add = ['//build/config/compiler:optimize']
[crate.flate2]
ban_features = [
# `any_zlib` feature is banned because Chromium does not use the `zlib`
# backend (and because this backend's extensive `unsafe` usage hasn't been
# audited).
'any_zlib',
]
[crate.flate2.extra_kv]
# Web tests (aka WPT tests, also formerly known as Layout Tests) require fast
# PNG encoding and decoding even in Debug builds. See
# https://crbug.com/396419181.
configs_to_remove = ['//build/config/compiler:default_optimization']
configs_to_add = ['//build/config/compiler:optimize']
[crate.hex]
group = 'test'
[crate.hex-literal]
group = 'test'
extra_input_roots = ['../README.md']
[crate.itertools]
group = 'test'
[crate.icu_calendar_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_casemap_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_collator_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_datetime_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_decimal_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_experimental_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_list_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_locale_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_normalizer_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_plurals_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_properties_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_segmenter_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.icu_timezone_data]
extra_input_roots = ['../data']
extra_src_roots = ['../data']
[crate.libc]
ban_features = [
# `extra_traits` feature is banned because of
# https://github.com/rust-lang/libc/issues/3560
'extra_traits',
]
[crate.libm]
license_files= ["LICENSE.txt"]
[crate.log]
[crate.miniz_oxide.extra_kv]
# Web tests (aka WPT tests, also formerly known as Layout Tests) require fast
# PNG encoding and decoding even in Debug builds. See
# https://crbug.com/396419181.
configs_to_remove = ['//build/config/compiler:default_optimization']
configs_to_add = ['//build/config/compiler:optimize']
[crate.num-traits]
# Configures the has_total_cmp feature, not necessary
remove_build_rs = true
[crate.nom]
remove_deps = ['minimal-lexical']
[crate.png.extra_kv]
# Web tests (aka WPT tests, also formerly known as Layout Tests) require fast
# PNG encoding and decoding even in Debug builds. See
# https://crbug.com/396419181.
configs_to_remove = ['//build/config/compiler:default_optimization']
configs_to_add = ['//build/config/compiler:optimize']
[crate.prost]
extra_input_roots = ['../README.md']
group = 'test'
[crate.prost-derive]
group = 'test'
[crate.rand]
group = 'test'
[crate.rand_pcg]
group = 'test'
[crate.read-fonts]
extra_src_roots = ['../generated']
[crate.regex]
group = 'test'
[crate.relative-path]
# TODO(https://crbug.com/369075726): Remove this exception.
no_license_file_tracked_in_crbug_369075726 = true
[crate.rstest]
group = 'test'
[crate.rstest_reuse]
group = 'test'
[crate.rust_decimal]
build_script_outputs = ['README-lib.md']
[crate.rustversion]
allow_first_party_usage = false
extra_build_script_src_roots = ['../build/rustc.rs']
build_script_outputs = [ "version.expr" ]
[crate.rustc-demangle-capi]
shipped = false
# TODO(https://crbug.com/369075726): Remove this exception.
no_license_file_tracked_in_crbug_369075726 = true
[crate.serde_json]
group = 'test'
[crate.skrifa]
extra_src_roots = ['../generated']
[crate.small_ctor]
group = 'test'
[crate.smallvec]
ban_features = ['malloc_size_of']
[crate.unicode-linebreak]
allow_first_party_usage = false
build_script_outputs = [ "tables.rs" ]
[crate.windows-sys]
extra_kv = { visibility = [ '//build/rust/tests/windows_sys_test' ] }
[crate.windows_aarch64_msvc]
native_libs_roots = [ '../lib' ]
[crate.windows_i686_msvc]
native_libs_roots = [ '../lib' ]
[crate.windows_x86_64_msvc]
native_libs_roots = [ '../lib' ]
|