File: BUILD.gn

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (144 lines) | stat: -rw-r--r-- 4,561 bytes parent folder | download | duplicates (7)
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
# 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.

import("//ash/webui/tools/mwc_path_mappings.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//third_party/material_web_components/rewrite_imports.gni")
import("//tools/typescript/ts_library.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

_cros_components_ts_files = [
  "accordion/accordion.ts",
  "accordion/accordion_item.ts",
  "async_helpers/async_helpers.ts",
  "badge/badge.ts",
  "button/button.ts",
  "card/card.ts",
  "checkbox/checkbox.ts",
  "chip/chip.ts",
  "dropdown/dropdown.ts",
  "dropdown/dropdown_option.ts",
  "helpers/helpers.ts",
  "icon_button/icon-button.ts",
  "icon_dropdown/icon-dropdown.ts",
  "icon_dropdown/icon-dropdown-option.ts",
  "lottie_renderer/event_binders.ts",
  "lottie_renderer/lottie-renderer.ts",
  "lottie_renderer/worker.ts",
  "lottie_renderer/lottie_processing_helpers.ts",
  "menu/menu.ts",
  "menu/menu_item.ts",
  "menu/menu_separator.ts",
  "menu/menu_util.ts",
  "menu/sub_menu_item.ts",
  "orca_feedback/maybe_safe_html.ts",
  "orca_feedback/orca-feedback.ts",
  "radio/radio.ts",
  "sidenav/sidenav.ts",
  "sidenav/sidenav_item.ts",
  "sidenav/sidenav_util.ts",
  "slider/slider.ts",
  "snackbar/snackbar.ts",
  "snackbar/show_snackbar.ts",
  "snackbar/snackbar-item.ts",
  "snackbar/snackbar-manager.ts",
  "switch/switch.ts",
  "tab_slider/tab-slider-item.ts",
  "tab_slider/tab-slider.ts",
  "tabs/tab.ts",
  "tabs/tabs.ts",
  "tag/tag.ts",
  "textfield/textfield.ts",
  "tooltip/tooltip.ts",
]

ts_library("cros_components__ts_library") {
  # Downstream ts_library targets should depend on `cros_components_ts` below.
  visibility = [ ":*" ]

  root_dir = "src/"
  out_dir =
      "$root_gen_dir/ui/webui/resources/tsc/cros_components/to_be_rewritten"
  tsconfig_base = "tsconfig_base.json"

  in_files = _cros_components_ts_files

  root_src_dir = rebase_path("//", target_gen_dir)
  resources_dir =
      rebase_path("$root_gen_dir/ui/webui/resources/tsc", target_gen_dir)

  path_mappings = [
    "chrome://resources/cr_components/color_change_listener/*|$resources_dir/cr_components/color_change_listener/*",
    "@material/*|$root_src_dir/third_party/material_web_components/components-chromium/node_modules/@material/*",
  ]

  foreach(_mwc_mapping, mwc_path_mappings) {
    path_mappings +=
        [ _mwc_mapping[0] + "|" + rebase_path(_mwc_mapping[1], target_gen_dir) ]
  }

  composite = true
  deps = [
    "//third_party/material_web_components:library",
    "//ui/webui/resources/cr_components/color_change_listener:build_ts",
  ]
}

# Downstream ts_library targets that depend on `cros_components_ts` expect
# tsconfig_cros_components_ts.json to exist so copy the tsconfig of
# `:cros_components__ts_library`.
copy("rename_tsconfig") {
  visibility = [ ":*" ]
  sources = [ "$target_gen_dir/tsconfig_cros_components__ts_library.json" ]
  outputs = [ "$target_gen_dir/tsconfig_cros_components_ts.json" ]
  deps = [ ":cros_components__ts_library" ]
}

rewrite_imports("cros_components_ts") {
  base_dir =
      "$root_gen_dir/ui/webui/resources/tsc/cros_components/to_be_rewritten"

  # Rollup maps URLs like `chrome://resources/cros_components/*` to
  # files in
  # `$root_gen_dir/ui/webui/resources/tsc/cros_components/*`.
  out_dir = "$root_gen_dir/ui/webui/resources/tsc/cros_components/"

  in_files = []
  foreach(_file, _cros_components_ts_files) {
    in_files += [ string_replace(_file, ".ts", ".js") ]
  }

  import_mappings = [
    "lit|//resources/mwc/lit/index.js",
    "@lit/task|//resources/mwc/lit/index.js",

    "@material/|//resources/mwc/@material/",

    # Add js prefix's to any internal imports so they work at runtime.
    "(?P<filepath>\.\.?/[\w\-/]+)\$|\g<filepath>.js",
  ]

  deps = [
    ":cros_components__ts_library",
    "//third_party/material_web_components:mwc_rewrite",
  ]
  public_deps = [ ":rename_tsconfig" ]
}

generate_grd("cros_components_grdp") {
  grd_prefix = "cros_components"
  out_grd = "${target_gen_dir}/resources.grdp"

  manifest_files = []

  deps = [ ":cros_components_ts" ]
  manifest_files += filter_include(get_target_outputs(":cros_components_ts"),
                                   [ "*.manifest" ])
  resource_path_prefix = "cros_components"
  input_files_base_dir = rebase_path(".", "//")
  input_files = [ "src/lottie_renderer/lottie_worker.js" ]
  resource_path_rewrites = [
    "src/lottie_renderer/lottie_worker.js|lottie_renderer/lottie_worker.js",
  ]
}