chromium/tools/android/forwarder2/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/symlink.gni")
import("//testing/test.gni")

group("forwarder2") {
  testonly = true
  data_deps = [
    ":device_forwarder_prepare_dist($default_toolchain)",
    ":host_forwarder",
    ":host_forwarder_unittests",
  ]
}

if (current_toolchain == default_toolchain) {
  import("//build/config/android/rules.gni")

  executable("device_forwarder") {
    sources = [
      "command.cc",
      "command.h",
      "common.cc",
      "common.h",
      "daemon.cc",
      "daemon.h",
      "device_controller.cc",
      "device_controller.h",
      "device_forwarder_main.cc",
      "device_listener.cc",
      "device_listener.h",
      "forwarder.cc",
      "forwarder.h",
      "forwarders_manager.cc",
      "forwarders_manager.h",
      "pipe_notifier.cc",
      "pipe_notifier.h",
      "self_deleter_helper.h",
      "socket.cc",
      "socket.h",
      "util.h",
    ]
    deps = [
      "//base",
      "//tools/android/common",
    ]
    data_deps = [ "//build/android/pylib/device/commands" ]
  }

  create_native_executable_dist("device_forwarder_prepare_dist") {
    dist_dir = "$root_build_dir/forwarder_dist"
    binary = "$root_build_dir/device_forwarder"
    deps = [ ":device_forwarder" ]
  }
}

if (current_toolchain != default_toolchain) {
  source_set("host_forwarder_source_set") {
    sources = [
      "command.cc",
      "command.h",
      "common.cc",
      "common.h",
      "daemon.cc",
      "daemon.h",
      "forwarder.cc",
      "forwarder.h",
      "forwarders_manager.cc",
      "forwarders_manager.h",
      "host_controller.cc",
      "host_controller.h",
      "host_controllers_manager.cc",
      "host_controllers_manager.h",
      "pipe_notifier.cc",
      "pipe_notifier.h",
      "self_deleter_helper.h",
      "socket.cc",
      "socket.h",
      "util.h",
    ]
    deps = [
      "//base",
      "//tools/android/common",
    ]
  }

  executable("host_forwarder") {
    sources = [ "host_forwarder_main.cc" ]
    deps = [
      ":host_forwarder_source_set",
      "//base",
    ]
  }

  test("host_forwarder_unittests") {
    testonly = true
    sources = [ "host_controllers_manager_unittest.cc" ]
    deps = [
      ":host_forwarder_source_set",
      "//base",
      "//testing/gtest",
      "//testing/gtest:gtest_main",
    ]
  }
} else {
  # Create a symlink from root_build_dir -> clang_x64/host_forwarder.
  binary_symlink("host_forwarder") {
    binary_label = ":$target_name($host_toolchain)"
  }
  binary_symlink("host_forwarder_unittests") {
    testonly = true
    binary_label = ":$target_name($host_toolchain)"
  }
}