# -*- mode: python; -*-

#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#
import os

Import('CfgmEnv')
env = CfgmEnv.Clone()

setup_sources = [
           'setup.py',
           'MANIFEST.in',
           'requirements.txt',
           'test-requirements.txt',
           '.stestr.conf',
           'tox.ini',
           '.coveragerc',
           'schema_transformer',
          ]

setup_sources_rules = []
for file in setup_sources:
    setup_sources_rules.append(
        env.Install(Dir('.'), "#controller/src/config/schema-transformer/" + file))

st_introspect_pkg = env.SandeshGenPy('st_introspect.sandesh', 'schema_transformer/sandesh/', False)

cd_cmd = 'cd ' + Dir('.').path + ' && '
sdist_depends = []
sdist_depends.extend(setup_sources_rules)
sdist_depends.extend(st_introspect_pkg)
pyver = env.GetPyVersion()
sdist_gen = env.Command('dist/schema_transformer-%s.tar.gz' % pyver,
                        'setup.py',
                        cd_cmd + 'python setup.py sdist')

env.Depends(sdist_gen, sdist_depends)
env.Default(sdist_gen)

# Documentation
doc_files = []
doc_files += env.SandeshGenDoc('st_introspect.sandesh')
doc_files += env['CFGM_DOC_FILES']

if 'install' in BUILD_TARGETS:
    install_cmd = env.Command(None, 'setup.py',
                              cd_cmd + 'python setup.py install %s' %
                              env['PYTHON_INSTALL_OPT'])
    env.Depends(install_cmd, sdist_depends)
    env.Alias('install', install_cmd)

env.Alias('install', env.Install(env['INSTALL_CONF'],
    'contrail-schema.conf'))
env.Alias('install', env.Install(
    env['INSTALL_MESSAGE_DOC'] + '/contrail-schema/', doc_files))

env.SetupPyTestSuite(
    sdist_gen,
    '/config/api-server/dist/contrail-api-server-%s.tar.gz' % pyver,
    '/../noarch/config/svc-monitor/dist/svc_monitor-%s.tar.gz' % pyver,
    use_tox=True)

# Local Variables:
# mode: python
# End:
