# -*- mode: python -*-

Import("env")

#
# The db/'common' lib has the abstractions that are shared by components of the
# server. Ideally, many of the object in 'coredb' should be moved here when their dependencies
# get resolved.
#

env.Library(
    target= 'common',
    source= [
        'field_ref.cpp',
        'field_ref_set.cpp',
        'field_parser.cpp',
        'keypattern.cpp',
        'write_concern_options.cpp'
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/bson',
        '$BUILD_DIR/mongo/util/foundation',
        '$BUILD_DIR/mongo/db/index_names'
    ],
)

env.CppUnitTest(
    target= 'field_ref_test',
    source= 'field_ref_test.cpp',
    LIBDEPS=[
        'common',
    ],
)

env.CppUnitTest(
    target= 'field_ref_set_test',
    source = 'field_ref_set_test.cpp',
    LIBDEPS=[
        'common',
    ],
)

env.CppUnitTest(
    target= 'field_parser_test',
    source= 'field_parser_test.cpp',
    LIBDEPS=[
        'common',
    ],
)

env.CppUnitTest(
    target= 'hasher_test',
    source= [
        'hasher_test.cpp',
    ],
    LIBDEPS=[
        'common',
        '$BUILD_DIR/mongo/db/mongohasher',
    ],
)

env.CppUnitTest(
    target= 'keypattern_test',
    source= 'keypattern_test.cpp',
    LIBDEPS=[
        'common'
    ],
)

env.CppUnitTest(
    target="dbmessage_test",
    source=[
        "dbmessage_test.cpp"
    ],
    LIBDEPS=[
        "common",
        "$BUILD_DIR/mongo/client/clientdriver",
    ],
)
env.CppUnitTest('record_id_test', 'record_id_test.cpp', LIBDEPS=[])

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

env.Library(
    target='startup_warnings_mongod',
    source=[
        'startup_warnings_mongod.cpp',
    ],
    LIBDEPS=[
        'startup_warnings_common',
        '$BUILD_DIR/mongo/processinfo',
    ]
)

env.CppUnitTest(
    target='startup_warnings_mongod_test',
    source=[
        'startup_warnings_mongod_test.cpp',
    ],
    LIBDEPS=[
        'startup_warnings_mongod',
    ],
)

env.Library(
    target='curop',
    source=[
        'curop.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/commands/server_status_core',
        '$BUILD_DIR/mongo/db/concurrency/lock_manager',
        '$BUILD_DIR/mongo/db/stats/top',
        '$BUILD_DIR/mongo/fail_point',
        '$BUILD_DIR/mongo/util/net/network',
        '$BUILD_DIR/mongo/service_context',
        '$BUILD_DIR/mongo/util/progress_meter',
    ],
)

env.CppUnitTest(
    target='curop_test',
    source=[
        'curop_test.cpp',
    ],
    LIBDEPS=[
        'curop',
    ],
)

env.Library(
    target='index_names',
    source=[
        "index_names.cpp",
    ],
)

env.Library(
    target='mongohasher',
    source=[
        "hasher.cpp",
    ],
)

# Range arithmetic library, used by both mongod and mongos
env.Library(
    target='range_arithmetic',
    source=[
        'range_arithmetic.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/bson',
        '$BUILD_DIR/mongo/util/foundation',
    ],
)

env.CppUnitTest(
    target='range_arithmetic_test',
    source=[
        'range_arithmetic_test.cpp',
    ],
    LIBDEPS=[
        'range_arithmetic',
    ],
)

env.Library(
    target='global_timestamp',
    source=[
        'global_timestamp.cpp',
    ],
)
