# -*- coding: utf-8 -*-
#
# WAF build script for geany-plugins - MultiTerm
#
# Copyright 2011 Matthew Brush <matt(at)geany(dot)org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

from build.wafutils import target_is_win32, install_docs

def build_vala_plugin(ctx, name, sources, vapi_dirs=None, packages=None,
    libraries=None, features=None):
    """
    Similar to build.wafutils.build_plugin() except it's for Vala.
    TODO: move this function to that module and make the
    geany.vapi/deps available for other plugins.
    """
    log_domain = name
    plugin_name = name.lower()
    vapi_dirs = vapi_dirs or []
    packages = packages or []
    libraries = libraries or []
    features = features or []

    libraries.extend(['GTK', 'GEANY'])
    features.extend(['c', 'cshlib'])

    install_path = '${G_PREFIX}/lib' if target_is_win32(ctx) else '${LIBDIR}/geany/'

    task = ctx.shlib(packages = packages,
                     features = features,
                     target = plugin_name,
                     source = sources,
                     vapi_dirs = vapi_dirs,
                     use = libraries,
                     vala_defines = [ 'G_LOG_DOMAIN="%s"' % log_domain ],
                     install_path = install_path)

    install_docs(ctx, plugin_name,
        'AUTHORS ChangeLog COPYING NEWS README THANKS TODO'.split())

    return task


name = 'MultiTerm'
sources = [ 'src/config.vala', 'src/context-menu.vala', 'src/defconf.vala',
    'src/notebook.vala', 'src/plugin.vala', 'src/shell-config.vala',
    'src/tab-label.vala', 'src/terminal.vala']
packages = [ 'gtk+-2.0', 'glib-2.0', 'vte', 'geany' ]
libraries = [ 'GTK', 'GLIB', 'VTE', 'GEANY' ]
vapi_dirs = [ 'src/vapi' ]

build_vala_plugin(bld, name, sources, vapi_dirs, packages, libraries)
