# File I/O and model loading

load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

package(
    default_applicable_licenses = [
        "//:license",  # Placeholder comment, do not modify
    ],
    # Placeholder for internal compatible_with
    default_visibility = [
        # Placeholder for internal visibility,
        # Users require gcpp::Path etc., which are defined in this package.
        "//visibility:public",
    ],
)

config_setting(
    name = "android",
    constraint_values = [
        "@platforms//os:android",
    ],
    visibility = ["//visibility:private"],
)

FILE_DEPS = select({
    "//conditions:default": [
        # Placeholder for io deps, do not remove
    ],
    ":android": [],
    # Placeholder for internal build rules, do not remove
})

cc_library(
    name = "io",
    srcs = [
        "io.cc",
        # Placeholder for io backend, do not remove
    ],
    hdrs = ["io.h"],
    local_defines = select({
        # Placeholder for internal build rules, do not remove
        "//conditions:default": [],
    }),
    deps = [
        # Placeholder for internal dep, do not remove.,
        "//:allocator",
        "@highway//:hwy",
    ] + FILE_DEPS,
)

cc_library(
    name = "fields",
    srcs = ["fields.cc"],
    hdrs = ["fields.h"],
    deps = [
        "@highway//:hwy",
    ],
)

cc_test(
    name = "fields_test",
    srcs = ["fields_test.cc"],
    deps = [
        ":fields",
        "@googletest//:gtest_main",  # buildcleaner: keep
        "@highway//:hwy_test_util",
    ],
)

cc_library(
    name = "blob_store",
    srcs = ["blob_store.cc"],
    hdrs = ["blob_store.h"],
    deps = [
        ":io",
        "//:basics",
        "//:threading_context",
        "@highway//:hwy",
        "@highway//:profiler",
    ],
)

cc_test(
    name = "blob_store_test",
    srcs = ["blob_store_test.cc"],
    deps = [
        ":blob_store",
        ":io",
        "@googletest//:gtest_main",  # buildcleaner: keep
        "//:basics",
        "//:threading_context",
        "@highway//:hwy_test_util",
    ],
)

cc_binary(
    name = "blob_compare",
    srcs = ["blob_compare.cc"],
    deps = [
        ":blob_store",
        ":io",
        "//:basics",
        "//:threading",
        "//:threading_context",
        "@highway//:hwy",
        "@highway//:hwy_test_util",
        "@highway//:nanobenchmark",
    ],
)

cc_binary(
    name = "migrate_weights",
    srcs = ["migrate_weights.cc"],
    deps = [
        "//:args",
        "//:benchmark_helper",
        "//:gemma_lib",
    ],
)
