# -*- mode: python; -*-
Import("env")
Import("has_option")

if has_option("tokubackup"):
    env.SConscript(
        dirs=[
            'backup',
        ],
    )

# Install tokumxse_stat.py
env.Append(ARCHIVE_ADDITIONS = [env.File('scripts/tokumxse_stat.py')])
env.Append(ARCHIVE_ADDITION_DIR_MAP = {'src/mongo/db/storage/tokuft/scripts': 'scripts'})

if has_option("PerconaFT"):
    env.Library(
        target='storage_tokuft_options',
        source=[
            'tokuft_dictionary_options.cpp',
            'tokuft_engine_options.cpp',
            'tokuft_global_options.cpp',
            'tokuft_options_init.cpp',
            ],
        LIBDEPS=[
            '$BUILD_DIR/mongo/db/catalog/collection_options',
            '$BUILD_DIR/mongo/util/options_parser/options_parser',
            ]
        )

    env.Library(
        target= 'storage_tokuft_base',
        source= [
            'periodically_durable_journal.cpp',
            'tokuft_capped_delete_range_optimizer.cpp',
            'tokuft_disk_format.cpp',
            'tokuft_engine.cpp',
            'tokuft_errors.cpp',
            'tokuft_dictionary.cpp',
            'tokuft_recovery_unit.cpp',
            ],
        LIBDEPS= [
            'storage_tokuft_options',
            '$BUILD_DIR/mongo/base',
            '$BUILD_DIR/mongo/bson/util/bson_extract',
            '$BUILD_DIR/mongo/db/catalog/collection_options',
            '$BUILD_DIR/mongo/db/index/index_descriptor',
            '$BUILD_DIR/mongo/db/repl/repl_coordinator_global',
            '$BUILD_DIR/mongo/db/service_context',
            '$BUILD_DIR/mongo/db/storage/bson_collection_catalog_entry',
            '$BUILD_DIR/mongo/db/storage/journal_listener',
            '$BUILD_DIR/mongo/db/storage/key_string',
            '$BUILD_DIR/mongo/db/storage/kv/dictionary/kv_engine_impl',
            '$BUILD_DIR/mongo/db/storage/storage_options',
            '$BUILD_DIR/mongo/util/foundation',
            '$BUILD_DIR/mongo/util/processinfo',
            ],
        SYSLIBDEPS= [
            'ftcxx',
            'tokufractaltree_static',
            'tokuportability_static',
            'z'],
        )

    env.Library(
        target= 'storage_tokuft',
        source= [
            'tokuft_init.cpp',
            'tokuft_engine_global_accessor.cpp',
            'tokuft_engine_server_parameters.cpp',
            'tokuft_engine_server_status.cpp',
            ],
        LIBDEPS= [
            'storage_tokuft_base',
            '$BUILD_DIR/mongo/db/storage/kv/kv_engine',
            '$BUILD_DIR/mongo/db/storage/kv/dictionary/kv_engine_impl',
            ]
        )

    # The sorted data impl and record store test harnesses each
    # utilize the tokuft_engine_test harness for convenience.
    env.Library(
       target='storage_tokuft_engine_test_lib',
       source=['tokuft_engine_test.cpp'
               ],
       LIBDEPS=[
            'storage_tokuft_base',
            ]
       )

    env.CppUnitTest(
       target='storage_tokuft_sorted_data_impl_test',
       source=['tokuft_sorted_data_impl_test.cpp'
               ],
       LIBDEPS=[
            'storage_tokuft_base',
            'storage_tokuft_engine_test_lib',
            '$BUILD_DIR/mongo/db/storage/sorted_data_interface_test_harness',
            ]
       )

    env.CppUnitTest(
       target='storage_tokuft_record_store_test',
       source=['tokuft_record_store_test.cpp'
               ],
       LIBDEPS=[
            'storage_tokuft_base',
            'storage_tokuft_engine_test_lib',
            '$BUILD_DIR/mongo/db/storage/record_store_test_harness',
            ]
       )

    env.CppUnitTest(
       target='storage_tokuft_engine_test',
       source=['tokuft_engine_test_shim.cpp'
               ],
       LIBDEPS=[
            'storage_tokuft_engine_test_lib',
            'storage_tokuft_base',
            '$BUILD_DIR/mongo/db/storage/kv/kv_engine_test_harness',
            ]
       )

    env.CppUnitTest(
       target='storage_tokuft_dictionary_test',
       source=['tokuft_dictionary_test.cpp'
               ],
       LIBDEPS=[
            'storage_tokuft_engine_test_lib',
            'storage_tokuft_base',
            '$BUILD_DIR/mongo/db/storage/kv/dictionary/kv_dictionary_test_harness'
            ]
       )
