chromium/google_apis/gcm/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("//testing/test.gni")
import("//third_party/protobuf/proto_library.gni")

component("gcm") {
  sources = [
    "base/gcm_constants.cc",
    "base/gcm_constants.h",
    "base/gcm_features.cc",
    "base/gcm_features.h",
    "base/gcm_util.cc",
    "base/gcm_util.h",
    "base/mcs_message.cc",
    "base/mcs_message.h",
    "base/mcs_util.cc",
    "base/mcs_util.h",
    "base/socket_stream.cc",
    "base/socket_stream.h",
    "engine/account_mapping.cc",
    "engine/account_mapping.h",
    "engine/checkin_request.cc",
    "engine/checkin_request.h",
    "engine/connection_event_tracker.cc",
    "engine/connection_event_tracker.h",
    "engine/connection_factory.cc",
    "engine/connection_factory.h",
    "engine/connection_factory_impl.cc",
    "engine/connection_factory_impl.h",
    "engine/connection_handler.cc",
    "engine/connection_handler.h",
    "engine/connection_handler_impl.cc",
    "engine/connection_handler_impl.h",
    "engine/gcm_registration_request_handler.cc",
    "engine/gcm_registration_request_handler.h",
    "engine/gcm_store.cc",
    "engine/gcm_store.h",
    "engine/gcm_store_impl.cc",
    "engine/gcm_store_impl.h",
    "engine/gcm_unregistration_request_handler.cc",
    "engine/gcm_unregistration_request_handler.h",
    "engine/gservices_settings.cc",
    "engine/gservices_settings.h",
    "engine/gservices_switches.cc",
    "engine/gservices_switches.h",
    "engine/heartbeat_manager.cc",
    "engine/heartbeat_manager.h",
    "engine/instance_id_delete_token_request_handler.cc",
    "engine/instance_id_delete_token_request_handler.h",
    "engine/instance_id_get_token_request_handler.cc",
    "engine/instance_id_get_token_request_handler.h",
    "engine/mcs_client.cc",
    "engine/mcs_client.h",
    "engine/registration_request.cc",
    "engine/registration_request.h",
    "engine/unregistration_request.cc",
    "engine/unregistration_request.h",
    "monitoring/gcm_stats_recorder.h",
  ]

  defines = [ "GCM_IMPLEMENTATION" ]

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  public_deps = [
    ":proto",
    "//google_apis",
  ]
  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//mojo/public/cpp/system:system",
    "//net",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
    "//third_party/leveldatabase",
    "//url",
  ]
}

proto_library("proto") {
  # This is part of the gcm component.
  visibility = [ ":gcm" ]
  sources = [
    "protocol/android_checkin.proto",
    "protocol/checkin.proto",
    "protocol/mcs.proto",
  ]

  cc_generator_options = "dllexport_decl=GCM_EXPORT:"
  cc_include = "google_apis/gcm/base/gcm_export.h"
  component_build_force_source_set = true
  defines = [ "GCM_IMPLEMENTATION" ]
}

static_library("test_support") {
  testonly = true
  sources = [
    "base/fake_encryptor.cc",
    "base/fake_encryptor.h",
    "engine/fake_connection_factory.cc",
    "engine/fake_connection_factory.h",
    "engine/fake_connection_handler.cc",
    "engine/fake_connection_handler.h",
    "monitoring/fake_gcm_stats_recorder.cc",
    "monitoring/fake_gcm_stats_recorder.h",
  ]

  public_deps = [ ":gcm" ]
  deps = [
    "//base",
    "//mojo/public/cpp/system:system",
    "//net",
    "//net:test_support",
    "//testing/gtest",
  ]
}

# A standalone MCS (mobile connection server) client.
if (!is_ios) {
  executable("mcs_probe") {
    testonly = true
    sources = [ "tools/mcs_probe.cc" ]

    deps = [
      ":gcm",
      ":test_support",
      "//base",
      "//build/win:default_exe_manifest",
      "//mojo/core/embedder",
      "//net",
      "//net:test_support",
      "//services/network:network_service",
      "//services/network:test_support",
      "//services/network/public/cpp",
      "//services/network/public/mojom",
      "//third_party/protobuf:protobuf_lite",
    ]
  }
}

test("gcm_unit_tests") {
  sources = [
    "base/mcs_message_unittest.cc",
    "base/mcs_util_unittest.cc",
    "base/socket_stream_unittest.cc",
    "engine/account_mapping_unittest.cc",
    "engine/checkin_request_unittest.cc",
    "engine/connection_event_tracker_unittest.cc",
    "engine/connection_factory_impl_unittest.cc",
    "engine/connection_handler_impl_unittest.cc",
    "engine/gcm_request_test_base.cc",
    "engine/gcm_request_test_base.h",
    "engine/gcm_store_impl_unittest.cc",
    "engine/gservices_settings_unittest.cc",
    "engine/heartbeat_manager_unittest.cc",
    "engine/mcs_client_unittest.cc",
    "engine/registration_request_unittest.cc",
    "engine/unregistration_request_unittest.cc",
  ]

  deps = [
    ":gcm",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//google_apis",
    "//google_apis:run_all_unittests",
    "//google_apis:test_support",
    "//mojo/public/cpp/system:system",
    "//net",
    "//net:test_support",
    "//services/network:network_service",
    "//services/network:test_support",
    "//testing/gtest",
    "//third_party/protobuf:protobuf_lite",
  ]
  if (is_android) {
    deps += [ "//net/android:net_java" ]
  }
}