chromium/services/passage_embeddings/BUILD.gn

# Copyright 2024 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")

source_set("passage_embeddings") {
  sources = [
    "passage_embeddings_service.cc",
    "passage_embeddings_service.h",
  ]

  if (build_with_tflite_lib) {
    sources += [
      "passage_embedder.cc",
      "passage_embedder.h",
      "passage_embedder_execution_task.cc",
      "passage_embedder_execution_task.h",
    ]
  }

  public_deps = [ "//mojo/public/cpp/bindings" ]

  if (build_with_tflite_lib) {
    public_deps += [
      "//third_party/tflite",
      "//third_party/tflite:tflite_public_headers",
      "//third_party/tflite_support",
      "//third_party/tflite_support:tflite_support_proto",
    ]
  }

  deps = [
    "//components/history_embeddings",
    "//services/passage_embeddings/public/mojom",
    "//third_party/sentencepiece:sentencepiece",
    "//third_party/sentencepiece:sentencepiece_proto",
  ]

  if (build_with_tflite_lib) {
    deps += [
      "//components/optimization_guide:machine_learning_tflite_buildflags",
      "//components/optimization_guide/core:machine_learning",
    ]
  }
}

source_set("tests") {
  testonly = true

  sources = [ "passage_embeddings_service_unittest.cc" ]
  deps = [
    ":passage_embeddings",
    "//base/test:test_support",
    "//services/on_device_model/public/mojom",
    "//testing/gtest",
  ]
}