# -*- mode: python -*-

Import("env")

env = env.Clone()

env.SConscript(dirs=['mongotmock'], exports=['env'])

env.Library(
    target='mongot_cursor',
    source=[
        'mongot_cursor.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/query/common_query_enums_and_helpers',
        '$BUILD_DIR/mongo/db/query/plan_yield_policy',
        '$BUILD_DIR/mongo/executor/task_executor_cursor',
        'mongot_options',
        'search_task_executors',
    ],
)

env.Library(
    target='mongot_options',
    source=[
        'mongot_options.cpp',
        'mongot_options.idl',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/db/server_base',
        '$BUILD_DIR/mongo/util/net/network',
    ],
)

env.Library(
    target='search_task_executors',
    source=[
        'search_task_executors.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/executor/connection_pool_controllers',
        '$BUILD_DIR/mongo/executor/network_interface_factory',
        '$BUILD_DIR/mongo/executor/network_interface_thread_pool',
        '$BUILD_DIR/mongo/executor/task_executor_interface',
        '$BUILD_DIR/mongo/executor/thread_pool_task_executor',
        '$BUILD_DIR/mongo/util/concurrency/thread_pool',
    ],
    LIBDEPS_PRIVATE=[
        'mongot_options',
        'search_index_options',
    ],
)

env.CppIntegrationTest(
    target='search_task_executors_integration_test',
    source=[
        'search_task_executors_integration_test.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/wire_version',
        '$BUILD_DIR/mongo/executor/network_interface',
        '$BUILD_DIR/mongo/executor/pinned_connection_task_executor_factory',
        '$BUILD_DIR/mongo/transport/transport_layer_egress_init',
        '$BUILD_DIR/mongo/util/version_impl',
        'search_task_executors',
    ],
)

env.CppUnitTest(
    target='auth_search_test',
    source=[
        'list_search_indexes_authorization_session_test.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/auth/auth_checks',
        '$BUILD_DIR/mongo/db/auth/authorization_session_test_fixture',
        '$BUILD_DIR/mongo/db/pipeline/pipeline',
    ],
)

env.Library(
    target='search_index_options',
    source=[
        'search_index_options.cpp',
        'search_index_options.idl',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/db/server_base',
        '$BUILD_DIR/mongo/util/net/network',
    ],
)

# This target holds the shared logic for dispatching search index requests to a mongot,
# whereas the search_index_process targets below hold the logic for fetching collection
# metadata, either as a mongos router or mongod shard.
env.Library(
    target='search_index_common',
    source=[
        'manage_search_index_request.idl',
        'search_index_common.cpp',
    ],
    LIBDEPS=[
        'search_index_options',
        'search_index_process_interface',
        'search_task_executors',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/db/server_base',
        '$BUILD_DIR/mongo/db/service_context',
        '$BUILD_DIR/mongo/rpc/command_status',
        '$BUILD_DIR/mongo/util/net/network',
    ],
)

env.Library(
    target='search_index_process_interface',
    source=[
        'search_index_process_interface.cpp',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/db/commands',
        '$BUILD_DIR/mongo/db/server_base',
        '$BUILD_DIR/mongo/db/service_context',
    ],
)

env.Library(
    target='search_index_process_shard',
    source=[
        'search_index_process_shard.cpp',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/db/catalog/collection_catalog',
        'search_index_process_interface',
    ],
)

env.Library(
    target='search_index_process_router',
    source=[
        'search_index_process_router.cpp',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/s/catalog/sharding_catalog_client',
        '$BUILD_DIR/mongo/s/sharding_router_api',
        'search_index_process_interface',
    ],
)
