chromium/chrome/browser/resources/chromeos/multidevice_setup/BUILD.gn

# Copyright 2018 The Chromium Authors
# 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/preprocess_if_expr.gni")
import("//tools/polymer/html_to_js.gni")
import("//ui/webui/resources/tools/generate_grd.gni")
import("//ui/webui/resources/tools/optimize_webui.gni")

preprocess_folder = "preprocessed"
preprocess_manifest = "preprocessed_manifest.json"
preprocess_gen_manifest = "preprocessed_gen_manifest.json"

if (optimize_webui) {
  build_manifest = "build_manifest.json"

  optimize_webui("build") {
    host = "multidevice-setup"
    js_module_in_files = [ "multidevice_setup_post_oobe.js" ]
    input = rebase_path("$target_gen_dir/$preprocess_folder", root_build_dir)

    out_manifest = "$target_gen_dir/$build_manifest"
    excludes = [
      "chrome://resources/mojo/chromeos/ash/components/multidevice/mojom/multidevice_types.mojom-webui.js",
      "chrome://resources/mojo/chromeos/ash/services/device_sync/public/mojom/device_sync.mojom-webui.js",
      "chrome://resources/mojo/chromeos/ash/services/multidevice_setup/public/mojom/multidevice_setup.mojom-webui.js",
    ]

    deps = [
      ":preprocess",
      ":preprocess_generated",
      "//ash/webui/common/resources:css_wrapper_files",
      "//ash/webui/common/resources:html_wrapper_files",
      "//ash/webui/common/resources:preprocess",
      "//third_party/cros-components:cros_components_ts",
      "//third_party/material_web_components:library",
      "//ash/webui/common/resources/cr_elements:build_ts",
    ]
  }
}

generate_grd("build_grd") {
  input_files = [ "multidevice_setup_dialog.html" ]
  input_files_base_dir = rebase_path(".", "//")
  if (optimize_webui) {
    deps = [ ":build" ]
    resource_path_rewrites = [
      "multidevice_setup_post_oobe.rollup.js|multidevice_setup_post_oobe.js",
    ]
    manifest_files = [ "$target_gen_dir/$build_manifest" ]
  } else {
    deps = [
      ":preprocess",
      ":preprocess_generated",
    ]
    manifest_files = [
      "$target_gen_dir/$preprocess_manifest",
      "$target_gen_dir/$preprocess_gen_manifest",
    ]
  }
  grd_prefix = "multidevice_setup"
  out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
}

preprocess_if_expr("preprocess") {
  out_folder = "$target_gen_dir/$preprocess_folder"
  out_manifest = "$target_gen_dir/$preprocess_manifest"
  in_files = [ "post_oobe_delegate.js" ]
}

preprocess_if_expr("preprocess_generated") {
  deps = [ ":web_components" ]
  in_folder = target_gen_dir
  out_folder = "$target_gen_dir/$preprocess_folder"
  out_manifest = "$target_gen_dir/$preprocess_gen_manifest"
  in_files = [ "multidevice_setup_post_oobe.js" ]
}

js_type_check("closure_compile") {
  is_polymer3 = true
  closure_flags = default_closure_args + mojom_js_args
  deps = [
    ":multidevice_setup_post_oobe",
    ":post_oobe_delegate",
  ]
}

js_library("multidevice_setup_post_oobe") {
  extra_deps = [
    "//third_party/cros-components:cros_components_ts",
    "//third_party/material_web_components:library",
  ]
  deps = [
    ":post_oobe_delegate",
    "//ash/webui/common/resources/multidevice_setup:multidevice_setup",
    "//ash/webui/common/resources/multidevice_setup:multidevice_setup_delegate",
    "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
  ]
  externs_list = [
    "//third_party/cros-components/externs/cros_lottie_renderer_externs.js",
  ]
}

js_library("post_oobe_delegate") {
  deps = [
    "//ash/webui/common/resources/multidevice_setup:mojo_api",
    "//ash/webui/common/resources/multidevice_setup:multidevice_setup_delegate",
  ]
}

html_to_js("web_components") {
  js_files = [ "multidevice_setup_post_oobe.js" ]
}