load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target")
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

oncall("executorch")

fbcode_target(
    _kind = runtime.python_library,
    name = "recipe",
    srcs = [
        "recipe.py",
    ],
    visibility = ["PUBLIC"],
    deps = [
        "//caffe2:torch",
        "//executorch/exir/backend:backend_api",
        "//executorch/exir:pass_manager",
        "//executorch/extension/export_util:export_util",
    ]
)

fbcode_target(
    _kind = runtime.python_library,
    name = "export",
    srcs = [
        "export.py",
    ],
    visibility = ["PUBLIC"],
    deps = [
        ":recipe",
        ":stages",
        ":types",
        ":recipe_registry"
    ]
)


fbcode_target(
    _kind = runtime.python_library,
    name = "stages",
    srcs = [
        "stages.py",
    ],
    visibility = ["PUBLIC"],
    deps = [
        ":recipe",
        ":types",
        "//executorch/devtools/backend_debug:delegation_info",
        "//executorch/exir/backend:backend_api",
        "//executorch/exir:pass_manager",
        "//caffe2:torch",
        "//executorch/devtools/backend_debug:delegation_info",
    ]
)


fbcode_target(
    _kind = runtime.python_library,
    name = "lib",
    srcs = [
        "__init__.py",
    ],
    visibility = ["PUBLIC"],
    deps = [
        ":export",
        ":recipe",
        ":stages",
        ":recipe_registry",
        ":recipe_provider",
        ":types",
    ],
)

fbcode_target(
    _kind = runtime.python_library,
    name = "recipe_registry",
    srcs = [
        "recipe_registry.py",
    ],
    visibility = ["PUBLIC"],
    deps = [
        ":recipe",
        ":recipe_provider"
    ],
)


fbcode_target(
    _kind = runtime.python_library,
    name = "recipe_provider",
    srcs = [
        "recipe_provider.py",
    ],
    deps = [
        ":recipe",
    ]
)

fbcode_target(
    _kind = runtime.python_library,
    name = "types",
    srcs = [
        "types.py",
    ],
)

fbcode_target(
    _kind = runtime.python_library,
    name = "target_recipes",
    srcs = [
        "target_recipes.py",
    ],
    deps = [
        ":export_utils",
        "fbsource//third-party/pypi/coremltools:coremltools",
        "//executorch/export:recipe",
        "//executorch/backends/xnnpack/recipes:xnnpack_recipes",
        "//executorch/backends/apple/coreml:coreml_recipes",
        "//executorch/backends/qualcomm/recipes:qnn_recipes",
    ]
)

fbcode_target(
    _kind = runtime.python_library,
    name = "export_utils",
    srcs = ["utils.py"],
    deps = [
        "//caffe2:torch",
    ]
)
