blob: 448b06a4faddfd4c331b71042d86b0a33cba8b6c [file] [log] [blame]
# 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.
# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by
# tools/crates/gnrt.
# Do not edit!
import("//build/rust/cargo_crate.gni")
{{#each rules}}
cargo_crate("{{this.name}}") {
{{#with this.detail}}
{{#if crate_name}}
crate_name = "{{crate_name}}"
{{/if}}
{{#if epoch}}
epoch = "{{epoch}}"
{{/if}}
{{#if cond}}
enabled = {{cond}}
{{/if}}
crate_type = "{{crate_type}}"
crate_root = "{{crate_root}}"
sources = [
{{#each sources}}
"{{this}}",
{{/each}}
]
inputs = [
{{#each inputs}}
"{{this}}",
{{/each}}
]
build_native_rust_unit_tests = false
edition = "{{edition}}"
{{#if cargo_pkg_authors}}
{{#with cargo_pkg_authors}}
cargo_pkg_authors = "{{gn_escape this}}"
{{/with}}
{{/if}}
cargo_pkg_name = "{{cargo_pkg_name}}"
{{#if cargo_pkg_description}}
{{#with cargo_pkg_description}}
cargo_pkg_description = "{{gn_escape this}}"
{{/with}}
{{/if}}
{{#if cargo_pkg_repository}}
{{#with cargo_pkg_repository}}
cargo_pkg_repository = "{{this}}"
{{/with}}
{{/if}}
cargo_pkg_version = "{{cargo_pkg_version}}"
{{! `cargo_pkg_version` changes during minor version updates, so (to help
reviewers see important crate properties at a glance) we try to include
review-relevant information (e.g. `allow_unsafe`) right below
`cargo_pkg_version`. }}
{{#if_key_present "allow_unsafe" extra_kv}}
allow_unsafe = {{#if extra_kv.allow_unsafe}} true {{else}} false {{/if}}
{{/if_key_present}}
{{#each deps}}
{{#if @first}}
deps = [
{{#if ../dep_on_lib}}
":lib",
{{/if}}
{{#each this.packages}}
"//third_party/rust/{{this.name}}/{{this.epoch}}:lib",
{{/each}}
]
{{else}}
if ({{this.cond}}) {
deps += [
{{#each this.packages}}
"//third_party/rust/{{this.name}}/{{this.epoch}}:lib",
{{/each}}
]
}
{{/if}}
{{/each}}
{{#if extra_kv.extra_deps}}
deps += [
{{#each extra_kv.extra_deps}}
"{{this}}",
{{/each}}
]
{{/if}}
{{#if aliased_deps}}
aliased_deps = {
{{#each aliased_deps}}
{{this.0}} = "//third_party/rust/{{this.1.name}}/{{this.1.epoch}}:lib"
{{/each}}
}
{{/if}}
{{#each build_deps}}
{{#if @first}}
build_deps = [
{{#each this.packages}}
"//third_party/rust/{{this.name}}/{{this.epoch}}:buildrs_support",
{{/each}}
]
{{else}}
if ({{this.cond}}) {
build_deps += [
{{#each this.packages}}
"//third_party/rust/{{this.name}}/{{this.epoch}}:buildrs_support",
{{/each}}
]
}
{{/if}}
{{/each}}
{{#if features}}
features = [
{{#each features}}
"{{this}}",
{{/each}}
]
{{/if}}
{{#if build_root}}
build_root = "{{build_root}}"
build_sources = [
{{#each build_script_sources}}
"{{this}}",
{{/each}}
]
{{#if build_script_inputs}}
build_script_inputs = [
{{#each build_script_inputs}}
"{{this}}",
{{/each}}
]
{{/if}}
{{#if build_script_outputs}}
build_script_outputs = [
{{#each build_script_outputs}}
"{{this}}",
{{/each}}
]
{{/if}}
{{/if}}
{{#if output_dir}}
output_dir = "{{output_dir}}"
{{/if}}
{{#if native_libs}}
native_libs = [
{{#each native_libs}}
"{{this}}",
{{/each}}
]
{{/if}}
{{/with}}
{{#if gn_visibility.public}}
{{#if detail.extra_kv.visibility}}
visibility = []
{{/if}}
{{else}}
# Only for usage from third-party crates. Add the crate to
# //third_party/rust/chromium_crates_io/Cargo.toml to use
# it from first-party code.
visibility = [ "//third_party/rust/*" ]
{{/if}}
{{#if detail.extra_kv.visibility}}
{{#each detail.extra_kv.visibility}}
visibility += [ "{{this}}" ]
{{/each}}
{{/if}}
{{#if gn_visibility.testonly}}
testonly = true
{{/if}}
{{#if detail.extra_kv.allow_unstable_features}}
# `gnrt_config.toml` for this crate specifies `allow_unstable_features`.
rustflags = [
{{#each detail.extra_kv.allow_unstable_features}}
"-Zallow-features={{this}}",
{{/each}}
]
{{/if}}
#####################################################################
# Tweaking which GN `config`s apply to this target.
# Config changes that apply to all `//third_party/rust` crates.
_configs_to_remove = [
# We don't need code coverage data for any `chromium_crates_io` crates.
"//build/config/coverage:default_coverage",
# This is third-party code, so remove `chromium_code` config. We are not
# at the same time adding `//build/config/compiler:no_chromium_code`,
# because 1) we don't want to pull how warnings are handled by that config
# and 2) that config doesn't have any non-warnings-related stuff.
"//build/config/compiler:chromium_code",
]
_configs_to_add = []
{{#if detail.extra_kv.allow_unstable_features}}
# `gnrt_config.toml` for this crate specifies `allow_unstable_features`.
_configs_to_remove += [ "//build/config/compiler:disallow_unstable_features" ]
{{/if}}
# Changing (if needed) which configs apply to this specific crate (based on
# `extra_kv.configs_to_remove` and `extra_kv.configs_to_add` from
# `gnrt_config.toml`).
_configs_to_remove += [
{{#if detail.extra_kv.configs_to_remove}}
{{#each detail.extra_kv.configs_to_remove}}
"{{this}}",
{{/each}}
{{/if}}
]
_configs_to_add += [
{{#if detail.extra_kv.configs_to_add}}
{{#each detail.extra_kv.configs_to_add}}
"{{this}}",
{{/each}}
{{/if}}
]
# Applying config changes.
library_configs -= _configs_to_remove
library_configs += _configs_to_add
executable_configs -= _configs_to_remove
executable_configs += _configs_to_add
proc_macro_configs -= _configs_to_remove
proc_macro_configs += _configs_to_add
}
{{/each}}