File: BUILD.gn.hbs

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (219 lines) | stat: -rw-r--r-- 5,706 bytes parent folder | download | duplicates (5)
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
# 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}}
  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 aliased_deps}}
  aliased_deps = {
    {{#each aliased_deps}}
    {{this.0}} = "{{this.1}}"
    {{/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}}