summaryrefslogtreecommitdiff
path: root/chromium/device/generic_sensor/BUILD.gn
blob: 2a0570bf3985c4798f32e320dea2965d1b78fa31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/features.gni")

if (is_android) {
  import("//build/config/android/rules.gni")  # For generate_jni().
}

component("generic_sensor") {
  output_name = "generic_sensor"
  sources = [
    "generic_sensor_consts.h",
    "linux/sensor_data_linux.cc",
    "linux/sensor_data_linux.h",
    "platform_sensor.cc",
    "platform_sensor.h",
    "platform_sensor_ambient_light_mac.cc",
    "platform_sensor_ambient_light_mac.h",
    "platform_sensor_android.cc",
    "platform_sensor_android.h",
    "platform_sensor_linux.cc",
    "platform_sensor_linux.h",
    "platform_sensor_provider.cc",
    "platform_sensor_provider.h",
    "platform_sensor_provider_android.cc",
    "platform_sensor_provider_android.h",
    "platform_sensor_provider_base.cc",
    "platform_sensor_provider_base.h",
    "platform_sensor_provider_mac.cc",
    "platform_sensor_provider_mac.h",
    "platform_sensor_provider_win.cc",
    "platform_sensor_provider_win.h",
    "platform_sensor_reader_linux.cc",
    "platform_sensor_reader_linux.h",
    "platform_sensor_reader_win.cc",
    "platform_sensor_reader_win.h",
    "platform_sensor_win.cc",
    "platform_sensor_win.h",
    "sensor_impl.cc",
    "sensor_impl.h",
    "sensor_provider_impl.cc",
    "sensor_provider_impl.h",
  ]

  defines = [ "DEVICE_GENERIC_SENSOR_IMPLEMENTATION" ]

  deps = [
    "//base",
    "//device/base/synchronization",
  ]

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

  if (is_android) {
    sources += [
      "android/sensors_jni_registrar.cc",
      "android/sensors_jni_registrar.h",
    ]

    deps += [ ":jni_headers" ]
  }

  if (is_mac) {
    deps += [ "//device/sensors/public/cpp" ]
    libs = [ "IOKit.framework" ]
  }

  if (use_udev) {
    deps += [
      "//device/base",
      "//device/udev_linux",
    ]

    sources += [
      "linux/sensor_device_manager.cc",
      "linux/sensor_device_manager.h",
      "platform_sensor_provider_linux.cc",
      "platform_sensor_provider_linux.h",
    ]
  }

  if (is_win) {
    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") {
    sources = device_sensors_jni_sources
    jni_package = "device"
  }

  android_library("java") {
    java_files = device_sensors_jni_sources

    deps = [
      "//base:base_java",
      "//device/generic_sensor/public/interfaces:interfaces_java",
    ]
  }
}

static_library("testing") {
  testonly = true
  sources = [
    "fake_platform_sensor.cc",
    "fake_platform_sensor.h",
    "fake_platform_sensor_provider.cc",
    "fake_platform_sensor_provider.h",
  ]

  public_deps = [
    ":generic_sensor",
    "//base",
    "//testing/gmock",
  ]
}