chromium/mojo/public/cpp/platform/BUILD.gn

# Copyright 2018 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/nacl/config.gni")
import("//components/nacl/toolchain.gni")

component("platform") {
  output_name = "mojo_cpp_platform"

  public = [
    "platform_channel.h",
    "platform_channel_endpoint.h",
    "platform_channel_server_endpoint.h",
    "platform_handle.h",
    "platform_handle_internal.h",
  ]

  sources = [
    "platform_channel.cc",
    "platform_channel_endpoint.cc",
    "platform_channel_server_endpoint.cc",
    "platform_handle.cc",
  ]

  if (is_android && !is_robolectric) {
    public += [ "binder_exchange.h" ]
    sources += [ "binder_exchange.cc" ]
  }

  if (is_posix && !is_mac && !is_nacl) {
    public += [ "socket_utils_posix.h" ]
    sources += [ "socket_utils_posix.cc" ]
  }

  if (is_win || is_mac || (is_posix && !is_nacl && !is_ios)) {
    public += [ "platform_channel_server.h" ]
    sources += [ "platform_channel_server.cc" ]
  }

  if (is_win) {
    public += [ "platform_handle_security_util_win.h" ]
    sources += [
      "platform_channel_server_win.cc",
      "platform_handle_security_util_win.cc",
    ]
  } else if (is_mac) {
    sources += [ "platform_channel_server_mac.cc" ]
  } else if (is_posix && !is_nacl) {
    sources += [ "platform_channel_server_posix.cc" ]
  }

  public_deps = [
    "//base",
    "//mojo:buildflags",
    "//mojo/public/c/system:headers",
  ]

  deps = [ "//mojo/core/embedder:features" ]

  if (is_posix && !is_nacl && !is_minimal_toolchain && !is_mac) {
    sources += [ "named_platform_channel_posix.cc" ]
    deps += [ "//net" ]
  }

  if (is_mac) {
    sources += [ "named_platform_channel_mac.cc" ]
  }

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

  if (is_fuchsia) {
    public_deps += [
      "//third_party/fuchsia-sdk/sdk/pkg/fdio",
      "//third_party/fuchsia-sdk/sdk/pkg/zx",
    ]
  } else {
    sources += [ "named_platform_channel.cc" ]
    public += [ "named_platform_channel.h" ]
  }

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

  defines = [ "IS_MOJO_CPP_PLATFORM_IMPL" ]
}