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

ash / webui / recorder_app_ui / resources / BUILD.gn [blame]

# Copyright 2024 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/recorder_app_ui/resources/components/components.gni")
import("//ash/webui/recorder_app_ui/resources/core/core.gni")
import("//ash/webui/recorder_app_ui/resources/images/images.gni")
import("//ash/webui/recorder_app_ui/resources/pages/pages.gni")
import("//ash/webui/recorder_app_ui/resources/platforms/platforms.gni")
import("//ash/webui/recorder_app_ui/resources/static/static.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//ui/webui/resources/tools/build_webui.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

assert(is_chromeos_ash)

action("gen_images_js") {
  script = "scripts/gen_images_js.py"

  image_paths = []
  foreach(image, images) {
    image_paths += [ "images/$image" ]
  }

  inputs = image_paths

  outputs = [ "$target_gen_dir/images/images.js" ]
  response_file_contents = rebase_path(image_paths)
  args = [
    "--output_file",
    rebase_path(outputs[0], root_build_dir),
    "--images_file={{response_file_name}}",
    "--root_dir",
    rebase_path("images"),
  ]
}

generated_grdp_file = "$target_gen_dir/generated.grdp"

generate_grd("build_generated_grdp") {
  deps = [ ":gen_images_js" ]
  grd_prefix = "generated"
  input_files_base_dir = rebase_path(target_gen_dir, root_build_dir)
  input_files = [ "images/images.js" ]
  out_grd = generated_grdp_file
}

static_grdp_file = "$target_gen_dir/static.grdp"

# Static files without any processing. Note that we don't use the static_files
# in build_webui, since that would run preprocess step on anything that is not
# .jpg, .png or .svg.
generate_grd("build_static_grdp") {
  grd_prefix = "static"
  input_files_base_dir = rebase_path(".", "//")
  input_files = []
  foreach(file, static_files) {
    input_files += [ "static/$file" ]
  }
  out_grd = static_grdp_file
}

build_webui("build") {
  grd_prefix = "recorder_app"

  # The name collide with static_files from static.gni, so we need to set to []
  # first before assigning new value...
  static_files = []
  static_files = [ "index.html" ]
  non_web_component_files = [ "init.ts" ]

  # Note that since we don't use separate .html/.css file for template in
  # components, all components/pages files are under non_web_component_files
  # even though they're actually lit components.

  foreach(file, component_files) {
    non_web_component_files += [ "components/$file" ]
  }

  foreach(file, page_files) {
    non_web_component_files += [ "pages/$file" ]
  }

  foreach(file, platform_files) {
    non_web_component_files += [ "platforms/$file" ]
  }

  foreach(file, core_files) {
    non_web_component_files += [ "core/$file" ]
  }

  ts_definitions = [
    "core/externs.d.ts",
    "images/images.d.ts",
  ]

  ts_deps = [
    "//ash/webui/common/resources:build_ts",
    "//third_party/cros-components:cros_components_ts",
    "//third_party/material_web_components:bundle_lit_ts",
    "//third_party/material_web_components:library",
    "//ui/webui/resources/cr_components/color_change_listener:build_ts",
    "//ui/webui/resources/js:build_ts",
    "//ui/webui/resources/mojo:build_ts",
  ]

  ts_tsconfig_base = "tsconfig_base.json"

  images_dir = rebase_path("images", target_gen_dir)

  # This is needed so the build_ts compilation can use the images.d.ts file as
  # dependency, and don't need to refer to the generated images.js file.
  ts_path_mappings = [ "/images/*|$images_dir/*" ]

  mojo_files = [
    "$root_gen_dir/ash/webui/recorder_app_ui/mojom/recorder_app.mojom-webui.ts",
    "$root_gen_dir/chromeos/services/machine_learning/public/mojom/soda.mojom-webui.ts",
    "$root_gen_dir/services/on_device_model/public/mojom/on_device_model.mojom-webui.ts",
    "$root_gen_dir/services/on_device_model/public/mojom/on_device_model_service.mojom-webui.ts",
  ]

  mojo_files_deps = [
    "//ash/webui/recorder_app_ui/mojom:mojom_ts__generator",
    "//chromeos/services/machine_learning/public/mojom:soda_ts__generator",
    "//services/on_device_model/public/mojom:mojom_ts__generator",
  ]

  mojo_base_path = "/mojom/"

  extra_grdp_deps = [
    ":build_generated_grdp",
    ":build_static_grdp",
  ]
  extra_grdp_files = [
    generated_grdp_file,
    static_grdp_file,
  ]

  grit_output_dir = target_gen_dir

  webui_context_type = "trusted"
}