#! /usr/bin/env python
# WAF build script for Postler (based on Midori's wscript)
#
# This script is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file COPYING for the full license text.

import os

tests = os.listdir ('tests')
for test in tests:
    folder = 'tests' + os.sep + test
    if os.path.isdir (folder):
        files = os.listdir (folder)
        target = test
        source = ''
        for fila in files:
            if file[-5:] == '.vala':
                source += ' ' + test + os.sep + fila
        if not source:
            Utils.pprint ('RED', folder + ': No source files found')
            continue
    else:
        if test[-5:] == '.vala':
            target = test[:-5]
        else:
            continue
        source = test

    obj = bld.new_task_gen ('cc', 'program')
    obj.target = 'test-' + target
    obj.includes = '. ..'
    obj.source = source
    obj.find_sources_in_dirs ('../postler',
        excludes=['postler-reader.vala', 'postler-service.vala'])
    obj.vapi_dirs = '../postler'
    obj.uselib = 'GIO GTHREAD GTK LIBNOTIFY LIBCANBERRA INDICATE UNIQUE WEBKIT'
    obj.packages = 'config postler posix gio-2.0 gtk+-2.0 libnotify libcanberra ' \
                   'unique-1.0 webkit-1.0'
    obj.unit_test = 1

