summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/nearby_share/BUILD.gn
blob: 237bef00becf528ea77827d59abccd84722dce5f (plain)
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
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//chrome/common/features.gni")
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/preprocess_if_expr.gni")
import("//tools/polymer/html_to_wrapper.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

assert(is_chromeos_ash, "Nearby Share is CrOS only")

preprocess_src_manifest = "preprocessed_src_manifest.json"
preprocess_gen_manifest = "preprocessed_gen_manifest.json"
preprocess_mojo_manifest = "preprocessed_mojo_manifest.json"
preprocess_folder = "preprocessed"

grit("resources") {
  defines = chrome_grit_defines

  # These arguments are needed since the grd is generated at build time.
  enable_input_discovery_for_gn_analyze = false
  source = "$target_gen_dir/nearby_share_dialog_resources.grd"
  deps = [ ":build_grd" ]
  outputs = [
    "grit/nearby_share_dialog_resources.h",
    "grit/nearby_share_dialog_resources_map.cc",
    "grit/nearby_share_dialog_resources_map.h",
    "nearby_share_dialog_resources.pak",
  ]
  output_dir = "$root_gen_dir/chrome"
}

generate_grd("build_grd") {
  grd_prefix = "nearby_share_dialog"
  out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
  deps = [
    ":build_mojo_grdp",
    ":preprocess_gen",
    ":preprocess_src",
    "shared:build_v3_grdp",
  ]
  grdp_files = [
    "$target_gen_dir/nearby_share_mojo_resources.grdp",
    "$target_gen_dir/shared/nearby_share_resources_v3.grdp",
  ]
  input_files = [
    "nearby_share_progress_bar_dark.json",
    "nearby_share_progress_bar_light.json",
    "nearby_share_pulse_animation_dark.json",
    "nearby_share_pulse_animation_light.json",
  ]
  input_files_base_dir = rebase_path("shared", "//")
  manifest_files = [
    "$target_gen_dir/$preprocess_src_manifest",
    "$target_gen_dir/$preprocess_gen_manifest",
  ]
  resource_path_rewrites = [
    "ash/services/nearby/public/mojom/nearby_share_target_types.mojom-lite.js|mojo/nearby_share_target_types.mojom-lite.js",
    "chrome/browser/ui/webui/nearby_share/nearby_share.mojom-lite.js|mojo/nearby_share.mojom-lite.js",
    "chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom-lite.js|mojo/nearby_share_share_type.mojom-lite.js",
    "chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom-lite.js|mojo/nearby_share_settings.mojom-lite.js",
  ]
}

web_component_files = [
  "app.js",
  "nearby_confirmation_page.js",
  "nearby_discovery_page.js",
]

# Files that are passed as input to html_to_wrapper().
html_files = []
foreach(f, web_component_files) {
  html_files += [ string_replace(f, ".js", ".html") ]
}

# Files that are generated by html_to_wrapper().
html_wrapper_files = []
foreach(f, html_files) {
  html_wrapper_files += [ f + ".js" ]
}

non_web_component_files = [ "discovery_manager.js" ]

html_to_wrapper("html_wrapper_files") {
  in_files = html_files
  use_js = true
}

preprocess_if_expr("preprocess_src") {
  out_folder = "$target_gen_dir/$preprocess_folder"
  out_manifest = "$target_gen_dir/$preprocess_src_manifest"
  in_files = web_component_files + non_web_component_files +
             [ "nearby_share_dialog.html" ]
}

preprocess_if_expr("preprocess_gen") {
  deps = [ ":html_wrapper_files" ]
  in_folder = target_gen_dir
  out_folder = "$target_gen_dir/$preprocess_folder"
  out_manifest = "$target_gen_dir/$preprocess_gen_manifest"
  in_files = html_wrapper_files
}

generate_grd("build_mojo_grdp") {
  grd_prefix = "nearby_share"
  out_grd = "$target_gen_dir/${grd_prefix}_mojo_resources.grdp"
  deps = [ ":preprocess_mojo" ]
  manifest_files = [ "$target_gen_dir/$preprocess_mojo_manifest" ]
  resource_path_rewrites = [
    "ash/services/nearby/public/mojom/nearby_share_target_types.mojom-lite.js|mojo/nearby_share_target_types.mojom-lite.js",
    "chrome/browser/ui/webui/nearby_share/nearby_share.mojom-lite.js|mojo/nearby_share.mojom-lite.js",
    "chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom-lite.js|mojo/nearby_share_share_type.mojom-lite.js",
    "chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom-lite.js|mojo/nearby_share_settings.mojom-lite.js",
  ]
}

# Mojo files, for generating grdp
preprocess_if_expr("preprocess_mojo") {
  deps = [
    "//ash/services/nearby/public/mojom:mojom_js",
    "//chrome/browser/ui/webui/nearby_share:mojom_js",
    "//chrome/browser/ui/webui/nearby_share/public/mojom:mojom_js__generator",
  ]
  in_folder = root_gen_dir
  out_folder = "$target_gen_dir/$preprocess_folder"
  out_manifest = "$target_gen_dir/$preprocess_mojo_manifest"
  in_files = [
    "ash/services/nearby/public/mojom/nearby_share_target_types.mojom-lite.js",
    "chrome/browser/ui/webui/nearby_share/nearby_share.mojom-lite.js",
    "chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom-lite.js",
    "chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom-lite.js",
  ]
}

js_type_check("closure_compile") {
  is_polymer3 = true
  closure_flags =
      default_closure_args + [
        "js_module_root=../../chrome/browser/resources/nearby_share/",
        "js_module_root=./gen/chrome/browser/resources/nearby_share/",
      ]
  deps = [
    ":app",
    ":discovery_manager",
    ":nearby_confirmation_page",
    ":nearby_discovery_page",
  ]
}

js_library("app") {
  deps = [
    ":nearby_confirmation_page",
    ":nearby_discovery_page",
    "./shared:nearby_onboarding_one_page",
    "./shared:nearby_onboarding_page",
    "./shared:nearby_share_settings_behavior",
    "./shared:nearby_visibility_page",
    "./shared:types",
    "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
    "//ui/webui/resources/js:load_time_data",
  ]
  externs_list = [ "//ui/webui/resources/cr_elements/cr_view_manager/cr_view_manager_externs.js" ]
}

js_library("discovery_manager") {
  deps = [
    "//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
    "//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
  ]
}

js_library("nearby_confirmation_page") {
  deps = [
    "./shared:nearby_preview",
    "./shared:nearby_progress",
    "./shared:types",
    "//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
    "//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
    "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
    "//ui/webui/resources/cr_elements/cr_button:cr_button",
    "//ui/webui/resources/js:i18n_behavior.m",
  ]
}

js_library("nearby_discovery_page") {
  deps = [
    ":discovery_manager",
    "./shared:nearby_device",
    "./shared:nearby_preview",
    "//chrome/browser/ui/webui/nearby_share:mojom_js_library_for_compile",
    "//chrome/browser/ui/webui/nearby_share:share_type_js_library_for_compile",
    "//third_party/polymer/v3_0/components-chromium/iron-list",
    "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
    "//ui/webui/resources/cr_elements/cr_button:cr_button",
    "//ui/webui/resources/cr_elements/cr_lottie:cr_lottie.m",
    "//ui/webui/resources/js:assert.m",
  ]
}