chromium/ui/events/ozone/layout/BUILD.gn

# Copyright 2019 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/linux/pkg_config.gni")
import("//ui/base/ui_features.gni")

assert(use_ozone)

if (use_xkbcommon) {
  pkg_config("xkbcommon") {
    packages = [ "xkbcommon" ]
  }
}

component("layout") {
  output_name = "events_ozone_layout"

  sources = [
    "keyboard_layout_engine.h",
    "keyboard_layout_engine_manager.cc",
    "keyboard_layout_engine_manager.h",
    "no/no_keyboard_layout_engine.cc",
    "no/no_keyboard_layout_engine.h",
    "scoped_keyboard_layout_engine.cc",
    "scoped_keyboard_layout_engine.h",
    "stub/stub_keyboard_layout_engine.cc",
    "stub/stub_keyboard_layout_engine.h",
  ]

  defines = [ "IS_EVENTS_OZONE_LAYOUT_IMPL" ]

  deps = [
    "//base",
    "//ui/events:dom_keycode_converter",
    "//ui/events:events_base",
  ]

  if (use_xkbcommon) {
    configs += [ ":xkbcommon" ]

    sources += [
      "xkb/xkb_evdev_codes.cc",
      "xkb/xkb_evdev_codes.h",
      "xkb/xkb_key_code_converter.h",
      "xkb/xkb_keyboard_layout_engine.cc",
      "xkb/xkb_keyboard_layout_engine.h",
      "xkb/xkb_modifier_converter.cc",
      "xkb/xkb_modifier_converter.h",
    ]

    deps += [
      "//build:chromeos_buildflags",
      "//ui/events/keycodes:xkb",
    ]
  }
}

source_set("unittests") {
  testonly = true

  sources = []
  if (use_xkbcommon) {
    sources += [
      "keyboard_layout_engine_unittest.cc",
      "xkb/xkb_keyboard_layout_engine_unittest.cc",
      "xkb/xkb_modifier_converter_unittest.cc",
    ]
    configs += [ ":xkbcommon" ]
  }

  deps = [
    ":layout",
    "//base",
    "//testing/gtest",
    "//ui/events",
    "//ui/events:dom_keycode_converter",
    "//ui/events/keycodes:xkb",
  ]
}

source_set("test_support") {
  testonly = true

  sources = [
    "keyboard_layout_engine_test_utils.cc",
    "keyboard_layout_engine_test_utils.h",
  ]

  deps = [
    ":layout",
    "//base",
    "//ui/base:features",
  ]
}