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

Import('BuildEnv')
import platform
import os

env = BuildEnv.Clone()

env.Append(CPPPATH = env['TOP'])
env.Append(CPPPATH = [env['TOP'] + '/database'])
env.Append(CPPPATH = env['TOP'] + '/ifmap/client/test')
env.Append(CPPPATH = env['TOP'] + '/config-client-mgr')
env.Append(CXXFLAGS = '-Wno-deprecated-declarations -DGTEST_USE_OWN_TR1_TUPLE=1 -std=c++11')

env.Append(LIBPATH = env['TOP'] + '/io')
env.Append(LIBPATH = env['TOP'] + '/db')
env.Append(LIBPATH = env['TOP'] + '/base')
env.Append(LIBPATH = env['TOP'] + '/bgp')
env.Append(LIBPATH = env['TOP'] + '/base/test')
env.Append(LIBPATH = env['TOP'] + '/control-node')
env.Append(LIBPATH = env['TOP'] + '/ifmap')
env.Append(LIBPATH = env['TOP'] + '/ifmap/test')
env.Append(LIBPATH = env['TOP'] + '/xml')
env.Append(LIBPATH = env['TOP'] + '/xmpp')
env.Append(LIBPATH = env['TOP'] + '/schema')

etcd_incl = os.environ.get('CONTRAIL_ETCD_INCL');

if etcd_incl:
    env.Prepend(LIBS = [
                    'etcdql', 'protobuf', 'grpc++', 'grpc', 'z'
                   ])

env.Prepend(LIBS = [
                    'ifmapio', 'bgp_schema', 'ifmap_vnc', 'ifmap_server',
                    'xmpp', 'peer_sandesh',
                    'sandesh', 'http', 'http_parser', 'httpc',
                    'curl', 'sandeshvns', 'process_info', 'io', 'control_node',
                    'ifmap_common', 'bgp_schema', 'ifmap_vnc',
                    'ifmap_test_util', 'ifmap_test_util_agent',
                    'pugixml', 'xml', 'task_test', 'db', 'curl',
                    'base', 'gunit', 'crypto', 'ssl', 'boost_regex',
                    'config_client_mgr','ifmapio', 'libbgp_schema',
                    'libifmap_server', 'libifmap_vnc', 'cassandra_cql',
                    'cassandra', 'gendb', 'httpc',
                    'SimpleAmqpClient', 'rabbitmq'
                   ])

if platform.system() != 'Darwin':
    env.Append(LIBS = ['boost_chrono'])

config_json_parser_test = env.UnitTest('config_json_parser_test',
                                       ['config_json_parser_test.cc'])
env.Alias('src/ifmap/client:config_json_parser_test', config_json_parser_test)

if etcd_incl:
    config_etcd_json_parser_test = env.UnitTest('config_etcd_json_parser_test',
                                             ['config_etcd_json_parser_test.cc'])
    env.Alias('src/ifmap/client:config_etcd_json_parser_test', 
                                             config_etcd_json_parser_test)

    client_unit_tests = [config_json_parser_test,
                         config_etcd_json_parser_test]
else:
    client_unit_tests = [config_json_parser_test]

client_test = env.TestSuite('ifmap-test', client_unit_tests)

env.Alias('src/ifmap/client:test', client_test)
env.Alias('src/ifmap/client:flaky-test', [ ])
Return('client_unit_tests')
