chromium/content/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/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//third_party/tflite/features.gni")

extra_configs = [
  "//build/config/compiler:wexit_time_destructors",
  "//content:content_implementation",
  "//v8:external_startup_data",
]

content_app_deps = [
  "//base",
  "//base:i18n",
  "//content:export",
  "//content:sandbox_helper_win",
  "//content/public/common:common_sources",
  "//crypto",
  "//mojo/core/embedder",
  "//mojo/public/cpp/platform",
  "//ppapi/buildflags",
  "//services/tracing/public/cpp",
  "//ui/base",
  "//ui/gfx",
  "//ui/gfx/geometry",
]

if (is_win) {
  content_app_deps += [ "//sandbox" ]
} else if (is_android) {
  # Many of these are required for JNI registration.
  content_app_deps += [
    "//content/browser",
    "//content/child",
    "//content/public/android:content_app_jni",
    "//device/bluetooth",
    "//device/gamepad",
    "//gpu",
    "//media",
    "//media/capture",
    "//media/midi",
    "//net",
    "//skia",
    "//third_party/cpu_features:ndk_compat",
    "//ui/android",
    "//ui/events",
    "//ui/shell_dialogs",
  ]
}

if (is_ios) {
  content_app_deps += [ "//content/app/ios/appex:child_process_bridge" ]
}

if (enable_ppapi) {
  content_app_deps += [ "//content/ppapi_plugin:ppapi_plugin_sources" ]
}

# Compile content_main_runner_impl.[h, cc] in a separate target to exempt from
# GN header checking without exempting any other source file. These files
# includes headers of all process types and varies significantly per platform
# in between browser and child. Otherwise it would require many "nogncheck"
# annotations that would both be useless and add noise.
source_set("content_main_runner_app") {
  visibility = [ ":app" ]
  check_includes = false

  sources = [
    "content_main_runner_impl.cc",
    "content_main_runner_impl.h",
  ]

  configs += extra_configs
  deps = content_app_deps + [
           "//components/power_monitor",
           "//content/browser",
           "//content/gpu:gpu_sources",
           "//content/public/browser:browser_sources",
           "//content/public/gpu:gpu_sources",
           "//content/public/renderer:renderer_sources",
           "//content/public/utility:utility_sources",
           "//content/renderer",
           "//content/utility",
           "//content/zygote",
           "//third_party/tflite:buildflags",
           "//tools/v8_context_snapshot:buildflags",
         ]
  if (is_chromeos_lacros) {
    deps += [
      "//chromeos/startup",
      "//chromeos/startup:constants",
    ]
  }
  if (build_tflite_with_xnnpack) {
    deps += [ "//third_party/cpuinfo" ]
  }
}

source_set("app") {
  # TODO(thakis): The comment above content_main_runner_app suggests this
  # line shouldn't be here; try removing it.
  check_includes = false

  sources = [
    "content_main.cc",
    "initialize_mojo_core.cc",
    "mojo/mojo_init.cc",
    "mojo/mojo_init.h",
    "mojo_ipc_support.cc",
    "mojo_ipc_support.h",
  ]

  configs += extra_configs
  deps = content_app_deps + [ "//ipc" ]

  public_deps = [ ":content_main_runner_app" ]

  # Only the public target should depend on this. All other targets (even
  # internal content ones) should depend on the public one.
  visibility = [
    ":for_content_tests",  # See top of //content/BUILD.gn for why.
    "//content/public/app:*",
  ]

  if (is_android) {
    sources += [
      "android/content_child_process_service_delegate.cc",
      "android/content_jni_onload.cc",
      "android/content_main_android.cc",
      "android/content_main_android.h",
      "android/library_loader_hooks.cc",
      "android/library_loader_hooks.h",
    ]
    deps += [
      "//mojo/public/java/system:native_support",
      "//ui/gl",
    ]
  }

  if (is_mac) {
    sources += [
      "mac_init.h",
      "mac_init.mm",
    ]

    frameworks = [ "Foundation.framework" ]
  }
}

# See comment at the top of //content/BUILD.gn for how this works.
group("for_content_tests") {
  visibility = [ "//content/test/*" ]
  if (!is_component_build) {
    public_deps = [ ":app" ]
  }
}