chromium/ui/base/idle/BUILD.gn

# Copyright 2019 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/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")

if (is_mac) {
  import("//build/config/mac/rules.gni")
}

component("idle") {
  output_name = "ui_base_idle"

  defines = [ "IS_UI_BASE_IDLE_IMPL" ]

  # All targets in this file are allowed to access any of the headers.
  friend = [ ":*" ]

  public = [
    "idle.h",
    "idle_polling_service.h",
    "idle_time_provider.h",
  ]

  deps = [
    "//base",
    "//ui/base",
  ]

  if (is_chromeos_ash) {
    deps += [ "//chromeos/ash/components/dbus/session_manager" ]
  }

  sources = [
    "idle.cc",
    "idle.h",
    "idle_internal.cc",
    "idle_internal.h",
    "idle_polling_service.cc",
    "idle_polling_service.h",
    "idle_time_provider.h",
  ]

  if (is_chromeos_ash) {
    sources += [ "idle_chromeos.cc" ]
  }

  if (is_chromeos_lacros) {
    sources += [ "idle_lacros.cc" ]
    deps += [ "//chromeos/lacros" ]
  }

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

  if (is_ios) {
    sources += [ "idle_ios.mm" ]
  }

  if (is_win) {
    sources += [ "idle_win.cc" ]
  }

  if (is_fuchsia) {
    sources += [ "idle_fuchsia.cc" ]
  }

  if (is_linux) {
    sources += [ "idle_linux.cc" ]
    deps += [ "//ui/display" ]
    if (use_dbus) {
      deps += [ "//dbus" ]
      defines += [ "USE_DBUS" ]
    }
  }

  if (is_android) {
    deps += [ "//ui/base:ui_base_jni_headers" ]
    sources -= [ "idle.cc" ]
    sources += [ "idle_android.cc" ]
  }

  if (is_mac) {
    frameworks = [
      "AppKit.framework",
      "Carbon.framework",
      "Foundation.framework",
    ]
  }
}

static_library("test_support") {
  testonly = true

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

  deps = [
    ":idle",
    "//base",
  ]
}