# -*- mode: python -*-

Import("env")

env.Library(
    target="cluster_query",
    source=[
        "cluster_find.cpp",
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/commands',
        '$BUILD_DIR/mongo/db/query/query_common',
        "cluster_client_cursor",
        "cluster_cursor_cleanup_job",
        "store_possible_cursor",
    ],
)

env.Library(
    target="cluster_client_cursor",
    source=[
        "cluster_client_cursor_impl.cpp",
    ],
    LIBDEPS=[
        "router_exec_stage",
    ],
)

env.Library(
    target="router_exec_stage",
    source=[
        "router_stage_limit.cpp",
        "router_stage_merge.cpp",
        "router_stage_mock.cpp",
        "router_stage_remove_sortkey.cpp",
        "router_stage_skip.cpp",
    ],
    LIBDEPS=[
        "async_results_merger",
    ],
)

env.CppUnitTest(
    target="router_exec_stage_test",
    source=[
        "router_stage_limit_test.cpp",
        "router_stage_remove_sortkey_test.cpp",
        "router_stage_skip_test.cpp",
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init',
        "$BUILD_DIR/mongo/s/mongoscore",
        "router_exec_stage",
    ],
)

env.Library(
    target="async_results_merger",
    source=[
        "async_results_merger.cpp",
        "cluster_client_cursor_params.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/db/query/command_request_response",
        "$BUILD_DIR/mongo/executor/task_executor_interface",
        "$BUILD_DIR/mongo/s/client/sharding_client",
        "$BUILD_DIR/mongo/s/coreshard",
    ],
)

env.Library(
    target="cluster_client_cursor_mock",
    source=[
        "cluster_client_cursor_mock.cpp",
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
    ],
)

env.CppUnitTest(
    target="async_results_merger_test",
    source=[
        "async_results_merger_test.cpp",
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init',
        "$BUILD_DIR/mongo/db/query/lite_parsed_query",
        "$BUILD_DIR/mongo/executor/thread_pool_task_executor_test_fixture",
        "$BUILD_DIR/mongo/s/mongoscore",
        "$BUILD_DIR/mongo/s/sharding_test_fixture",
        "async_results_merger",
    ],
)

env.Library(
    target="store_possible_cursor",
    source=[
        "store_possible_cursor.cpp"
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/base",
        "$BUILD_DIR/mongo/db/query/command_request_response",
        "cluster_client_cursor",
        "cluster_cursor_manager",
    ],
)

env.CppUnitTest(
    target="store_possible_cursor_test",
    source=[
        "store_possible_cursor_test.cpp",
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init',
        "$BUILD_DIR/mongo/s/mongoscore",
        "$BUILD_DIR/mongo/util/clock_source_mock",
        "store_possible_cursor",
    ],
)

env.Library(
    target="cluster_cursor_manager",
    source=[
        "cluster_cursor_manager.cpp",
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
    ],
)

env.CppUnitTest(
    target="cluster_cursor_manager_test",
    source=[
        "cluster_cursor_manager_test.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/util/clock_source_mock",
        "cluster_client_cursor_mock",
        "cluster_cursor_manager",
    ],
)

env.Library(
    target="cluster_cursor_cleanup_job",
    source=[
        "cluster_cursor_cleanup_job.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/s/coreshard",
        "$BUILD_DIR/mongo/util/background_job",
    ],
    LIBDEPS_TAGS=[
        # Needs mongo::inShutDown()
        'incomplete',
    ],
)

env.CppUnitTest(
    target="cluster_client_cursor_impl_test",
    source=[
        "cluster_client_cursor_impl_test.cpp",
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init',
        "$BUILD_DIR/mongo/s/mongoscore",
        "cluster_client_cursor",
    ],
)
