# -*- mode: python -*-

Import("env")

env = env.Clone()

env.Library(
    target='connection_pool_stats',
    source=[
        'connection_pool_stats.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
        '$BUILD_DIR/mongo/util/net/network',
    ])

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

env.Library(target='remote_command',
            source=[
                'remote_command_request.cpp',
                'remote_command_response.cpp',
            ],
            LIBDEPS=[
                '$BUILD_DIR/mongo/rpc/metadata',
                '$BUILD_DIR/mongo/util/net/network',
            ])

env.Library(target='async_multicaster',
            source=[
                'async_multicaster.cpp',
            ],
            LIBDEPS=[
                'remote_command',
                'task_executor_interface',
                '$BUILD_DIR/mongo/base',
                '$BUILD_DIR/mongo/util/net/network',
            ])

env.Library(target='task_executor_interface',
            source=[
                'task_executor.cpp',
            ],
            LIBDEPS=[
                '$BUILD_DIR/mongo/base',
                'remote_command',
            ])

env.Library(target='scoped_task_executor',
            source=[
                'scoped_task_executor.cpp',
            ],
            LIBDEPS=[
                'task_executor_interface',
                '$BUILD_DIR/mongo/util/fail_point',
            ])

env.Library(target='network_interface',
            source=['network_interface.cpp',],
            LIBDEPS=[
                'task_executor_interface',
            ])

env.Library('network_interface_mock',
            [
                'network_interface_mock.cpp',
                'thread_pool_mock.cpp',
            ],
            LIBDEPS=[
                '$BUILD_DIR/mongo/base',
                '$BUILD_DIR/mongo/rpc/metadata',
                '$BUILD_DIR/mongo/util/clock_source_mock',
                '$BUILD_DIR/mongo/util/net/network',
                'network_interface',
                'task_executor_interface',
            ])

env.Library(
    target='connection_pool_executor',
    source=[
       'connection_pool.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
        '$BUILD_DIR/mongo/util/net/network',
        'connection_pool_stats',
        'remote_command',
    ],
    LIBDEPS_PRIVATE=[
        'egress_tag_closer_manager',
    ],
)

env.Library(target='network_test_env',
            source=['network_test_env.cpp',],
            LIBDEPS=[
                '$BUILD_DIR/mongo/db/commands',
                '$BUILD_DIR/mongo/db/query/command_request_response',
                'network_interface_mock',
                'task_executor_interface',
            ])

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

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

env.Library(
    target='network_interface_tl',
    source=[
        'connection_pool_tl.cpp',
        'network_interface_tl.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/client/async_client',
        '$BUILD_DIR/mongo/transport/transport_layer',
        'hedging_metrics',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/transport/transport_layer_manager',
        'connection_pool_executor',
        'network_interface',
    ]
)

env.Library(
    target='network_interface_fixture',
    source=[
        'network_interface_integration_fixture.cpp'
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/unittest/integration_test_main',
        '$BUILD_DIR/mongo/executor/thread_pool_task_executor',
        '$BUILD_DIR/mongo/executor/network_interface_thread_pool',
        '$BUILD_DIR/mongo/executor/network_interface_factory',
        '$BUILD_DIR/mongo/rpc/command_status',
        '$BUILD_DIR/mongo/util/concurrency/thread_pool',
        '$BUILD_DIR/mongo/util/version_impl',
    ]
)

env.Library(
    target='network_interface_factory',
    source=[
        'network_interface_factory.cpp',
    ],
    LIBDEPS=[
        'connection_pool_executor',
    ],
    LIBDEPS_PRIVATE=[
        'network_interface',
        'network_interface_tl',
        'egress_tag_closer_manager',
    ])

env.Library(
    target='task_executor_test_fixture',
    source=[
        'task_executor_test_common.cpp',
        'task_executor_test_fixture.cpp'
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/util/clock_source_mock',
        '$BUILD_DIR/mongo/unittest/unittest',
        'network_interface_mock',
        'task_executor_interface',
    ]
)

env.Library(
    target='thread_pool_task_executor',
    source=[
        'thread_pool_task_executor.cpp',
    ],
    LIBDEPS=[
        'task_executor_interface',
        '$BUILD_DIR/mongo/util/fail_point',
        '$BUILD_DIR/mongo/db/service_context',
    ],
    LIBDEPS_PRIVATE=[
        'network_interface',
    ]
)

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

env.Library(
    target='thread_pool_task_executor_test_fixture',
    source=[
        'thread_pool_task_executor_test_fixture.cpp',
        ],
    LIBDEPS=[
        'task_executor_test_fixture',
        'thread_pool_task_executor',
    ]
)

env.Library(
    target='task_executor_pool',
    source=[
        'task_executor_pool.cpp',
        "task_executor_pool_parameters.idl",
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/idl/server_parameter',
        '$BUILD_DIR/mongo/util/processinfo',
        'task_executor_interface',
    ],
)

env.Library(
    target='task_executor_cursor',
    source=[
        'task_executor_cursor.cpp',
    ],
    LIBDEPS=[
        'task_executor_interface',
        '$BUILD_DIR/mongo/db/query/command_request_response',
    ],
)

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

env.CppUnitTest(
    target='executor_test',
    source=[
        'connection_pool_test.cpp',
        'connection_pool_test_fixture.cpp',
        'network_interface_mock_test.cpp',
        'scoped_task_executor_test.cpp',
        'task_executor_cursor_test.cpp',
        'thread_pool_task_executor_test.cpp',
    ],
    LIBDEPS=[
        'connection_pool_executor',
        'egress_tag_closer_manager',
        'network_interface_mock',
        'scoped_task_executor',
        'task_executor_cursor',
        'thread_pool_task_executor',
        'thread_pool_task_executor_test_fixture',
    ],
)

env.CppIntegrationTest(
    target='executor_integration_test',
    source=[
        'network_interface_integration_test.cpp',
        'task_executor_cursor_integration_test.cpp',
        'non_auth_task_executor_integration_test.cpp',
        'thread_pool_task_executor_integration_test.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/client/clientdriver_network',
        '$BUILD_DIR/mongo/db/wire_version',
        '$BUILD_DIR/mongo/executor/network_interface_factory',
        '$BUILD_DIR/mongo/executor/network_interface_thread_pool',
        '$BUILD_DIR/mongo/executor/thread_pool_task_executor',
        '$BUILD_DIR/mongo/transport/transport_layer_egress_init',
        '$BUILD_DIR/mongo/util/concurrency/thread_pool',
        '$BUILD_DIR/mongo/util/version_impl',
        'network_interface_fixture',
        'non_auth_task_executor',
        'task_executor_cursor',
    ],
)
