view wscript @ 72:9aebbf4e02f7

Added equip component, wich stores the equipment data of an entity.
author KarstenBock@gmx.net
date Wed, 07 Sep 2011 13:24:02 +0200
parents a2b1966ebe5a
children
line wrap: on
line source

#!/usr/bin/env python
# encoding: utf-8
import os
import platform

APPNAME = 'parpg'
VERSION = '0.2.0'

def options(opt):
    opt.load('waf_paths python')
    
    ext_dep = opt.add_option_group(
        'External dependencies',
        '',
    )
    ext_dep.add_option(
        '--fifepath',
        help='Path to where the fife Python package is located',
        default='',
        dest='fifepath',
    )

def configure(cnf):
    cnf.load('waf_paths python')
    if platform.system() == 'Windows':
        min_python_version = (2, 7)
    else:
        min_python_version = (2, 6)
    cnf.check_python_version(min_python_version)
    
    if cnf.options.fifepath:
        cnf.env['FIFEPATH'] = os.path.abspath(
            os.path.expanduser(cnf.options.fifepath)
        )
    else:
        cnf.env['FIFEPATH'] = cnf.env['PYTHONDIR']

def build(bld):
    subst_vars = _get_subst_vars(bld)
    
    if platform.system() == 'Windows':
        launcher_template = bld.path.find_node('bin/parpg.bat.in')
        launcher = bld.path.find_or_declare('parpg.bat')
    else:
        launcher_template = bld.path.find_node('bin/parpg.sh.in')
        launcher = bld.path.find_or_declare('parpg')
    args = dict(
        features='subst',
        source=launcher_template,
        target=launcher,
        install_path='${BINDIR}',
        chmod=0755,
    )
    args.update(subst_vars)
    bld(**args)
    
    bld(
        features='py',
        source=bld.path.ant_glob('src/parpg/**/*.py', dir=True),
        install_from='src',
    )
    
    args = dict(
        features='subst',
        source=bld.path.find_node('parpg.cfg.in'),
        target=bld.path.find_or_declare('parpg.cfg'),
        install_path='${SYSCONFDIR}',
        chmod=0644,
    )
    args.update(subst_vars)
    bld(**args)
    
    bld.install_files(
        files=bld.path.find_node('data').ant_glob('**/*'),
        dest='${DATADIR}',
        relative_trick=True,
        cwd=bld.path.find_node('data'),
        chmod=0644,
    )

def _get_subst_vars(cnf):
    # Set up substitution variables for the launcher and configuration files.
    subst_vars = {}
    install_path_names = cnf.env['INSTALL_PATHS']
    for path_name in install_path_names + ['PYTHONDIR']:
        subst_vars[path_name] = cnf.env[path_name]
    # If the destdir option is used we'll have to manually prefix any path
    # variables with it since env doesn't get updated.
    # NOTE M. George Hansen 2011-06-09: This should probably be done
    #     automatically. Maybe we should patch WAF and contribute it the WAF
    #     project.
    destdir = cnf.options.destdir
    if destdir:
        for key, path in subst_vars.items():
            # If this is an absolute path, prefix it with the destdir.
            if os.path.isabs(path):
                subst_vars[key] = os.path.join(
                    destdir,
                    os.path.splitdrive(path)[1].lstrip('/\\'),
                )
    subst_vars['FIFEPATH'] = cnf.env['FIFEPATH']
    return subst_vars