chromium/ash/webui/resources/BUILD.gn

# Copyright 2021 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/boca_ui/boca_app.gni")
import("//ash/webui/eche_app_ui/eche_app_ui.gni")
import("//ash/webui/help_app_ui/help_app_ui.gni")
import("//ash/webui/media_app_ui/media_app_ui.gni")
import("//ash/webui/projector_app/projector_app.gni")
import("//tools/grit/grit_rule.gni")

assert(is_chromeos_ash, "Non-ChromeOS builds cannot depend on //ash")

ash_webui_grit_output_dir = "$root_gen_dir/ash/webui"

# Convenience template for WebUIs using generate_grd.
# TODO(calamity): Further deduplicate with non-generated grit targets.
template("ash_generated_grit") {
  grit(target_name) {
    forward_variables_from(invoker,
                           [
                             "deps",
                             "source",
                           ])

    # These arguments are needed since the grd is generated at build time.
    enable_input_discovery_for_gn_analyze = false

    outputs = [
      "ash_${target_name}.pak",
      "grit/ash_${target_name}.h",
      "grit/ash_${target_name}_map.cc",
      "grit/ash_${target_name}_map.h",
    ]
    output_dir = "$ash_webui_grit_output_dir"
  }
}

# Boca app resource bundle, obtained via DEPS.
grit("boca_app_bundle_resources") {
  if (enable_cros_boca_app) {
    # Obtained via an internal CIPD package in src / DEPS.
    source = "//ash/webui/boca_ui/resources/prod/boca_app_bundle_resources.grd"
  } else {
    source =
        "//ash/webui/boca_ui/resources/mock/boca_app_bundle_mock_resources.grd"
    deps = [ "//ash/webui/boca_ui/resources/mock:build_ts" ]
  }
  use_brotli = true

  # TODO(crbug.com/40250824): Prefix of outputs should be changed to ash
  # when.grd from internal CIPD package is updated.
  outputs = [
    "grit/chromeos_boca_app_bundle_resources.h",
    "grit/chromeos_boca_app_bundle_resources_map.cc",
    "grit/chromeos_boca_app_bundle_resources_map.h",
    "chromeos_boca_app_bundle_resources.pak",
  ]
  output_dir = "$root_gen_dir/chromeos"
}

# Resources used by chrome://camera-app.
ash_generated_grit("camera_app_resources") {
  source = "$root_gen_dir/ash/webui/camera_app_ui/ash_camera_app_resources.grd"
  deps = [ "//ash/webui/camera_app_ui:build_grd" ]
}

ash_generated_grit("files_internals_resources") {
  source = "$root_gen_dir/ash/webui/files_internals/ash_files_internals_resources.grd"
  deps = [ "//ash/webui/files_internals:build_grd" ]
}

# Resources used by chrome-untrusted://demo-mode-app
ash_generated_grit("demo_mode_app_resources") {
  source =
      "$root_gen_dir/ash/webui/demo_mode_app_ui/ash_demo_mode_app_resources.grd"
  deps = [ "//ash/webui/demo_mode_app_ui:build_grd" ]
}

# Resources used by chrome://help-app, and parts of the sandboxed app it hosts
# that do not come from the app bundle (below).
grit("help_app_resources") {
  source = "//ash/webui/help_app_ui/resources/help_app_resources.grd"

  outputs = [
    "grit/ash_help_app_resources.h",
    "grit/ash_help_app_resources_map.cc",
    "grit/ash_help_app_resources_map.h",
    "ash_help_app_resources.pak",
  ]
  output_dir = "$ash_webui_grit_output_dir"

  deps = [
    "//ash/webui/help_app_ui:mojo_bindings_js",
    "//ash/webui/help_app_ui/resources:browser_proxy_rollup",
    "//ash/webui/help_app_ui/resources:receiver_rollup",
    "//ash/webui/help_app_ui/search:mojo_bindings_js",
    "//chromeos/ash/components/local_search_service/public/mojom:mojom_js",
  ]
}

# Resources automatically served by the chrome://help-app bundle, obtained via DEPS.
grit("help_app_bundle_resources") {
  if (enable_cros_help_app) {
    # Obtained via an internal CIPD package in src/DEPS.
    source =
        "//ash/webui/help_app_ui/resources/prod/help_app_bundle_resources.grd"
  } else {
    source = "//ash/webui/help_app_ui/resources/mock/help_app_bundle_mock_resources.grd"
    deps = [ "//ash/webui/help_app_ui/resources/mock:build_ts" ]
  }

  use_brotli = true

  # TODO(crbug.com/40250824): Prefix of outputs should be changed to ash
  # when .grd from internal CIPD package is updated.
  outputs = [
    "grit/chromeos_help_app_bundle_resources.h",
    "grit/chromeos_help_app_bundle_resources_map.cc",
    "grit/chromeos_help_app_bundle_resources_map.h",
    "chromeos_help_app_bundle_resources.pak",
  ]
  output_dir = "$root_gen_dir/chromeos"
}

grit("help_app_kids_magazine_bundle_resources") {
  if (enable_cros_help_app) {
    source = "//ash/webui/help_app_ui/resources/prod/help_app_kids_magazine_bundle_resources.grd"
  } else {
    source = "//ash/webui/help_app_ui/resources/mock/help_app_kids_magazine_bundle_mock_resources.grd"
  }

  use_brotli = true

  # TODO(crbug.com/40250824): Prefix of outputs should be changed to ash
  # when .grd from internal CIPD package is updated.
  outputs = [
    "grit/chromeos_help_app_kids_magazine_bundle_resources.h",
    "grit/chromeos_help_app_kids_magazine_bundle_resources_map.cc",
    "grit/chromeos_help_app_kids_magazine_bundle_resources_map.h",
    "chromeos_help_app_kids_magazine_bundle_resources.pak",
  ]
  output_dir = "$root_gen_dir/chromeos"
}

