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

import("//components/optimization_guide/features.gni")
import("//testing/test.gni")

static_library("chinese_script_classifier") {
  sources = [
    "chinese_script_classifier.cc",
    "chinese_script_classifier.h",
  ]

  deps = [
    "//base",
    "//third_party/icu",
  ]
}

static_library("language_detection") {
  sources = [
    "language_detection_model.cc",
    "language_detection_model.h",
    "language_detection_util.cc",
    "language_detection_util.h",
  ]

  deps = [
    ":chinese_script_classifier",
    "//base",
    "//components/language/core/common",
    "//components/translate/core/common",
    "//third_party/cld_3/src/src:cld_3",
    "//third_party/icu",
    "//third_party/libphonenumber",
    "//third_party/libphonenumber:libphonenumber_without_metadata",
    "//third_party/smhasher:murmurhash2",
    "//third_party/tflite",
    "//third_party/tflite_support",
    "//third_party/tflite_support:tflite_support_proto",
  ]
  if (build_with_tflite_lib) {
    deps += [ "//components/language_detection/core" ]
  }
}

source_set("unit_tests") {
  testonly = true
  sources = [ "chinese_script_classifier_test.cc" ]
  if (build_with_tflite_lib) {
    sources += [
      "language_detection_model_unittest.cc",
      "language_detection_util_unittest.cc",
    ]
  }

  deps = [
    ":chinese_script_classifier",
    ":language_detection",
    "//base",
    "//base/test:test_support",
    "//components/translate/core/common",
    "//testing/gtest",
    "//third_party/icu",
  ]
  if (build_with_tflite_lib) {
    deps += [
      "//components/language_detection/core",
      "//components/language_detection/testing",
    ]
  }
}

test("language_detection_util_fuzztest") {
  sources = [ "language_detection_util_fuzztest.cc" ]
  fuzztests =
      [ "LanguageDetectionUtilFuzzTest.DeterminePageLanguageDoesNotCrash" ]

  deps = [
    ":language_detection",
    "//testing/gtest",
    "//third_party/fuzztest:fuzztest_gtest_main",
  ]
}