chromium/chrome/app/BUILD.gn

# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chrome_build.gni")
import("//build/config/chromebox_for_meetings/buildflags.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/locales.gni")
import("//build/config/ozone.gni")
import("//build/config/ui.gni")
import("//chrome/common/features.gni")
import("//components/nacl/features.gni")
import("//crypto/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/ipc_fuzzer/ipc_fuzzer.gni")

assert(!is_fuchsia, "Fuchsia shouldn't use anything in //chrome")

if (is_android) {
  import("//build/config/android/rules.gni")
}

# This target is for dependency tracking for the command ID header.
source_set("command_ids") {
  sources = [ "chrome_command_ids.h" ]
  public_deps = [
    "//build:branding_buildflags",
    "//build:chromeos_buildflags",
    "//services/screen_ai/buildflags",
  ]
  deps = [ "//ui/base:constants" ]
}

# On Windows, links chrome_dll.rc. On other platforms, does nothing so you can
# unconditionally depend on it.
source_set("chrome_dll_resources") {
  # This source is added unconditionally for include checking on non-Windows
  # platforms.
  sources = [ "chrome_dll_resource.h" ]

  deps = [ ":command_ids" ]

  if (is_win) {
    sources += [
      "chrome_dll.rc",
      "etw_events/chrome_events_win.rc",
    ]

    deps += [
      "//build:branding_buildflags",
      "//printing/buildflags",
    ]
  }
}

if (is_win) {
  source_set("chrome_exe_main_exports") {
    sources = [ "chrome_exe_main_win.h" ]
  }

  source_set("exit_code_watcher") {
    sources = [
      "exit_code_watcher_win.cc",
      "exit_code_watcher_win.h",
    ]
    public_deps = [ "//base:base" ]
  }

  source_set("win_unit_tests") {
    testonly = true
    sources = [
      "chrome_crash_reporter_client_win_unittest.cc",
      "exit_code_watcher_win_unittest.cc",
    ]
    deps = [
      ":exit_code_watcher",
      "//base:base",
      "//base/test:test_support",
      "//chrome/chrome_elf:crash",
      "//testing/gtest:gtest",
    ]
  }
}

if (is_android) {
  android_generated_java_resources =
      [ "java/res/values/generated_resources.xml" ] +
      process_file_template(
          android_bundle_locales_as_resources,
          [ "java/res/values-{{source_name_part}}/generated_resources.xml" ])

  strings_java_resources = [ "java/res/values/${branding_path_product}_strings.xml" ] + process_file_template(
                               android_bundle_locales_as_resources,
                               [ "java/res/values-{{source_name_part}}/${branding_path_product}_strings.xml" ])
}

grit("generated_resources") {
  source = "generated_resources.grd"
  defines = chrome_grit_defines + [ "is_cfm=${is_cfm}" ]
  output_dir = "$root_gen_dir/chrome"
  outputs =
      [ "grit/generated_resources.h" ] +
      process_file_template(all_chrome_locales,
                            [ "generated_resources_{{source_name_part}}.pak" ])
  if (is_android) {
    outputs += android_generated_java_resources
  }
}

if (is_android) {
  java_strings_grd_prebuilt("java_strings_grd") {
    grit_output_dir = "$root_gen_dir/chrome/java/res"
    generated_files =
        rebase_path(android_generated_java_resources, "java/res", ".") +
        rebase_path(strings_java_resources, "java/res", ".")
    deps = [
      ":branded_strings",
      ":generated_resources",
    ]
  }
}

grit("branded_strings") {
  source = "${branding_path_product}_strings.grd"
  defines = chrome_grit_defines
  output_dir = "$root_gen_dir/chrome"
  outputs = [ "grit/branded_strings.h" ] +
            process_file_template(
                all_chrome_locales,
                [ "${branding_path_product}_strings_{{source_name_part}}.pak" ])

  if (is_android) {
    outputs += strings_java_resources
  }
}

static_library("test_support") {
  testonly = true
  visibility = [ "//chrome/test:test_support" ]

  sources = [
    "chrome_main_delegate.cc",
    "chrome_main_delegate.h",
    "startup_timestamps.h",
  ]

  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//chrome/browser",
    "//chrome/browser:buildflags",
    "//chrome/browser/policy:path_parser",
    "//chrome/child",
    "//chrome/common",
    "//chrome/common:version_header",
    "//chrome/gpu",
    "//chrome/renderer",
    "//chrome/utility",
    "//components/about_ui",
    "//components/crash/core/app",
    "//components/crash/core/app:test_support",
    "//components/devtools/devtools_pipe",
    "//components/memory_system",
    "//components/nacl/common:buildflags",
    "//components/startup_metric_utils",
    "//content/public/app",
    "//content/public/common",
    "//extensions/buildflags",
    "//ppapi/buildflags",
    "//printing/buildflags",
    "//services/tracing/public/cpp",
    "//ui/base",
    "//v8:v8_headers",
  ]
  public_deps = []

  if (is_android) {
    deps += [
      "//chrome/browser/flags:flags_android",
      "//components/crash/android:crash_android",
    ]
  }

  if (is_mac) {
    sources += [ "chrome_main_mac.mm" ]

    deps += [ "//chrome:chrome_framework" ]
  }

  if (is_win) {
    deps += [
      "//chrome/chrome_elf:test_stubs",
      "//chrome/install_static:install_static_util",
      "//sandbox/win:sandbox",
    ]
  }

  if (is_chromeos) {
    deps += [ "//chromeos/dbus/constants" ]
  }

  if (is_chromeos_ash) {
    deps += [
      "//ash/components/arc:arc_base_utils",
      "//ash/constants",
      "//chrome/browser/ash/boot_times_recorder",
      "//chrome/browser/ash/dbus",
      "//chrome/browser/ash/locale",
      "//chrome/browser/ash/schedqos",
      "//chromeos",
      "//chromeos/ash/components/memory:memory",
    ]
    public_deps += [ "//ui/lottie" ]
  }

  if (is_chromeos_lacros) {
    deps += [
      "//chromeos/crosapi/cpp:crosapi_constants",
      "//chromeos/crosapi/mojom",
      "//chromeos/lacros",
      "//chromeos/lacros:lacros_paths",
      "//chromeos/lacros/dbus",
      "//chromeos/startup",
    ]
  }

  if (use_ozone) {
    deps += [ "//ui/ozone" ]
    if (is_linux) {
      deps += [ "//ui/linux:display_server_utils" ]
    }
  }

  if (enable_plugins && enable_nacl) {
    deps += [
      "//components/nacl/browser",
      "//components/nacl/renderer/plugin:nacl_trusted_plugin",
    ]
  }
}