chromium/components/gcm_driver/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/buildflag_header.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//components/gcm_driver/config.gni")

buildflag_header("gcm_buildflags") {
  header = "gcm_buildflags.h"
  flags = [ "USE_GCM_FROM_PLATFORM=$use_gcm_from_platform" ]
}

static_library("gcm_driver") {
  sources = [
    "features.cc",
    "features.h",
    "gcm_activity.cc",
    "gcm_activity.h",
    "gcm_app_handler.cc",
    "gcm_app_handler.h",
    "gcm_backoff_policy.cc",
    "gcm_backoff_policy.h",
    "gcm_client.cc",
    "gcm_client.h",
    "gcm_connection_observer.cc",
    "gcm_connection_observer.h",
    "gcm_delayed_task_controller.cc",
    "gcm_delayed_task_controller.h",
    "gcm_driver.cc",
    "gcm_driver.h",
    "gcm_driver_constants.cc",
    "gcm_driver_constants.h",
    "gcm_internals_constants.cc",
    "gcm_internals_constants.h",
    "gcm_internals_helper.cc",
    "gcm_internals_helper.h",
    "gcm_profile_service.cc",
    "gcm_profile_service.h",
    "registration_info.cc",
    "registration_info.h",
    "system_encryptor.cc",
    "system_encryptor.h",
  ]

  public_deps = [
    "//base",
    "//components/gcm_driver/common",
    "//components/gcm_driver/crypto",
    "//components/gcm_driver/instance_id",
    "//components/version_info:channel",
    "//crypto",
  ]

  deps = [
    ":gcm_buildflags",
    "//base:i18n",
    "//components/crx_file",
    "//components/keyed_service/core",
    "//components/os_crypt/sync",
    "//components/pref_registry",
    "//components/prefs",
    "//components/signin/public/identity_manager",
    "//components/version_info",
    "//google_apis",
    "//google_apis/gcm",
    "//net",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
    "//url:url",
  ]

  # This target goes with these other deps and they can include headers from
  # each other.
  allow_circular_includes_from = [
    "//components/gcm_driver/crypto",
    "//components/gcm_driver/instance_id",
  ]

  if (use_gcm_from_platform) {
    assert(is_android)
    sources += [
      "gcm_driver_android.cc",
      "gcm_driver_android.h",
      "gcm_stats_recorder_android.cc",
      "gcm_stats_recorder_android.h",
    ]
  } else {
    sources += [
      "account_tracker.cc",
      "account_tracker.h",
      "gcm_account_mapper.cc",
      "gcm_account_mapper.h",
      "gcm_account_tracker.cc",
      "gcm_account_tracker.h",
      "gcm_client_factory.cc",
      "gcm_client_factory.h",
      "gcm_client_impl.cc",
      "gcm_client_impl.h",
      "gcm_desktop_utils.cc",
      "gcm_desktop_utils.h",
      "gcm_driver_desktop.cc",
      "gcm_driver_desktop.h",
      "gcm_stats_recorder_impl.cc",
      "gcm_stats_recorder_impl.h",
    ]
    deps += [
      "//build:chromeos_buildflags",
      "//components/crx_file",
      "//components/version_info:version_info",
      "//google_apis/gcm",
    ]
  }

  if (is_android) {
    deps += [ "android:jni_headers" ]
  }
}

static_library("test_support") {
  testonly = true
  sources = [
    "fake_gcm_app_handler.cc",
    "fake_gcm_app_handler.h",
    "fake_gcm_driver.cc",
    "fake_gcm_driver.h",
    "fake_gcm_profile_service.cc",
    "fake_gcm_profile_service.h",
  ]

  public_deps = [ ":gcm_driver" ]
  deps = [
    "//base",
    "//components/gcm_driver/instance_id:test_support",
    "//google_apis/gcm:test_support",
    "//net",
    "//services/network:test_support",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
    "//testing/gtest",
  ]

  # This target goes with Instance ID and they can include headers from each
  # other.
  allow_circular_includes_from =
      [ "//components/gcm_driver/instance_id:test_support" ]

  if (is_ios) {
    sources -= [
      "fake_gcm_profile_service.cc",
      "fake_gcm_profile_service.h",
    ]
  }

  if (!use_gcm_from_platform) {
    sources += [
      "fake_gcm_client.cc",
      "fake_gcm_client.h",
      "fake_gcm_client_factory.cc",
      "fake_gcm_client_factory.h",
    ]
    deps += [ "//google_apis/gcm:test_support" ]
  }
}

# This is part of the components_unittests BUILD target.
source_set("unit_tests") {
  testonly = true

  sources = [ "gcm_delayed_task_controller_unittest.cc" ]

  deps = [
    ":gcm_driver",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//components/gcm_driver/crypto",
    "//components/prefs:test_support",
    "//google_apis:test_support",
    "//google_apis/gcm:test_support",
    "//net:test_support",
    "//testing/gtest",
    "//third_party/leveldatabase",
    "//third_party/protobuf:protobuf_lite",
  ]

  if (is_android) {
    sources += [ "gcm_stats_recorder_android_unittest.cc" ]
  }

  if (!use_gcm_from_platform) {
    sources += [
      "account_tracker_unittest.cc",
      "gcm_account_mapper_unittest.cc",
      "gcm_account_tracker_unittest.cc",
      "gcm_client_impl_unittest.cc",
      "gcm_driver_desktop_unittest.cc",
      "gcm_driver_unittest.cc",
      "gcm_stats_recorder_impl_unittest.cc",
    ]

    deps += [
      "//build:chromeos_buildflags",
      "//components/signin/public/identity_manager:test_support",
    ]
  }
}