summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorDan Klein <danklei@cisco.com>2015-08-23 18:52:11 +0300
committerDan Klein <danklei@cisco.com>2015-08-23 18:52:11 +0300
commit651a7d779551e193bd9dbadbe8b2a02bdab231b4 (patch)
treea42cb5ab0eca820899f9fedf538eef8d83ad4383 /linux
parent84bb24ace632141dd5ece01d5f4985239014f660 (diff)
parent3bfe53394f43a37ce02b09c6420751027c602047 (diff)
Merge branch 'master' into dan_latest
Diffstat (limited to 'linux')
-rwxr-xr-xlinux/b2
-rwxr-xr-xlinux/ws_main.py111
2 files changed, 94 insertions, 19 deletions
diff --git a/linux/b b/linux/b
index a308cf60..b33a4400 100755
--- a/linux/b
+++ b/linux/b
@@ -1,5 +1,5 @@
#! /bin/bash
-/router/bin/python-2.7.1 waf-1.6.8 $@
+python2.7 waf-1.6.8 $@
sts=$?
exit $sts
diff --git a/linux/ws_main.py b/linux/ws_main.py
index 93ed02b8..6a8967bf 100755
--- a/linux/ws_main.py
+++ b/linux/ws_main.py
@@ -7,15 +7,18 @@
VERSION='0.0.1'
APPNAME='cxx_test'
+
import os;
import commands;
import shutil;
import copy;
+from distutils.version import StrictVersion
top = '../'
out = 'build'
b_path ="./build/linux/"
+REQUIRED_CC_VERSION = "4.7.0"
class SrcGroup:
' group of source by directory '
@@ -68,8 +71,25 @@ class SrcGroups:
def options(opt):
opt.load('compiler_cxx')
+
+def verify_cc_version (env):
+ ver = '.'.join(env['CC_VERSION'])
+
+ if StrictVersion(ver) < REQUIRED_CC_VERSION:
+ print "\nMachine GCC version too low '{0}' - required at least '{1}'".format(ver, REQUIRED_CC_VERSION)
+ print "\n*** please set a compiler using CXX / AR enviorment variables ***\n"
+ exit(-1)
+
+
def configure(conf):
+ # start from clean
+ if 'RPATH' in os.environ:
+ conf.env.RPATH = os.environ['RPATH'].split(':')
+ else:
+ conf.env.RPATH = []
+
conf.load('g++')
+ verify_cc_version(conf.env)
main_src = SrcGroup(dir='src',
@@ -118,6 +138,38 @@ net_src = SrcGroup(dir='src/common/Network/Packet',
'MacAddress.cpp',
'VLANHeader.cpp']);
+# RPC code
+rpc_server_src = SrcGroup(dir='src/rpc-server/src',
+ src_list=[
+ 'trex_rpc_server.cpp',
+ 'trex_rpc_req_resp_server.cpp',
+ 'trex_rpc_jsonrpc_v2_parser.cpp',
+ 'trex_rpc_cmds_table.cpp',
+
+ 'commands/trex_rpc_cmd_test.cpp',
+ 'commands/trex_rpc_cmd_general.cpp',
+
+ ])
+
+# RPC mock server (test)
+rpc_server_mock_src = SrcGroup(dir='src/rpc-server/src',
+ src_list=[
+ 'trex_rpc_server_mock.cpp',
+ '../../gtest/rpc_test.cpp',
+ ])
+
+# JSON package
+json_src = SrcGroup(dir='external_libs/json',
+ src_list=[
+ 'jsoncpp.cpp'
+ ])
+
+rpc_server_mock = SrcGroups([cmn_src,
+ rpc_server_src,
+ rpc_server_mock_src,
+ json_src
+ ])
+
yaml_src = SrcGroup(dir='yaml-cpp/src/',
src_list=[
'aliasmanager.cpp',
@@ -152,22 +204,27 @@ bp =SrcGroups([
main_src,
cmn_src ,
net_src ,
- yaml_src
+ yaml_src,
]);
cxxflags_base =['-DWIN_UCODE_SIM',
- '-D_BYTE_ORDER',
- '-D_LITTLE_ENDIAN',
- '-DLINUX',
- '-g',
+ '-D_BYTE_ORDER',
+ '-D_LITTLE_ENDIAN',
+ '-DLINUX',
+ '-g',
+ '-Wno-deprecated-declarations',
+ '-std=c++0x',
];
includes_path =''' ../src/pal/linux/
+ ../src/zmq/include/
../src/
+ ../src/rpc-server/include
+ ../external_libs/json/
../yaml-cpp/include/
''';
@@ -183,10 +240,13 @@ PLATFORM_32 = "32"
class build_option:
- def __init__(self,platform,debug_mode,is_pie):
+ def __init__(self, name, src, platform, debug_mode, is_pie, use = []):
self.mode = debug_mode; ##debug,release
self.platform = platform; #['32','64']
self.is_pie = is_pie
+ self.name = name
+ self.src = src
+ self.use = use
def __str__(self):
s=self.mode+","+self.platform;
@@ -253,12 +313,18 @@ class build_option:
return result;
+ def get_use_libs (self):
+ return self.use
+
def get_target (self):
- return self.update_executable_name("bp-sim");
+ return self.update_executable_name(self.name);
def get_flags (self):
return self.cxxcomp_flags(cxxflags_base);
+ def get_src (self):
+ return self.src.file_list(top)
+
def get_link_flags(self):
# add here basic flags
base_flags = ['-lpthread'];
@@ -268,34 +334,39 @@ class build_option:
#platform depended flags
if self.is64Platform():
- base_flags += ['-m64'];
+ base_flags += ['-m64']
else:
- base_flags += ['-lrt'];
+ base_flags += ['-m32']
+ base_flags += ['-lrt']
+
if self.isPIE():
base_flags += ['-pie', '-DPATCH_FOR_PIE']
return base_flags;
- def get_exe (self,full_path = True):
- return self.toExe(self.get_target(),full_path);
-
build_types = [
- build_option(debug_mode= DEBUG_, platform = PLATFORM_32, is_pie = False),
- build_option(debug_mode= DEBUG_, platform = PLATFORM_64, is_pie = False),
- build_option(debug_mode= RELEASE_,platform = PLATFORM_32, is_pie = False),
- build_option(debug_mode= RELEASE_,platform = PLATFORM_64, is_pie = False),
+ build_option(name = "bp-sim", src = bp, debug_mode= DEBUG_, platform = PLATFORM_32, is_pie = False),
+ build_option(name = "bp-sim", src = bp, debug_mode= DEBUG_, platform = PLATFORM_64, is_pie = False),
+ build_option(name = "bp-sim", src = bp, debug_mode= RELEASE_,platform = PLATFORM_32, is_pie = False),
+ build_option(name = "bp-sim", src = bp, debug_mode= RELEASE_,platform = PLATFORM_64, is_pie = False)
+
+ #build_option(name = "mock-rpc-server", use = ['zmq'], src = rpc_server_mock, debug_mode= DEBUG_,platform = PLATFORM_64, is_pie = False),
]
def build_prog (bld, build_obj):
+ zmq_lib_path='src/zmq/'
+ bld.read_shlib( name='zmq' , paths=[top + zmq_lib_path] )
+
bld.program(features='cxx cxxprogram',
includes =includes_path,
cxxflags =build_obj.get_flags(),
- stlib = 'stdc++',
linkflags = build_obj.get_link_flags(),
- source = bp.file_list(top),
+ source = build_obj.get_src(),
+ use = build_obj.get_use_libs(),
+ rpath = bld.env.RPATH,
target = build_obj.get_target())
@@ -305,15 +376,19 @@ def build_type(bld,build_obj):
def post_build(bld):
print "copy objects"
+
exec_p ="../scripts/"
+
for obj in build_types:
install_single_system(bld, exec_p, obj);
def build(bld):
+
bld.add_post_fun(post_build);
for obj in build_types:
build_type(bld,obj);
+
def build_info(bld):
pass;