"""Build object tests"""


def scons():
    """Execute build"""
    Import('env', 'prereqs')

    if not prereqs.test_requested():
        return

    denv = env.Clone()

    denv.require('isal')

    denv.AppendUnique(LIBPATH=[Dir('../../client/api')])

    denv.AppendUnique(RPATH_FULL=['$PREFIX/lib64/daos_srv'])

    ring_test_tgt = denv.SharedObject(['ring_map_place_obj.c',
                                       'place_obj_common.c'])
    jump_test_tgt = denv.SharedObject(['jump_map_place_obj.c',
                                       'place_obj_common.c',
                                       'jump_map_pda.c',
                                       'jump_map_pda_layout.c',
                                       'jump_map_dist.c',
                                       'placement_test.c'])
    pl_bench_tgt = denv.SharedObject(['pl_bench.c', 'place_obj_common.c'])

    libraries = ['daos', 'daos_common', 'gurt', 'uuid', 'cmocka', 'isal', 'm']

    ring_pl_test = denv.d_program('ring_pl_map', ring_test_tgt, LIBS=libraries)

    jump_pl_test = denv.d_program('jump_pl_map',
                                  jump_test_tgt + ['../../pool/srv_pool_map.c'], LIBS=libraries)

    pl_bench = denv.d_program('pl_bench', pl_bench_tgt, LIBS=libraries)

    denv.Install('$PREFIX/bin/', ring_pl_test)
    denv.Install('$PREFIX/bin/', jump_pl_test)
    denv.Install('$PREFIX/bin/', pl_bench)


if __name__ == "SCons.Script":
    scons()
