import os
Import('env')

#connector
os.system('echo \'genereate c++ code over protobuf [client.proto]...\' && protoc --cpp_out=. client.proto')
os.system('echo \'genereate c++ code over protobuf [server.proto]...\' && protoc --cpp_out=. server.proto')
os.system('echo \'genereate c++ code over protobuf [config.proto]...\' && protoc --cpp_out=. config.proto')
connector_src = Glob('*.cpp')
connector_src += Glob('*.cc')
connector_src += Glob('../../lib/librapidapp.a')
env.Program('connector_svr', connector_src, LIBS=['event', 'glog', 'gflags', 'protobuf', 'pthread'])

#connector client
connapi_src = Glob('client_api/connector_client_api*.cpp')
connapi_src += Glob('*.cc')
client_lib = env.StaticLibrary('client_api/cconnapi', connapi_src)
Install('../../lib', client_lib)

env.Append(CPPPATH=['./', '../../utils/'])
clientsrc = Glob('client_api/client_main.cpp')
env.Program('connector_client_test', clientsrc, OBJPREFIX='cclient_',
            LIBS=['cconnapi', 'rapidapp', 'event', 'glog', 'gflags', 'protobuf', 'pthread', 'boost_thread', 'boost_system'])

#connector svr api
os.system('cd server_api/ && echo \'genereate c++ code over protobuf [game_data.proto]...\' && protoc --cpp_out=. game_data.proto')

svrapi_src = Glob('server_api/connector_server_api.cpp')
svrapi_src += Glob('server.pb.cc')
server_lib = env.StaticLibrary('server_api/sconnapi', svrapi_src)
Install('../../lib', server_lib)

svr_src = Glob('server_api/connector_server_demo.cpp')
svr_src += Glob('server_api/connector_server_main.cpp')
env.Program('connector_server_test', svr_src, OBJPREFIX='cserver_',
            LIBS=['sconnapi', 'rapidapp', 'event', 'glog', 'gflags', 'protobuf'])


