# Any targets that should be shared between fbcode and xplat must be defined in
# targets.bzl. This file can contain fbcode-only targets.

load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary")
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version")

oncall("executorch")

python_binary(
    name = "export_example",
    srcs = ["scripts/export_example.py"],
    main_function = ".scripts.export_example.main",
    visibility = ["//executorch/examples/..."],
    deps = [
        "//caffe2:torch",
        "//executorch/extension/pybindings:aten_lib",
        "//executorch/backends/qualcomm/partition:partition",
        "//executorch/backends/qualcomm/quantizer:quantizer",
        "//executorch/devtools:lib",
        "//executorch/examples/models:models",
        "//executorch/extension/export_util:export_util",
    ],
)

runtime.command_alias(
    name = "export_example_qnn",
    env = {
        "LD_LIBRARY_PATH": "$(location fbsource//third-party/qualcomm/qnn/qnn-{0}:qnn_offline_compile_libs)".format(get_qnn_library_version()),
        "QNN_SDK_ROOT": "$(location fbsource//third-party/qualcomm/qnn/qnn-{0}:__dir__)".format(get_qnn_library_version()),
    },
    exe = ":export_example",
)

runtime.python_library(
    name = "utils",
    srcs = ["utils.py"],
    deps = [
        "//executorch/backends/qualcomm/partition:partition",
        "//executorch/backends/qualcomm/quantizer:quantizer",
    ],
)
