chromium/components/named_mojo_ipc_server/BUILD.gn

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

import("//mojo/public/tools/bindings/mojom.gni")

mojom("testing_mojom") {
  testonly = true
  sources = [ "testing.test-mojom" ]
  deps = [ "//mojo/public/mojom/base" ]
}

static_library("named_mojo_ipc_server") {
  sources = [
    "connection_info.cc",
    "connection_info.h",
    "endpoint_options.h",
    "ipc_server.h",
    "named_mojo_ipc_server.cc",
    "named_mojo_ipc_server.h",
    "named_mojo_ipc_server_client_util.cc",
    "named_mojo_ipc_server_client_util.h",
    "named_mojo_ipc_util.cc",
    "named_mojo_ipc_util.h",
    "named_mojo_message_pipe_server.cc",
    "named_mojo_message_pipe_server.h",
    "named_mojo_server_endpoint_connector.cc",
    "named_mojo_server_endpoint_connector.h",
  ]
  deps = [
    "//base",
    "//mojo/public/cpp/bindings",
    "//mojo/public/cpp/platform",
    "//mojo/public/cpp/system",
  ]
  libs = []
  if (is_linux) {
    sources += [ "named_mojo_server_endpoint_connector_linux.cc" ]
  } else if (is_win) {
    sources += [ "named_mojo_server_endpoint_connector_win.cc" ]
  } else if (is_mac) {
    sources += [ "named_mojo_server_endpoint_connector_mac.cc" ]
    libs += [ "bsm" ]
  } else {
    sources += [ "named_mojo_server_endpoint_connector_unsupported.cc" ]
  }
}

static_library("test_support") {
  testonly = true

  sources = [
    "fake_ipc_server.cc",
    "fake_ipc_server.h",
    "named_mojo_ipc_test_util.cc",
    "named_mojo_ipc_test_util.h",
  ]
  deps = [
    ":named_mojo_ipc_server",
    ":testing_mojom",
    "//base",
    "//mojo/public/cpp/platform",
  ]
}

source_set("unit_tests") {
  testonly = true

  sources = []

  # Disable MojoIpcServerTest on unsupported platforms.
  if (is_linux || is_win || is_mac) {
    sources += [ "named_mojo_ipc_server_unittest.cc" ]
  }
  deps = [
    ":named_mojo_ipc_server",
    ":test_support",
    ":testing_mojom",
    "//base",
    "//base/test:test_support",
    "//components/test:test_support",
    "//mojo/public/cpp/bindings",
    "//mojo/public/cpp/platform",
    "//mojo/public/cpp/system",
    "//remoting/host/mojom",
    "//testing/gmock",
    "//testing/gtest",
  ]
}