# 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/linux/pkg_config.gni")

assert(is_linux)

declare_args() {
  # Controls whether the build should use the version of gestures
  # library shipped with the system. In release builds of Chrome OS we
  # use the system version, but when building on dev workstations we
  # bundle it because Ubuntu doesn't ship a usable version.
  use_system_gestures = true
}

if (!use_system_gestures) {
  config("gestures_config") {
    include_dirs = [
      ".",
      "include",
      "//third_party/googletest/src/googletest/include",
    ]
  }

  static_library("gestures") {
    sources = [
      "gestures/src/accel_filter_interpreter.cc",
      "gestures/src/activity_log.cc",
      "gestures/src/box_filter_interpreter.cc",
      "gestures/src/click_wiggle_filter_interpreter.cc",
      "gestures/src/cr48_profile_sensor_filter_interpreter.cc",
      "gestures/src/file_util.cc",
      "gestures/src/filter_interpreter.cc",
      "gestures/src/finger_merge_filter_interpreter.cc",
      "gestures/src/finger_metrics.cc",
      "gestures/src/fling_stop_filter_interpreter.cc",
      "gestures/src/gestures.cc",
      "gestures/src/iir_filter_interpreter.cc",
      "gestures/src/immediate_interpreter.cc",
      "gestures/src/integral_gesture_filter_interpreter.cc",
      "gestures/src/interpreter.cc",
      "gestures/src/logging_filter_interpreter.cc",
      "gestures/src/lookahead_filter_interpreter.cc",
      "gestures/src/metrics_filter_interpreter.cc",
      "gestures/src/mouse_interpreter.cc",
      "gestures/src/multitouch_mouse_interpreter.cc",
      "gestures/src/non_linearity_filter_interpreter.cc",
      "gestures/src/palm_classifying_filter_interpreter.cc",
      "gestures/src/prop_registry.cc",
      "gestures/src/scaling_filter_interpreter.cc",
      "gestures/src/sensor_jump_filter_interpreter.cc",
      "gestures/src/split_correcting_filter_interpreter.cc",
      "gestures/src/stationary_wiggle_filter_interpreter.cc",
      "gestures/src/string_util.cc",
      "gestures/src/stuck_button_inhibitor_filter_interpreter.cc",
      "gestures/src/t5r2_correcting_filter_interpreter.cc",
      "gestures/src/trace_marker.cc",
      "gestures/src/tracer.cc",
      "gestures/src/trend_classifying_filter_interpreter.cc",
      "gestures/src/util.cc",
    ]

    deps = [
      "//third_party/jsoncpp",
    ]

    defines = [ "GESTURES_INTERNAL=1" ]

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]

    # gestures uses typeid.
    configs -= [ "//build/config/compiler:no_rtti" ]
    configs += [ "//build/config/compiler:rtti" ]

    if (is_clang) {
      # Suppress warnings from the Chromium Clang plugin.
      configs -= [ "//build/config/clang:find_bad_constructs" ]
    }

    public_configs = [ ":gestures_config" ]
  }
}

if (use_system_gestures) {
  pkg_config("libgestures") {
    packages = [ "libgestures" ]
  }

  group("gestures") {
    public_configs = [ ":libgestures" ]
  }
}
