# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-

from waflib import Utils

top = '..'

def build(bld):
    # Single object tools:
    # tools/example-tool.cpp is a self-contained tool with a main() function
    # and is built as build/bin/example-tool.
    # These tools cannot be unit-tested.
    for tool in bld.path.ant_glob('*.cpp'):
        name = tool.change_ext('').path_from(bld.path.get_bld())
        bld.program(name=name,
                    target='../bin/%s' % name,
                    source=[tool],
                    use='NDN_CXX libndn-nac')

    # Sub-directory tools:
    # tools/example-tool/**/*.cpp is compiled and linked into build/bin/example-tool.
    # tools/example-tool/main.cpp must exist and must contain the main() function.
    # All other objects are collected into 'tools-objects' and can be unit-tested.
    testableObjects = []
    for subdir in bld.path.ant_glob('*', dir=True, src=False):
        mainFile = subdir.find_node('main.cpp')
        if mainFile is None:
            continue # not a C++ tool

        name = subdir.path_from(bld.path)
        srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp'])
        srcObjects = ''
        if srcFiles:
            srcObjects = 'tools-%s-objects' % name
            bld.objects(target=srcObjects,
                        source=srcFiles,
                        use='NDN_CXX libndn-nac',
                        includes=name)
            testableObjects.append(srcObjects)

        bld.program(name=name,
                    target='../bin/%s' % name,
                    source=[mainFile],
                    use='NDN_CXX libndn-nac ' + srcObjects,
                    includes=name)

    bld.objects(target='tools-objects',
                source=[],
                export_includes='.',
                use=testableObjects)

    # Tool wrappers
    wrapperFiles = bld.path.ant_glob('wrapper/*.sh')
    bld(name='wrappers',
        features='subst',
        source=wrapperFiles,
        target=['../bin/%s' % node.change_ext('', '.sh').path_from(bld.path.find_dir('wrapper').get_bld())
                for node in wrapperFiles],
        install_path='${BINDIR}',
        chmod=Utils.O755)
