# -*- mode: python -*-

Import("env")

env.Library(
    target='sharding_catalog_client',
    source=[
        'sharding_catalog_client.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/write_concern_options',
    ]
)

env.Library(
    target='sharding_catalog_mock',
    source=[
        'sharding_catalog_client_mock.cpp',
    ],
    LIBDEPS=[
        'dist_lock_manager_mock',
        'sharding_catalog_client',
    ]
)

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

env.Library(
    target='dist_lock_manager_mock',
    source=[
        'dist_lock_manager_mock.cpp',
    ],
    LIBDEPS=[
        'dist_lock_manager',
        '$BUILD_DIR/mongo/unittest/unittest',
    ],
)

env.Library(
    target='dist_lock_catalog_interface',
    source=[
        'dist_lock_catalog.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/write_concern_options',
    ],
)

env.Library(
    target='dist_lock_catalog_mock',
    source=[
        'dist_lock_catalog_mock.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/s/common',
        '$BUILD_DIR/mongo/unittest/unittest',
        'dist_lock_catalog_interface',
    ]
)

env.Library(
    target='replset_dist_lock_manager',
    source=[
        'replset_dist_lock_manager.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/service_context',
        '$BUILD_DIR/mongo/s/catalog/dist_lock_catalog_interface',
        '$BUILD_DIR/mongo/s/catalog/dist_lock_manager',
        '$BUILD_DIR/mongo/s/client/sharding_client',
        '$BUILD_DIR/mongo/s/coreshard',
        '$BUILD_DIR/mongo/util/fail_point'
    ],
)

env.Library(
    target='dist_lock_catalog_impl',
    source=[
        'dist_lock_catalog_impl.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
        '$BUILD_DIR/mongo/client/read_preference',
        '$BUILD_DIR/mongo/client/remote_command_targeter',
        '$BUILD_DIR/mongo/db/common',
        '$BUILD_DIR/mongo/db/query/command_request_response',
        '$BUILD_DIR/mongo/db/repl/read_concern_args',
        '$BUILD_DIR/mongo/rpc/command_status',
        '$BUILD_DIR/mongo/s/catalog/dist_lock_catalog_interface',
        '$BUILD_DIR/mongo/s/client/sharding_client',
        '$BUILD_DIR/mongo/s/write_ops/batch_write_types',
        '$BUILD_DIR/mongo/util/net/hostandport',
    ],
)

env.CppUnitTest(
    target='replset_dist_lock_manager_test',
    source=[
        'dist_lock_catalog_impl_test.cpp',
        'replset_dist_lock_manager_test.cpp',
    ],
    LIBDEPS=[
        'dist_lock_catalog_impl',
        'replset_dist_lock_manager',
        '$BUILD_DIR/mongo/s/catalog/dist_lock_catalog_mock',
        '$BUILD_DIR/mongo/s/catalog/sharding_catalog_mock',
        '$BUILD_DIR/mongo/s/sharding_mongod_test_fixture',
    ]
)

env.Library(
    target='sharding_catalog_client_impl',
    source=[
        'sharding_catalog_client_impl.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/repl/read_concern_args',
        '$BUILD_DIR/mongo/db/s/type_shard_identity',
        '$BUILD_DIR/mongo/executor/network_interface',
        '$BUILD_DIR/mongo/s/catalog/dist_lock_manager',
        '$BUILD_DIR/mongo/s/catalog/sharding_catalog_client',
        '$BUILD_DIR/mongo/s/client/sharding_client',
    ],
    LIBDEPS_TAGS=[
        # Depends on coreshard, but that would be circular
        'incomplete',
    ],
)

env.Library(
    target='sharding_catalog_manager_impl',
    source=[
        'sharding_catalog_manager_chunk_operations_impl.cpp',
        'sharding_catalog_manager_impl.cpp',
        'sharding_catalog_manager_shard_operations_impl.cpp',
        'sharding_catalog_manager_zone_operations_impl.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/db_raii',
        '$BUILD_DIR/mongo/db/repl/read_concern_args',
        '$BUILD_DIR/mongo/executor/network_interface',
        '$BUILD_DIR/mongo/s/client/sharding_client',
    ],
    LIBDEPS_TAGS=[
        # Depends on coreshard, but that would be circular
        'incomplete',
    ],
)

env.Library(
    target='sharding_catalog_test_fixture',
    source=[
        'sharding_catalog_test_fixture.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/s/sharding_test_fixture',
    ],
)

env.CppUnitTest(
    target='config_server_catalog_test',
    source=[
        'sharding_catalog_add_shard_test.cpp',
        'sharding_catalog_add_shard_to_zone_test.cpp',
        'sharding_catalog_assign_key_range_to_zone_test.cpp',
        'sharding_catalog_config_initialization_test.cpp',
        'sharding_catalog_merge_chunks_test.cpp',
        'sharding_catalog_remove_shard_from_zone_test.cpp',
        'sharding_catalog_split_chunk_test.cpp',
        'sharding_catalog_commit_chunk_migration_test.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/s/config_server_test_fixture',
    ]
)

env.CppUnitTest(
    target='sharding_catalog_test',
    source=[
        'sharding_catalog_append_db_stats_test.cpp',
        'sharding_catalog_drop_coll_test.cpp',
        'sharding_catalog_log_change_test.cpp',
        'sharding_catalog_remove_shard_test.cpp',
        'sharding_catalog_shard_collection_test.cpp',
        'sharding_catalog_test.cpp',
        'sharding_catalog_write_retry_test.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/s/sharding_test_fixture',
        '$BUILD_DIR/mongo/s/catalog/sharding_catalog_test_fixture',
    ]
)
