chromium/services/device/generic_sensor/BUILD.gn

# Copyright 2016 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/chromeos/ui_mode.gni")
import("//build/config/features.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
  import("//third_party/jni_zero/jni_zero.gni")
}

source_set("generic_sensor") {
  visibility = [ "//services/device:*" ]

  output_name = "generic_sensor"
  sources = [
    "absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.cc",
    "absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.h",
    "generic_sensor_consts.h",
    "gravity_fusion_algorithm_using_accelerometer.cc",
    "gravity_fusion_algorithm_using_accelerometer.h",
    "linear_acceleration_fusion_algorithm_using_accelerometer.cc",
    "linear_acceleration_fusion_algorithm_using_accelerometer.h",
    "orientation_euler_angles_fusion_algorithm_using_quaternion.cc",
    "orientation_euler_angles_fusion_algorithm_using_quaternion.h",
    "orientation_quaternion_fusion_algorithm_using_euler_angles.cc",
    "orientation_quaternion_fusion_algorithm_using_euler_angles.h",
    "orientation_util.cc",
    "orientation_util.h",
    "platform_sensor.cc",
    "platform_sensor.h",
    "platform_sensor_fusion.cc",
    "platform_sensor_fusion.h",
    "platform_sensor_fusion_algorithm.cc",
    "platform_sensor_fusion_algorithm.h",
    "platform_sensor_provider.cc",
    "platform_sensor_provider.h",
    "platform_sensor_util.cc",
    "platform_sensor_util.h",
    "relative_orientation_euler_angles_fusion_algorithm_using_accelerometer.cc",
    "relative_orientation_euler_angles_fusion_algorithm_using_accelerometer.h",
    "relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_gyroscope.cc",
    "relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_gyroscope.h",
    "sensor_impl.cc",
    "sensor_impl.h",
    "sensor_provider_impl.cc",
    "sensor_provider_impl.h",
    "virtual_platform_sensor.cc",
    "virtual_platform_sensor.h",
    "virtual_platform_sensor_provider.cc",
    "virtual_platform_sensor_provider.h",
  ]

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

  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//device/base/synchronization",
    "//services/device/public/cpp:device_features",
    "//ui/gfx/geometry:geometry",
  ]

  public_deps = [ "//services/device/public/cpp/generic_sensor" ]

  if (is_android) {
    sources += [
      "platform_sensor_android.cc",
      "platform_sensor_android.h",
      "platform_sensor_provider_android.cc",
      "platform_sensor_provider_android.h",
    ]
    deps += [ ":jni_headers" ]
  }

  if (is_mac) {
    sources += [
      "platform_sensor_provider_mac.cc",
      "platform_sensor_provider_mac.h",
    ]
  }

  if (is_chromeos) {
    deps += [
      "//chromeos/components/sensors",
      "//chromeos/components/sensors/mojom",
    ]

    sources += [
      "platform_sensor_chromeos.cc",
      "platform_sensor_chromeos.h",
      "platform_sensor_provider_chromeos.cc",
      "platform_sensor_provider_chromeos.h",
      "platform_sensor_provider_linux_base.cc",
      "platform_sensor_provider_linux_base.h",
    ]
  } else if (is_linux && use_udev) {
    deps += [
      "//device/base",
      "//device/udev_linux",
    ]

    sources += [
      "linux/sensor_data_linux.cc",
      "linux/sensor_data_linux.h",
      "linux/sensor_device_manager.cc",
      "linux/sensor_device_manager.h",
      "platform_sensor_linux.cc",
      "platform_sensor_linux.h",
      "platform_sensor_provider_linux.cc",
      "platform_sensor_provider_linux.h",
      "platform_sensor_provider_linux_base.cc",
      "platform_sensor_provider_linux_base.h",
      "platform_sensor_reader_linux.cc",
      "platform_sensor_reader_linux.h",
    ]
  }

  if (is_win) {
    sources += [
      "platform_sensor_provider_win.cc",
      "platform_sensor_provider_win.h",
      "platform_sensor_provider_winrt.cc",
      "platform_sensor_provider_winrt.h",
      "platform_sensor_reader_win.cc",
      "platform_sensor_reader_win.h",
      "platform_sensor_reader_win_base.h",
      "platform_sensor_reader_winrt.cc",
      "platform_sensor_reader_winrt.h",
      "platform_sensor_win.cc",
      "platform_sensor_win.h",
    ]

    libs = [
      "portabledeviceguids.lib",
      "sensorsapi.lib",
    ]
  }
}

if (is_android) {
  device_sensors_jni_sources = [
    "android/java/src/org/chromium/device/sensors/PlatformSensor.java",
    "android/java/src/org/chromium/device/sensors/PlatformSensorProvider.java",
  ]

  generate_jni("jni_headers") {
    visibility = [ ":*" ]

    sources = device_sensors_jni_sources
  }

  android_library("java") {
    visibility = [
      "//services:*",
      "//services/device:*",
    ]

    srcjar_deps = [ ":jni_headers" ]
    sources = device_sensors_jni_sources
    deps = [
      "//base:base_java",
      "//build/android:build_java",
      "//services/device/public/mojom:generic_sensor_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }
}