# Resources used by chrome://media-app, and parts of the sandboxed app it hosts
# that do not come from the app bundle (below).
grit("media_app_resources") {
  source = "//ash/webui/media_app_ui/resources/media_app_resources.grd"

  outputs = [
    "grit/ash_media_app_resources.h",
    "ash_media_app_resources.pak",
  ]
  output_dir = "$ash_webui_grit_output_dir"

  use_brotli = true

  deps = [
    "//ash/webui/media_app_ui:mojo_bindings_js",
    "//ash/webui/media_app_ui/resources/js:launch_rollup",
    "//ash/webui/media_app_ui/resources/js:piex_rollup",
    "//ash/webui/media_app_ui/resources/js:receiver_rollup",
  ]
}

# Resources automatically served by the chrome://media-app bundle, obtained via DEPS.
grit("media_app_bundle_resources") {
  if (enable_cros_media_app) {
    # Obtained via an internal CIPD package in src/DEPS.
    source =
        "//ash/webui/media_app_ui/resources/prod/media_app_bundle_resources.grd"
  } else {
    source = "//ash/webui/media_app_ui/resources/mock/media_app_bundle_mock_resources.grd"
    deps = [ "//ash/webui/media_app_ui/resources/mock/js:build_ts" ]
  }

  use_brotli = true

  # TODO(crbug.com/40250824): Prefix of outputs should be changed to ash
  # when .grd from internal CIPD package is updated.
  outputs = [
    "grit/chromeos_media_app_bundle_resources.h",
    "grit/chromeos_media_app_bundle_resources_map.cc",
    "grit/chromeos_media_app_bundle_resources_map.h",
    "chromeos_media_app_bundle_resources.pak",
  ]
  output_dir = "$root_gen_dir/chromeos"
}

# Resources used by chrome-untrusted://projector SWA.
ash_generated_grit("projector_app_untrusted_resources") {
  source = "$root_gen_dir/ash/webui/projector_app/resources/app/untrusted/ash_projector_app_untrusted_resources.grd"
  deps = [
    "//ash/webui/projector_app/resources/app/untrusted:build_untrusted_grd",
  ]
}

# Resources automatically served by the chrome-untrusted://projector bundle, obtained via DEPS.
# TODO(b/216523790): Split up the projector_app_bundle_resource into app_bundle and annotator_bundle.
grit("projector_app_bundle_resources") {
  if (enable_cros_projector_app) {
    # Obtained via an internal CIPD package in src/DEPS.
    source = "//ash/webui/projector_app/resources/prod/projector_app_bundle_resources.grd"
  } else {
    source = "//ash/webui/projector_app/resources/mock/projector_app_bundle_mock_resources.grd"
  }

  use_brotli = true

  # TODO(crbug.com/40250824): Prefix of outputs should be changed to ash
  # when .grd from internal CIPD package is updated.
  outputs = [
    "grit/chromeos_projector_app_bundle_resources.h",
    "grit/chromeos_projector_app_bundle_resources_map.cc",
    "grit/chromeos_projector_app_bundle_resources_map.h",
    "chromeos_projector_app_bundle_resources.pak",
  ]
  output_dir = "$root_gen_dir/chromeos"
}

# Resources used by chrome-untrusted://projector-annotator SWA.
ash_generated_grit("annotator_untrusted_resources") {
  source = "$root_gen_dir/ash/webui/annotator/resources/untrusted/ash_annotator_untrusted_resources.grd"
  deps = [ "//ash/webui/annotator/resources/untrusted:build_untrusted_grd" ]
}

# Resources used by chrome://projector and chrome://projector-annotator SWA.
ash_generated_grit("projector_common_resources") {
  source = "$root_gen_dir/ash/webui/projector_app/resources/common/ash_projector_common_resources.grd"
  deps = [ "//ash/webui/projector_app/resources/common:build_common_grd" ]
}

# Resources used by chrome://eche-app
ash_generated_grit("eche_app_resources") {
  source = "$root_gen_dir/ash/webui/eche_app_ui/ash_eche_app_resources.grd"
  deps = [ "//ash/webui/eche_app_ui:build_grd" ]
}

# Resources automatically served by the chrome://eche-app bundle, obtained via DEPS.
grit("eche_bundle_resources") {
  # Obtained via an internal CIPD package in src/DEPS.
  if (enable_cros_eche_app) {
    # Obtained via an internal CIPD package in src/DEPS.
    source =
        "//ash/webui/eche_app_ui/resources/prod/ash_eche_bundle_resources.grd"
  } else {
    source = "//ash/webui/eche_app_ui/resources/mock/ash_eche_bundle_mock_resources.grd"
  }

  use_brotli = true

  outputs = [
    "grit/ash_eche_bundle_resources.h",
    "grit/ash_eche_bundle_resources_map.cc",
    "grit/ash_eche_bundle_resources_map.h",
    "ash_eche_bundle_resources.pak",
  ]
  output_dir = "$ash_webui_grit_output_dir"
}

grit("multidevice_debug_resources") {
  source =
      "//ash/webui/multidevice_debug/resources/multidevice_debug_resources.grd"

  outputs = [
    "grit/ash_multidevice_debug_resources.h",
    "grit/ash_multidevice_debug_resources_map.cc",
    "grit/ash_multidevice_debug_resources_map.h",
    "ash_multidevice_debug_resources.pak",
  ]

  output_dir = "$ash_webui_grit_output_dir"
}