added support for c++ 2011
authorimarom <[email protected]>
Tue, 11 Aug 2015 12:28:32 +0000 (15:28 +0300)
committerimarom <[email protected]>
Tue, 11 Aug 2015 12:28:32 +0000 (15:28 +0300)
this requires some compiler support (checking version, adding RPATH)

linux/b
linux/ws_main.py
linux_dpdk/ws_main.py

diff --git a/linux/b b/linux/b
index a308cf6..b33a440 100755 (executable)
--- 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
 
index 93ed02b..b6e4fcc 100755 (executable)
@@ -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,12 @@ net_src = SrcGroup(dir='src/common/Network/Packet',
            'MacAddress.cpp',
            'VLANHeader.cpp']);
 
+# JSON package
+json_src = SrcGroup(dir='external_libs/json',
+        src_list=[
+            'jsoncpp.cpp'
+           ])
+
 yaml_src = SrcGroup(dir='yaml-cpp/src/',
         src_list=[
             'aliasmanager.cpp',
@@ -152,15 +178,18 @@ bp =SrcGroups([
                 main_src, 
                 cmn_src ,
                 net_src ,
-                yaml_src
+                yaml_src,
+                json_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',
        ];
 
 
@@ -268,9 +297,11 @@ 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']
 
@@ -293,9 +324,9 @@ def build_prog (bld, build_obj):
     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),
+                rpath  = bld.env.RPATH,
                 target = build_obj.get_target())
 
 
index 223a81f..af55981 100755 (executable)
@@ -130,6 +130,12 @@ net_src = SrcGroup(dir='src/common/Network/Packet',
            'MacAddress.cpp',
            'VLANHeader.cpp']);
 
+# JSON package
+json_src = SrcGroup(dir='external_libs/json',
+        src_list=[
+            'jsoncpp.cpp'
+           ])
+
 yaml_src = SrcGroup(dir='yaml-cpp/src/',
         src_list=[
             'aliasmanager.cpp',
@@ -320,6 +326,7 @@ bp =SrcGroups([
                 cmn_src ,
                 net_src ,
                 yaml_src,
+                json_src,
                 version_src
                 ]);