def build(ctx):
    # Exit early if we're just viewing the state.
    if ctx.options.dump_state:
        # print out the entire state
        ctx.db.dump_database()
        return 0

    # Exit early if we're just deleting a function.
    if ctx.options.delete_function:
        if not ctx.db.delete_function(ctx.options.delete_function):
            raise fbuild.Error('function %r not cached' %
                    ctx.options.delete_function)
        return 0

    # Exit early if we're just deleting a file.
    if ctx.options.delete_file:
        if not ctx.db.delete_file(ctx.options.delete_file):
            raise fbuild.Error('file %r not cached' % ctx.options.delete_file)
        return 0

    # We'll use the arguments as our targets.
    targets = ctx.args or ['build']

    # Installation stuff.
    if 'install' in targets:
        if targets[-1] != 'install':
            raise fbuild.Error('install must be last target')
        if not set(targets) - {'configure', 'install'}:
            targets.insert(targets.index('install')-1, 'build')

    # Step through each target and execute it.
    for target_name in targets:
        if target_name == 'install':
            install_files(ctx)
        else:
            target = fbuild.target.find(target_name)
            target.function(ctx)

    return 0

# ------------------------------------------------------------------------------
dataset/ETHPy150Open felix-lang/fbuild/lib/fbuild/main.py/build/original