chromium/components/language_detection/core/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.

# We need a component because this gives access to a per-process
# singleton instance of the model. Without a component, we end up an
# instance in each component that uses the library.
component("language_detection") {
  sources = [
    "language_detection_provider.cc",
    "language_detection_provider.h",
  ]
  public_deps = [ ":core" ]
  deps = [ "//base" ]
  defines = [ "IS_LANGUAGE_DETECTION_IMPL" ]
}

static_library("core") {
  sources = [
    "embedding_lookup.cc",
    "embedding_lookup.h",
    "language_detection_model.cc",
    "language_detection_model.h",
    "language_detection_resolver.h",
    "ngram_hash.cc",
    "ngram_hash.h",
    "ngram_hash_ops_utils.cc",
    "ngram_hash_ops_utils.h",
    "quantization_utils.cc",
    "quantization_utils.h",
  ]

  deps = [
    "//base",
    "//components/optimization_guide/core:features",
    "//components/translate/core/common",
    "//third_party/smhasher:murmurhash2",
    "//third_party/tflite",
    "//third_party/tflite_support",
    "//third_party/tflite_support:tflite_support_proto",
    "//third_party/utf",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "language_detection_model_unittest.cc",
    "language_detection_provider_unittest.cc",
    "ngram_hash_ops_utils_unittest.cc",
    "quantization_utils_unittest.cc",
  ]

  deps = [
    ":language_detection",
    "//base",
    "//base/test:test_support",
    "//components/language_detection/testing",
    "//components/translate/core/common:common",
  ]
}