chromium/third_party/nearby/BUILD.gn

# Copyright 2020 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/util/process_version.gni")
import("//third_party/protobuf/proto_library.gni")
if (is_chromeos_device) {
  import("//build/config/chromeos/rules.gni")
}
import("//build/config/rust.gni")

assert(enable_rust, "Nearby Presence requires rust to be enabled")

# Nearby Config
config("nearby_include_config") {
  include_dirs = [
    "src",
    "$root_gen_dir/third_party/nearby",

    # For WebRTC APIs.
    "//third_party",

    # For bloom filter.
    "//third_party/smhasher",

    # For beto-core apis
    "//third_party/beto-core/src/nearby/presence/np_cpp_ffi/include",
    "//third_party/beto-core/src/nearby/presence/np_c_ffi/include/cpp",
  ]
}

config("nearby_defines") {
  defines = [
    "NEARBY_CHROMIUM=1",
    "USE_RUST_DECODER=1",
  ]
}

###############################################################################
# src/connections
###############################################################################
# src/connections
source_set("connections") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [ "src/connections/core.cc" ]
  public = [ "src/connections/core.h" ]
  public_deps = [
    ":analytics_event_logger",
    ":connections_enums_proto",
    ":connections_implementation",
    ":connections_types",
    ":platform_public_comm",
    ":platform_public_logging",
    ":platform_public_types",
    ":v3_types",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("connections_types") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/connections/advertising_options.cc",
    "src/connections/connection_options.cc",
    "src/connections/discovery_options.cc",
    "src/connections/payload.cc",
    "src/connections/status.cc",
    "src/connections/strategy.cc",
  ]
  public = [
    "src/connections/advertising_options.h",
    "src/connections/connection_options.h",
    "src/connections/discovery_options.h",
    "src/connections/listeners.h",
    "src/connections/options_base.h",
    "src/connections/out_of_band_connection_metadata.h",
    "src/connections/params.h",
    "src/connections/payload.h",
    "src/connections/power_level.h",
    "src/connections/status.h",
    "src/connections/strategy.h",
  ]
  public_deps = [
    ":connections_enums_proto",
    ":interop_authentication_status",
    ":platform_base",
    ":platform_public_comm",
    ":platform_public_logging",
    ":platform_public_types",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/connections/implementation
source_set("connections_implementation") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/connections/implementation/base_bwu_handler.cc",
    "src/connections/implementation/base_endpoint_channel.cc",
    "src/connections/implementation/base_pcp_handler.cc",
    "src/connections/implementation/ble_advertisement.cc",
    "src/connections/implementation/ble_endpoint_channel.cc",
    "src/connections/implementation/ble_v2_endpoint_channel.cc",
    "src/connections/implementation/bluetooth_bwu_handler.cc",
    "src/connections/implementation/bluetooth_device_name.cc",
    "src/connections/implementation/bluetooth_endpoint_channel.cc",
    "src/connections/implementation/bwu_manager.cc",
    "src/connections/implementation/client_proxy.cc",
    "src/connections/implementation/connections_authentication_transport.cc",
    "src/connections/implementation/encryption_runner.cc",
    "src/connections/implementation/endpoint_channel_manager.cc",
    "src/connections/implementation/endpoint_manager.cc",
    "src/connections/implementation/injected_bluetooth_device_store.cc",
    "src/connections/implementation/internal_payload.cc",
    "src/connections/implementation/internal_payload_factory.cc",
    "src/connections/implementation/offline_frames.cc",
    "src/connections/implementation/offline_frames_validator.cc",
    "src/connections/implementation/offline_service_controller.cc",
    "src/connections/implementation/p2p_cluster_pcp_handler.cc",
    "src/connections/implementation/p2p_point_to_point_pcp_handler.cc",
    "src/connections/implementation/p2p_star_pcp_handler.cc",
    "src/connections/implementation/payload_manager.cc",
    "src/connections/implementation/pcp_manager.cc",
    "src/connections/implementation/reconnect_manager.cc",
    "src/connections/implementation/service_controller_router.cc",
    "src/connections/implementation/webrtc_bwu_handler.cc",
    "src/connections/implementation/webrtc_endpoint_channel.cc",
    "src/connections/implementation/wifi_direct_bwu_handler.cc",
    "src/connections/implementation/wifi_direct_endpoint_channel.cc",
    "src/connections/implementation/wifi_hotspot_bwu_handler.cc",
    "src/connections/implementation/wifi_hotspot_endpoint_channel.cc",
    "src/connections/implementation/wifi_lan_bwu_handler.cc",
    "src/connections/implementation/wifi_lan_endpoint_channel.cc",
    "src/connections/implementation/wifi_lan_service_info.cc",
  ]
  public = [
    "src/connections/implementation/base_bwu_handler.h",
    "src/connections/implementation/base_endpoint_channel.h",
    "src/connections/implementation/base_pcp_handler.h",
    "src/connections/implementation/ble_advertisement.h",
    "src/connections/implementation/ble_endpoint_channel.h",
    "src/connections/implementation/ble_v2_endpoint_channel.h",
    "src/connections/implementation/bluetooth_bwu_handler.h",
    "src/connections/implementation/bluetooth_device_name.h",
    "src/connections/implementation/bluetooth_endpoint_channel.h",
    "src/connections/implementation/bwu_handler.h",
    "src/connections/implementation/bwu_manager.h",
    "src/connections/implementation/client_proxy.h",
    "src/connections/implementation/connections_authentication_transport.h",
    "src/connections/implementation/encryption_runner.h",
    "src/connections/implementation/endpoint_channel.h",
    "src/connections/implementation/endpoint_channel_manager.h",
    "src/connections/implementation/endpoint_manager.h",
    "src/connections/implementation/injected_bluetooth_device_store.h",
    "src/connections/implementation/internal_payload.h",
    "src/connections/implementation/internal_payload_factory.h",
    "src/connections/implementation/message_lite.h",
    "src/connections/implementation/offline_frames.h",
    "src/connections/implementation/offline_frames_validator.h",
    "src/connections/implementation/offline_service_controller.h",
    "src/connections/implementation/p2p_cluster_pcp_handler.h",
    "src/connections/implementation/p2p_point_to_point_pcp_handler.h",
    "src/connections/implementation/p2p_star_pcp_handler.h",
    "src/connections/implementation/payload_manager.h",
    "src/connections/implementation/pcp.h",
    "src/connections/implementation/pcp_handler.h",
    "src/connections/implementation/pcp_manager.h",
    "src/connections/implementation/reconnect_manager.h",
    "src/connections/implementation/service_controller.h",
    "src/connections/implementation/service_controller_router.h",
    "src/connections/implementation/webrtc_bwu_handler.h",
    "src/connections/implementation/webrtc_endpoint_channel.h",
    "src/connections/implementation/wifi_direct_bwu_handler.h",
    "src/connections/implementation/wifi_direct_endpoint_channel.h",
    "src/connections/implementation/wifi_hotspot_bwu_handler.h",
    "src/connections/implementation/wifi_hotspot_endpoint_channel.h",
    "src/connections/implementation/wifi_lan_bwu_handler.h",
    "src/connections/implementation/wifi_lan_endpoint_channel.h",
    "src/connections/implementation/wifi_lan_service_info.h",
  ]
  public_deps = [
    ":connections_enums_proto",
    ":connections_implementation_analytics",
    ":connections_implementation_flags",
    ":connections_implementation_mediums",
    ":connections_implementation_mediums_webrtc",
    ":connections_types",
    ":interop_authentication_status",
    ":interop_authentication_transport_interface",
    ":interop_device",
    ":offline_wire_formats_proto",
    ":platform_base",
    ":platform_base_cancellation_flag",
    ":platform_base_error_code_recorder",
    ":platform_base_util",
    ":platform_impl_shared_file",
    ":platform_public_comm",
    ":platform_public_logging",
    ":platform_public_types",
    ":v3_types",
    "//third_party/abseil-cpp:absl",
    "//third_party/protobuf:protobuf_lite",
    "//third_party/ukey2",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

source_set("connections_test_util") {
  testonly = true
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [ "src/connections/implementation/mock_service_controller_router.h" ]
  deps = [
    ":connections_implementation",
    "//third_party/googletest:gmock",
  ]
}

# src/connections/implementation/analytics
source_set("connections_implementation_analytics") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/connections/implementation/analytics/analytics_recorder.cc",
    "src/connections/implementation/analytics/throughput_recorder.cc",
  ]
  public = [
    "src/connections/implementation/analytics/analytics_recorder.h",
    "src/connections/implementation/analytics/packet_meta_data.h",
    "src/connections/implementation/analytics/throughput_recorder.h",
  ]
  public_deps = [
    ":analytics_event_logger",
    ":connections_enums_proto",
    ":connections_log_proto",
    ":connections_types",
    ":error_code_enums_proto",
    ":platform_base",
    ":platform_base_error_code_recorder",
    ":platform_public_logging",
    ":platform_public_types",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/connections/implementation/flags
source_set("connections_implementation_flags") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [
    "src/connections/implementation/flags/nearby_connections_feature_flags.h",
  ]
  public_deps = [
    ":flags",
    ":platform_base",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/connections/implementation/mediums
source_set("connections_implementation_mediums") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/connections/implementation/mediums/ble.cc",
    "src/connections/implementation/mediums/ble_v2.cc",
    "src/connections/implementation/mediums/ble_v2/advertisement_read_result.cc",
    "src/connections/implementation/mediums/ble_v2/ble_advertisement.cc",
    "src/connections/implementation/mediums/ble_v2/ble_advertisement_header.cc",
    "src/connections/implementation/mediums/ble_v2/ble_packet.cc",
    "src/connections/implementation/mediums/ble_v2/ble_utils.cc",
    "src/connections/implementation/mediums/ble_v2/bloom_filter.cc",
    "src/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.cc",
    "src/connections/implementation/mediums/ble_v2/instant_on_lost_advertisement.cc",
    "src/connections/implementation/mediums/ble_v2/instant_on_lost_manager.cc",
    "src/connections/implementation/mediums/bluetooth_classic.cc",
    "src/connections/implementation/mediums/bluetooth_radio.cc",
    "src/connections/implementation/mediums/mediums.cc",
    "src/connections/implementation/mediums/multiplex/multiplex_frames.cc",
    "src/connections/implementation/mediums/multiplex/multiplex_output_stream.cc",
    "src/connections/implementation/mediums/multiplex/multiplex_socket.cc",
    "src/connections/implementation/mediums/webrtc.cc",
    "src/connections/implementation/mediums/wifi_direct.cc",
    "src/connections/implementation/mediums/wifi_hotspot.cc",
    "src/connections/implementation/mediums/wifi_lan.cc",
  ]
  public = [
    "src/connections/implementation/mediums/ble.h",
    "src/connections/implementation/mediums/ble_v2.h",
    "src/connections/implementation/mediums/ble_v2/advertisement_read_result.h",
    "src/connections/implementation/mediums/ble_v2/ble_advertisement.h",
    "src/connections/implementation/mediums/ble_v2/ble_advertisement_header.h",
    "src/connections/implementation/mediums/ble_v2/ble_packet.h",
    "src/connections/implementation/mediums/ble_v2/ble_utils.h",
    "src/connections/implementation/mediums/ble_v2/bloom_filter.h",
    "src/connections/implementation/mediums/ble_v2/discovered_peripheral_callback.h",
    "src/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.h",
    "src/connections/implementation/mediums/ble_v2/instant_on_lost_advertisement.h",
    "src/connections/implementation/mediums/ble_v2/instant_on_lost_manager.h",
    "src/connections/implementation/mediums/bluetooth_classic.h",
    "src/connections/implementation/mediums/bluetooth_radio.h",
    "src/connections/implementation/mediums/lost_entity_tracker.h",
    "src/connections/implementation/mediums/mediums.h",
    "src/connections/implementation/mediums/multiplex/multiplex_frames.h",
    "src/connections/implementation/mediums/multiplex/multiplex_output_stream.h",
    "src/connections/implementation/mediums/multiplex/multiplex_socket.h",
    "src/connections/implementation/mediums/webrtc.h",
    "src/connections/implementation/mediums/wifi_direct.h",
    "src/connections/implementation/mediums/wifi_hotspot.h",
    "src/connections/implementation/mediums/wifi_lan.h",
  ]
  public_deps = [
    ":ble_frames_proto",
    ":connections_implementation_flags",
    ":connections_implementation_mediums_webrtc",
    ":connections_types",
    ":multiplex_frames_proto",
    ":platform_api_types",
    ":platform_base",
    ":platform_base_cancellation_flag",
    ":platform_base_util",
    ":platform_public_comm",
    ":platform_public_logging",
    ":platform_public_types",
    ":web_rtc_signaling_frames_proto",
    "//third_party/abseil-cpp:absl",
    "//third_party/smhasher:murmurhash3",
    "//third_party/webrtc_overrides:webrtc_component",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

source_set("connections_implementation_mediums_utils") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/connections/implementation/mediums/utils.cc",
    "src/connections/implementation/mediums/webrtc_peer_id.cc",
  ]
  public = [
    "//third_party/abseil-cpp:absl",
    "src/connections/implementation/mediums/utils.h",
    "src/connections/implementation/mediums/webrtc_peer_id.h",
    "src/connections/implementation/mediums/webrtc_socket.h",
  ]
  public_deps = [
    ":connections_implementation_mediums_webrtc_data_types",
    ":offline_wire_formats_proto",
    ":platform_base",
    ":platform_public_types",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

source_set("connections_implementation_mediums_webrtc_data_types") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources =
      [ "src/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc" ]
  public =
      [ "src/connections/implementation/mediums/webrtc/webrtc_socket_impl.h" ]
  public_deps = [
    ":connections_types",
    ":platform_base",
    ":platform_public_types",
    "//third_party/webrtc_overrides:webrtc_component",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

source_set("connections_implementation_mediums_webrtc") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/connections/implementation/mediums/webrtc/connection_flow.cc",
    "src/connections/implementation/mediums/webrtc/signaling_frames.cc",
  ]
  public = [
    "src/connections/implementation/mediums/webrtc/connection_flow.h",
    "src/connections/implementation/mediums/webrtc/data_channel_listener.h",
    "src/connections/implementation/mediums/webrtc/local_ice_candidate_listener.h",
    "src/connections/implementation/mediums/webrtc/session_description_wrapper.h",
    "src/connections/implementation/mediums/webrtc/signaling_frames.h",
  ]
  public_deps = [
    ":connections_implementation_mediums_utils",
    ":connections_implementation_mediums_webrtc_data_types",
    ":connections_types",
    ":platform_base",
    ":platform_public_comm",
    ":platform_public_logging",
    ":platform_public_types",
    ":web_rtc_signaling_frames_proto",
    "//third_party/abseil-cpp:absl",
    "//third_party/webrtc_overrides:webrtc_component",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/connections/v3
source_set("v3_types") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [ "src/connections/v3/connections_device.cc" ]
  public = [
    "src/connections/v3/bandwidth_info.h",
    "src/connections/v3/connection_listening_options.h",
    "src/connections/v3/connection_result.h",
    "src/connections/v3/connections_device.h",
    "src/connections/v3/connections_device_provider.h",
    "src/connections/v3/listeners.h",
    "src/connections/v3/params.h",
  ]
  public_deps = [
    ":connections_enums_proto",
    ":connections_types",
    ":interop_device",
    ":platform_base_connection_info",
    ":platform_public_types",
    "//crypto:crypto",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

###############################################################################
# src/internal
###############################################################################
# src/internal/analytics
source_set("analytics_event_logger") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [ "src/internal/analytics/event_logger.h" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  public_deps = [
    ":connections_log_proto",
    ":fast_pair_log_proto",
    ":sharing_log_proto",
  ]
}

# src/internal/crypto
# NOTE: This does not include any of the classes found in //crypto.
# //third_party/nearby/internal/crypto_cros is a subset of //crypto whereas
# //third_party/nearby/internal/crypto contains completely different classes.
source_set("nearby_crypto") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [ "src/internal/crypto/ed25519.cc" ]
  public = [ "src/internal/crypto/ed25519.h" ]
  public_deps = [
    ":platform_base_logging",
    ":platform_public_types",
    "//third_party/abseil-cpp:absl",
    "//third_party/boringssl:boringssl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/internal/flags
source_set("flags") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [ "src/internal/flags/nearby_flags.cc" ]
  public = [
    "src/internal/flags/default_flag_reader.h",
    "src/internal/flags/flag.h",
    "src/internal/flags/flag_reader.h",
    "src/internal/flags/nearby_flags.h",
  ]
  public_deps = [
    ":platform_mutex",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/internal/interop
source_set("interop_authentication_transport_interface") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [ "src/internal/interop/authentication_transport.h" ]
  public_deps = [ "//third_party/abseil-cpp:absl" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

source_set("interop_device") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [
    "src/internal/interop/device.h",
    "src/internal/interop/device_provider.h",
  ]
  public_deps = [
    ":interop_authentication_status",
    ":interop_authentication_transport_interface",
    ":platform_base_connection_info",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

source_set("interop_authentication_status") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [ "src/internal/interop/authentication_status.h" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

###############################################################################
# src/internal/platform
###############################################################################
# src/internal/platform/implementation
source_set("platform_api_comm") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/internal/platform/implementation/ble.h",
    "src/internal/platform/implementation/ble_v2.h",
    "src/internal/platform/implementation/bluetooth_adapter.h",
    "src/internal/platform/implementation/bluetooth_classic.h",
    "src/internal/platform/implementation/credential_callbacks.h",
    "src/internal/platform/implementation/credential_storage.h",
    "src/internal/platform/implementation/http_loader.h",
    "src/internal/platform/implementation/server_sync.h",
    "src/internal/platform/implementation/webrtc.h",
    "src/internal/platform/implementation/wifi.h",
    "src/internal/platform/implementation/wifi_direct.h",
    "src/internal/platform/implementation/wifi_hotspot.h",
    "src/internal/platform/implementation/wifi_lan.h",
  ]
  public_deps = [
    ":connections_credential_proto",
    ":connections_local_credential_proto",
    ":offline_wire_formats_proto",
    ":platform_base",
    ":platform_base_cancellation_flag",
    ":platform_base_uuid",
    "//third_party/abseil-cpp:absl",
    "//third_party/webrtc_overrides:webrtc_component",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

source_set("platform_api_types") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/internal/platform/implementation/atomic_boolean.h",
    "src/internal/platform/implementation/atomic_reference.h",
    "src/internal/platform/implementation/bluetooth_adapter.h",
    "src/internal/platform/implementation/cancelable.h",
    "src/internal/platform/implementation/condition_variable.h",
    "src/internal/platform/implementation/count_down_latch.h",
    "src/internal/platform/implementation/crypto.h",
    "src/internal/platform/implementation/executor.h",
    "src/internal/platform/implementation/future.h",
    "src/internal/platform/implementation/input_file.h",
    "src/internal/platform/implementation/listenable_future.h",
    "src/internal/platform/implementation/log_message.h",
    "src/internal/platform/implementation/mutex.h",
    "src/internal/platform/implementation/output_file.h",
    "src/internal/platform/implementation/scheduled_executor.h",
    "src/internal/platform/implementation/settable_future.h",
    "src/internal/platform/implementation/submittable_executor.h",
    "src/internal/platform/implementation/system_clock.h",
  ]
  public_deps = [
    ":platform_base",
    "//crypto:crypto",
    "//third_party/abseil-cpp:absl",
  ]
  deps = [ ":platform_impl_crypto" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("platform_api_platform") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [ "src/internal/platform/implementation/platform.h" ]
  public_deps = [
    ":platform_api_comm",
    ":platform_api_types",
    ":platform_base",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/internal/platform
source_set("platform_base") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]

  # TODO(crbug.com/325102878): Remove once usage of the deprecated version of
  # absl::HexStringToBytes have been removed.
  cflags = [ "-Wno-deprecated-declarations" ]
  sources = [
    "src/internal/platform/base64_utils.cc",
    "src/internal/platform/bluetooth_utils.cc",
    "src/internal/platform/input_stream.cc",
    "src/internal/platform/nsd_service_info.cc",
    "src/internal/platform/prng.cc",
  ]
  public = [
    "src/internal/platform/base64_utils.h",
    "src/internal/platform/bluetooth_utils.h",
    "src/internal/platform/byte_array.h",
    "src/internal/platform/callable.h",
    "src/internal/platform/exception.h",
    "src/internal/platform/feature_flags.h",
    "src/internal/platform/input_stream.h",
    "src/internal/platform/listeners.h",
    "src/internal/platform/nsd_service_info.h",
    "src/internal/platform/os_name.h",
    "src/internal/platform/output_stream.h",
    "src/internal/platform/payload_id.h",
    "src/internal/platform/prng.h",
    "src/internal/platform/runnable.h",
    "src/internal/platform/socket.h",
    "src/internal/platform/types.h",
    "src/internal/platform/wifi_credential.h",
  ]
  public_deps = [
    ":connections_enums_proto",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("platform_base_error_code_recorder") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [ "src/internal/platform/error_code_recorder.cc" ]
  public = [
    "src/internal/platform/error_code_params.h",
    "src/internal/platform/error_code_recorder.h",
  ]
  public_deps = [
    ":connections_enums_proto",
    ":error_code_enums_proto",
    ":platform_base_logging",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("platform_base_uuid") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [ "src/internal/platform/uuid.cc" ]
  public = [ "src/internal/platform/uuid.h" ]
  public_deps = [ ":platform_api_types" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("platform_base_util") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/internal/platform/base_input_stream.cc",
    "src/internal/platform/byte_utils.cc",
  ]
  public = [
    "src/internal/platform/base_input_stream.h",
    "src/internal/platform/base_mutex_lock.h",
    "src/internal/platform/byte_utils.h",
  ]
  public_deps = [
    ":platform_api_types",
    ":platform_base",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("platform_base_logging") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [ "src/internal/platform/logging.h" ]
  public_deps = [
    ":platform_api_platform",
    ":platform_api_types",
    "//base:base",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("platform_base_cancellation_flag") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [ "src/internal/platform/cancellation_flag.cc" ]
  public = [ "src/internal/platform/cancellation_flag.h" ]
  public_deps = [
    ":platform_base",
    ":platform_base_util",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("platform_base_connection_info") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/internal/platform/ble_connection_info.cc",
    "src/internal/platform/bluetooth_connection_info.cc",
    "src/internal/platform/connection_info.cc",
    "src/internal/platform/wifi_lan_connection_info.cc",
  ]
  public = [
    "src/internal/platform/ble_connection_info.h",
    "src/internal/platform/bluetooth_connection_info.h",
    "src/internal/platform/connection_info.h",
    "src/internal/platform/wifi_lan_connection_info.h",
  ]
  public_deps = [
    ":platform_base",
    ":platform_base_logging",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/internal/platform/implementation/shared
source_set("platform_impl_shared_file") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [ "src/internal/platform/implementation/shared/file.cc" ]
  public = [ "src/internal/platform/implementation/shared/file.h" ]
  public_deps = [
    ":platform_api_platform",
    ":platform_public_types",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/internal/platform
# TODO(b/360211019): This was moved out of `platform_public_types` due to a
# circular dependency with `flags`. Move this back into `platform_public_types`
# once we can resolve the circular dependency.
source_set("platform_mutex") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [
    "src/internal/platform/mutex.h",
    "src/internal/platform/mutex_lock.h",
  ]
  public_deps = [
    ":platform_api_platform",
    ":platform_api_types",
    "//third_party/abseil-cpp:absl",
    "//third_party/webrtc_overrides:webrtc_component",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

source_set("platform_public_types") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/internal/platform/blocking_queue_stream.cc",
    "src/internal/platform/monitored_runnable.cc",
    "src/internal/platform/pending_job_registry.cc",
    "src/internal/platform/pipe.cc",
  ]
  public = [
    "src/internal/platform/atomic_boolean.h",
    "src/internal/platform/atomic_reference.h",
    "src/internal/platform/blocking_queue_stream.h",
    "src/internal/platform/borrowable.h",
    "src/internal/platform/cancelable.h",
    "src/internal/platform/cancelable_alarm.h",
    "src/internal/platform/cancellable_task.h",
    "src/internal/platform/condition_variable.h",
    "src/internal/platform/count_down_latch.h",
    "src/internal/platform/crypto.h",
    "src/internal/platform/direct_executor.h",
    "src/internal/platform/file.h",
    "src/internal/platform/future.h",
    "src/internal/platform/lockable.h",
    "src/internal/platform/logging.h",
    "src/internal/platform/monitored_runnable.h",
    "src/internal/platform/multi_thread_executor.h",
    "src/internal/platform/pending_job_registry.h",
    "src/internal/platform/pipe.h",
    "src/internal/platform/scheduled_executor.h",
    "src/internal/platform/settable_future.h",
    "src/internal/platform/single_thread_executor.h",
    "src/internal/platform/submittable_executor.h",
    "src/internal/platform/system_clock.h",
    "src/internal/platform/thread_check_callable.h",
    "src/internal/platform/thread_check_runnable.h",
  ]
  public_deps = [
    ":flags",
    ":platform_api_platform",
    ":platform_api_types",
    ":platform_base",
    ":platform_base_cancellation_flag",
    ":platform_base_logging",
    ":platform_base_util",
    ":platform_mutex",
    ":platform_public_logging",
    "//crypto:crypto",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("platform_public_comm") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/internal/platform/ble.cc",
    "src/internal/platform/ble_v2.cc",
    "src/internal/platform/bluetooth_classic.cc",
    "src/internal/platform/credential_storage_impl.cc",
    "src/internal/platform/file.cc",
    "src/internal/platform/wifi_direct.cc",
    "src/internal/platform/wifi_hotspot.cc",
    "src/internal/platform/wifi_lan.cc",
    "src/internal/platform/wifi_utils.cc",
  ]
  public = [
    "src/internal/platform/ble.h",
    "src/internal/platform/ble_v2.h",
    "src/internal/platform/bluetooth_adapter.h",
    "src/internal/platform/bluetooth_classic.h",
    "src/internal/platform/credential_storage_impl.h",
    "src/internal/platform/webrtc.h",
    "src/internal/platform/wifi_direct.h",
    "src/internal/platform/wifi_hotspot.h",
    "src/internal/platform/wifi_lan.h",
    "src/internal/platform/wifi_utils.h",
  ]
  public_deps = [
    ":platform_api_comm",
    ":platform_api_platform",
    ":platform_base",
    ":platform_base_uuid",
    ":platform_public_logging",
    ":platform_public_types",
    "//third_party/abseil-cpp:absl",
    "//third_party/webrtc_overrides:webrtc_component",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("platform_public_logging") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [ "src/internal/platform/logging.h" ]
  public_deps = [ ":platform_base_logging" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

###############################################################################
# src/presence
###############################################################################
# src/presence
source_set("presence") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/presence/presence_client_impl.cc",
    "src/presence/presence_device_provider.cc",
    "src/presence/presence_service_impl.cc",
  ]
  public = [
    "src/presence/presence_client.h",
    "src/presence/presence_client_impl.h",
    "src/presence/presence_device_provider.h",
    "src/presence/presence_service.h",
    "src/presence/presence_service_impl.h",
  ]
  public_deps = [
    ":connections_local_credential_proto",
    ":connections_metadata_proto",
    ":interop_authentication_status",
    ":interop_authentication_transport_interface",
    ":interop_device",
    ":platform_api_comm",
    ":platform_api_types",
    ":platform_base",
    ":platform_base_logging",
    ":platform_public_types",
    ":presence_frame_proto",
    ":presence_internal",
    ":presence_mediums",
    ":presence_types",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("presence_test") {
  testonly = true
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/internal/interop/fake_device_provider.cc",
    "src/presence/fake_presence_client.cc",
    "src/presence/fake_presence_service.cc",
  ]
  public = [
    "src/internal/interop/fake_device_provider.h",
    "src/presence/fake_presence_client.h",
    "src/presence/fake_presence_service.h",
  ]
  deps = [ ":presence" ]
}
source_set("presence_types") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/presence/device_motion.cc",
    "src/presence/discovery_filter.cc",
    "src/presence/presence_action.cc",
    "src/presence/presence_device.cc",
    "src/presence/presence_zone.cc",
    "src/presence/scan_request_builder.cc",
  ]
  public = [
    "src/presence/broadcast_options.h",
    "src/presence/broadcast_request.h",
    "src/presence/data_element.h",
    "src/presence/data_types.h",
    "src/presence/device_motion.h",
    "src/presence/discovery_filter.h",
    "src/presence/power_mode.h",
    "src/presence/presence_action.h",
    "src/presence/presence_device.h",
    "src/presence/presence_zone.h",
    "src/presence/scan_request.h",
    "src/presence/scan_request_builder.h",
  ]
  public_deps = [
    ":connections_credential_proto",
    ":connections_metadata_proto",
    ":interop_device",
    ":offline_wire_formats_proto",
    ":platform_base",
    ":platform_base_connection_info",
    ":platform_public_logging",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/presence/implementation
source_set("presence_internal") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  sources = [
    "src/presence/implementation/action_factory.cc",
    "src/presence/implementation/advertisement_decoder_rust_impl.cc",
    "src/presence/implementation/advertisement_factory.cc",
    "src/presence/implementation/advertisement_filter.cc",
    "src/presence/implementation/base_broadcast_request.cc",
    "src/presence/implementation/broadcast_manager.cc",
    "src/presence/implementation/connection_authenticator_impl.cc",
    "src/presence/implementation/credential_manager_impl.cc",
    "src/presence/implementation/ldt.cc",
    "src/presence/implementation/scan_manager.cc",
    "src/presence/implementation/service_controller_impl.cc",
  ]
  public = [
    "src/presence/implementation/action_factory.h",
    "src/presence/implementation/advertisement_decoder.h",
    "src/presence/implementation/advertisement_decoder_rust_impl.h",
    "src/presence/implementation/advertisement_factory.h",
    "src/presence/implementation/advertisement_filter.h",
    "src/presence/implementation/base_broadcast_request.h",
    "src/presence/implementation/broadcast_manager.h",
    "src/presence/implementation/connection_authenticator.h",
    "src/presence/implementation/connection_authenticator_impl.h",
    "src/presence/implementation/credential_manager.h",
    "src/presence/implementation/credential_manager_impl.h",
    "src/presence/implementation/ldt.h",
    "src/presence/implementation/scan_manager.h",
    "src/presence/implementation/service_controller.h",
    "src/presence/implementation/service_controller_impl.h",
  ]
  public_deps = [
    ":connections_enums_proto",
    ":connections_local_credential_proto",
    ":connections_metadata_proto",
    ":nearby_crypto",
    ":platform_base",
    ":platform_base_uuid",
    ":platform_public_comm",
    ":platform_public_logging",
    ":platform_public_types",
    ":presence_mediums",
    ":presence_types",
    "//crypto:crypto",
    "//third_party/abseil-cpp:absl",
    "//third_party/beto-core:ldt_np_adv_ffi",
    "//third_party/beto-core:np_cpp_ffi",
    "//third_party/boringssl:boringssl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

source_set("presence_sensor_fusion") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [ "src/presence/implementation/sensor_fusion.h" ]
  public_deps = [
    ":presence_types",
    "//third_party/abseil-cpp:absl",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

# src/presence/implementation/mediums
source_set("presence_mediums") {
  public_configs = [
    ":nearby_include_config",
    ":nearby_defines",
  ]
  public = [
    "src/presence/implementation/mediums/advertisement_data.h",
    "src/presence/implementation/mediums/ble.h",
    "src/presence/implementation/mediums/mediums.h",
  ]
  public_deps = [
    ":platform_base_uuid",
    ":platform_public_comm",
    ":presence_types",
  ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
}

###############################################################################
# src/proto
###############################################################################
# src/proto
proto_library("connections_enums_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/proto/connections_enums.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("sharing_enums_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/proto/sharing_enums.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("fast_pair_enums_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/proto/fast_pair_enums.proto" ]
  proto_out_dir = "third_party/nearby"
}

# src/internal/proto/analytics
proto_library("connections_log_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/internal/proto/analytics/connections_log.proto" ]
  proto_out_dir = "third_party/nearby"
  proto_deps = [
    ":connections_enums_proto",
    ":error_code_enums_proto",
  ]
  link_deps = [
    ":connections_enums_proto",
    ":error_code_enums_proto",
  ]
}

proto_library("fast_pair_log_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/internal/proto/analytics/fast_pair_log.proto" ]
  proto_out_dir = "third_party/nearby"
  proto_deps = [
    ":connections_log_proto",
    ":fast_pair_enums_proto",
  ]
  link_deps = [
    ":connections_log_proto",
    ":fast_pair_enums_proto",
  ]
}

# src/internal/proto
proto_library("connections_credential_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/internal/proto/credential.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("connections_local_credential_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/internal/proto/local_credential.proto" ]
  proto_out_dir = "third_party/nearby"
  proto_deps = [ ":connections_credential_proto" ]
  link_deps = [ ":connections_credential_proto" ]
}

proto_library("connections_metadata_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/internal/proto/metadata.proto" ]
  proto_out_dir = "third_party/nearby"
}

# src/connections/implementation/proto
proto_library("offline_wire_formats_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/connections/implementation/proto/offline_wire_formats.proto" ]
  proto_out_dir = "third_party/nearby"
}

# src/sharing/proto
proto_library("encrypted_metadata_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/encrypted_metadata.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("enums_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/enums.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("field_mask_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/field_mask.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("settings_observer_data_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/settings_observer_data.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("timestamp_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/timestamp.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("rpc_resources_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/rpc_resources.proto" ]
  proto_out_dir = "third_party/nearby"
  proto_deps = [ ":timestamp_proto" ]
  link_deps = [ ":timestamp_proto" ]
}

proto_library("wire_format_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/wire_format.proto" ]
  proto_out_dir = "third_party/nearby"
  proto_deps = [ ":sharing_enums_proto" ]
  link_deps = [ ":sharing_enums_proto" ]
}

proto_library("device_rpc_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/device_rpc.proto" ]
  proto_out_dir = "third_party/nearby"
  proto_deps = [
    ":field_mask_proto",
    ":rpc_resources_proto",
  ]
  link_deps = [
    ":field_mask_proto",
    ":rpc_resources_proto",
  ]
}

proto_library("contact_rpc_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/contact_rpc.proto" ]
  proto_out_dir = "third_party/nearby"
  proto_deps = [ ":rpc_resources_proto" ]
  link_deps = [ ":rpc_resources_proto" ]
}

proto_library("certificate_rpc_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/sharing/proto/certificate_rpc.proto" ]
  proto_out_dir = "third_party/nearby"
  proto_deps = [ ":rpc_resources_proto" ]
  link_deps = [ ":rpc_resources_proto" ]
}

# src/sharing/proto/analytics
proto_library("sharing_log_proto") {
  proto_in_dir = "src"
  sources =
      [ "${proto_in_dir}/sharing/proto/analytics/nearby_sharing_log.proto" ]
  proto_out_dir = "third_party/nearby"
  proto_deps = [ ":sharing_enums_proto" ]
  link_deps = [ ":sharing_enums_proto" ]

  # For built-in protos, specifically duration.proto.
  import_dirs = [ "//third_party/protobuf/src" ]
}

# src/presence/proto
proto_library("presence_frame_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/presence/proto/presence_frame.proto" ]
  proto_out_dir = "third_party/nearby"
}

# src/proto/errorcode
proto_library("error_code_enums_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/proto/errorcode/error_code_enums.proto" ]
  proto_out_dir = "third_party/nearby"
}

# src/proto/mediums
proto_library("ble_frames_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/proto/mediums/ble_frames.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("multiplex_frames_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/proto/mediums/multiplex_frames.proto" ]
  proto_out_dir = "third_party/nearby"
}

proto_library("web_rtc_signaling_frames_proto") {
  proto_in_dir = "src"
  sources = [ "${proto_in_dir}/proto/mediums/web_rtc_signaling_frames.proto" ]
  proto_out_dir = "third_party/nearby"
}

# The following definitions only apply when building for a CrOS board
if (is_chromeos_device) {
  # Test target is for running Skylab tests from Chrome builder.
  tast_test("nearby_share_tast_tests") {
    tast_attr_expr = "\"group:nearby-share-remote\""
  }
}

###############################################################################
# Chromium platform implementations. These are not third-party code.
###############################################################################
source_set("platform_impl_crypto") {
  sources = [ "platform_impl/crypto.cc" ]
  deps = [ "//base" ]
}