ws_main.py revision 057a1ec1
1#!/usr/bin/env python
2# encoding: utf-8
3#
4# Hanoh Haim
5# Cisco Systems, Inc.
6
7VERSION='0.0.1'
8APPNAME='cxx_test'
9import os;
10import shutil;
11import copy;
12import re
13import uuid
14import subprocess
15import platform
16from waflib import Logs
17from waflib.Configure import conf
18from waflib import Build
19
20# use hostname as part of cache filename
21Build.CACHE_SUFFIX = '_%s_cache.py' % platform.node()
22
23# these variables are mandatory ('/' are converted automatically)
24top = '../'
25out = 'build_dpdk'
26
27
28b_path ="./build/linux_dpdk/"
29
30C_VER_FILE      = "version.c"
31H_VER_FILE      = "version.h"
32
33BUILD_NUM_FILE  = "../VERSION"
34USERS_ALLOWED_TO_RELEASE = ['hhaim']
35
36
37#######################################
38# utility for group source code
39###################################
40
41orig_system = os.system
42
43def verify_system(cmd):
44    ret = orig_system(cmd)
45    if ret:
46        raise Exception('Return code %s on command: system("%s")' % (ret, cmd))
47
48os.system = verify_system
49
50
51class SrcGroup:
52    ' group of source by directory '
53
54    def __init__(self,dir,src_list):
55      self.dir = dir;
56      self.src_list = src_list;
57      self.group_list = None;
58      assert (type(src_list)==list)
59      assert (type(dir)==str)
60
61
62
63    def file_list (self,top):
64        ' return  the long list of the files '
65        res=''
66        for file in self.src_list:
67            res= res + top+'/'+self.dir+'/'+file+'  ';
68
69        return res;
70
71    def __str__ (self):
72        return (self.file_list(''));
73
74    def __repr__ (self):
75        return (self.file_list(''));
76
77
78
79class SrcGroups:
80    ' group of source groups '
81
82    def __init__(self,list_group):
83      self.list_group = list_group;
84      assert (type(list_group)==list)
85
86
87    def file_list (self,top):
88          ' return  the long list of the files '
89          res=''
90          for o in self.list_group:
91              res += o.file_list(top);
92          return res;
93
94    def __str__ (self):
95          return (self.file_list(''));
96
97    def __repr__ (self):
98          return (self.file_list(''));
99
100
101def options(opt):
102    opt.load('compiler_cxx')
103    opt.load('compiler_c')
104    opt.add_option('--pkg-dir', '--pkg_dir', dest='pkg_dir', default=False, action='store', help="Destination folder for 'pkg' option.")
105    opt.add_option('--pkg-file', '--pkg_file', dest='pkg_file', default=False, action='store', help="Destination filename for 'pkg' option.")
106    opt.add_option('--publish-commit', '--publish_commit', dest='publish_commit', default=False, action='store', help="Specify commit id for 'publish_both' option (Please make sure it's good!)")
107
108
109def check_ibverbs_deps(bld):
110    if 'LDD' not in bld.env or not len(bld.env['LDD']):
111        bld.fatal('Please run configure. Missing key LDD.')
112    cmd = '%s %s/external_libs/ibverbs/libibverbs.so' % (bld.env['LDD'][0], top)
113    ret, out = getstatusoutput(cmd)
114    if ret or not out:
115        bld.fatal("Command of checking libraries '%s' failed.\nReturn status: %s\nOutput: %s" % (cmd, ret, out))
116    if '=> not found' in out:
117        Logs.pprint('YELLOW', 'Could not find dependency libraries of libibverbs.so:')
118        for line in out.splitlines():
119            if '=> not found' in line:
120                Logs.pprint('YELLOW', line)
121        dumy_libs_path = os.path.abspath(top + 'scripts/dumy_libs')
122        Logs.pprint('YELLOW', 'Adding rpath of %s' % dumy_libs_path)
123        rpath_linkage.append(dumy_libs_path)
124
125
126def missing_pkg_msg(fedora, ubuntu):
127    msg = 'not found\n'
128    fedora_install = 'Fedora install:\nsudo yum install %s\n' % fedora
129    ubuntu_install = 'Ubuntu install:\nsudo apt install %s\n' % ubuntu
130    try:
131        if platform.linux_distribution()[0].capitalize() == 'Ubuntu':
132            msg += ubuntu_install
133        elif platform.linux_distribution()[0].capitalize() == 'Fedora':
134            msg += fedora_install
135        else:
136            raise
137    except:
138        msg += 'Could not determine Linux distribution.\n%s\n%s' % (ubuntu_install, fedora_install)
139    return msg
140
141
142@conf
143def check_ofed(ctx):
144    ctx.start_msg('Checking for OFED')
145    ofed_info='/usr/bin/ofed_info'
146    ofed_ver= '-3.4-'
147    ofed_ver_show= 'v3.4'
148
149    if not os.path.isfile(ofed_info):
150        ctx.end_msg('not found', 'YELLOW')
151        return False
152
153    ret, out = getstatusoutput(ofed_info)
154    if ret:
155        ctx.end_msg("Can't run %s to verify version:\n%s" % (ofed_info, out), 'YELLOW')
156        return False
157
158    lines = out.splitlines()
159    if len(lines) < 2:
160        ctx.end_msg('Expected several output lines from %s, got:\n%s' % (ofed_info, out), 'YELLOW')
161        return False
162
163    if ofed_ver not in lines[0]:
164        ctx.end_msg('Expected version: %s, got: %s.' % (ofed_ver, lines[0]), 'YELLOW')
165        return False
166
167    ctx.end_msg('Found needed version %s' % ofed_ver_show)
168    return True
169
170
171def configure(conf):
172    conf.load('g++')
173    conf.load('gcc')
174    conf.find_program('ldd')
175    conf.check_cxx(lib = 'z', errmsg = missing_pkg_msg(fedora = 'zlib-devel', ubuntu = 'zlib1g-dev'))
176    ofed_ok = conf.check_ofed(mandatory = False)
177    if ofed_ok:
178        conf.check_cxx(lib = 'ibverbs', errmsg = 'Could not find library ibverbs, will use internal version.', mandatory = False)
179    else:
180        Logs.pprint('YELLOW', 'Warning: will use internal version of ibverbs. If you need to use Mellanox NICs, install OFED:\n' +
181                              'https://trex-tgn.cisco.com/trex/doc/trex_manual.html#_mellanox_connectx_4_support')
182
183
184def getstatusoutput(cmd):
185    """    Return (status, output) of executing cmd in a shell. Taken from Python3 subprocess.getstatusoutput"""
186    try:
187        data = subprocess.check_output(cmd, shell=True, universal_newlines=True, stderr=subprocess.STDOUT)
188        status = 0
189    except subprocess.CalledProcessError as ex:
190        data = ex.output
191        status = ex.returncode
192    if data[-1:] == '\n':
193        data = data[:-1]
194    return status, data
195
196main_src = SrcGroup(dir='src',
197        src_list=[
198             'bp_sim.cpp',
199             'utl_term_io.cpp',
200             'global_io_mode.cpp',
201             'main_dpdk.cpp',
202             'trex_watchdog.cpp',
203             'trex_client_config.cpp',
204             'debug.cpp',
205             'flow_stat.cpp',
206             'flow_stat_parser.cpp',
207             'inet_pton.cpp',
208             'pkt_gen.cpp',
209             'platform_cfg.cpp',
210             'pre_test.cpp',
211             'tuple_gen.cpp',
212             'rx_check.cpp',
213             'rx_check_header.cpp',
214             'stateful_rx_core.cpp',
215             'timer_wheel_pq.cpp',
216             'time_histogram.cpp',
217             'os_time.cpp',
218             'utl_cpuu.cpp',
219             'utl_ip.cpp',
220             'utl_json.cpp',
221             'utl_yaml.cpp',
222             'nat_check.cpp',
223             'nat_check_flow_table.cpp',
224             'msg_manager.cpp',
225             'trex_port_attr.cpp',
226             'publisher/trex_publisher.cpp',
227             'pal/linux_dpdk/pal_utl.cpp',
228             'pal/linux_dpdk/mbuf.cpp',
229             'pal/common/common_mbuf.cpp'
230             ]);
231
232cmn_src = SrcGroup(dir='src/common',
233    src_list=[
234        'basic_utils.cpp',
235        'captureFile.cpp',
236        'erf.cpp',
237        'pcap.cpp',
238        'base64.cpp'
239        ]);
240
241net_src = SrcGroup(dir='src/common/Network/Packet',
242        src_list=[
243           'CPktCmn.cpp',
244           'EthernetHeader.cpp',
245           'IPHeader.cpp',
246           'IPv6Header.cpp',
247           'TCPHeader.cpp',
248           'TCPOptions.cpp',
249           'UDPHeader.cpp',
250           'MacAddress.cpp',
251           'VLANHeader.cpp']);
252
253# JSON package
254json_src = SrcGroup(dir='external_libs/json',
255        src_list=[
256            'jsoncpp.cpp'
257           ])
258
259# RPC code
260rpc_server_src = SrcGroup(dir='src/rpc-server/',
261                          src_list=[
262                              'trex_rpc_server.cpp',
263                              'trex_rpc_req_resp_server.cpp',
264                              'trex_rpc_async_server.cpp',
265                              'trex_rpc_jsonrpc_v2_parser.cpp',
266                              'trex_rpc_cmds_table.cpp',
267                              'trex_rpc_cmd.cpp',
268                              'trex_rpc_zip.cpp',
269
270                              'commands/trex_rpc_cmd_test.cpp',
271                              'commands/trex_rpc_cmd_general.cpp',
272                              'commands/trex_rpc_cmd_stream.cpp',
273
274                          ])
275
276
277ef_src = SrcGroup(dir='src/common',
278    src_list=[
279        'ef/efence.cpp',
280        'ef/page.cpp',
281        'ef/print.cpp'
282        ]);
283
284
285# stateless code
286stateless_src = SrcGroup(dir='src/stateless/',
287                          src_list=['cp/trex_stream.cpp',
288                                    'cp/trex_stream_vm.cpp',
289                                    'cp/trex_stateless.cpp',
290                                    'cp/trex_stateless_port.cpp',
291                                    'cp/trex_streams_compiler.cpp',
292                                    'cp/trex_vm_splitter.cpp',
293                                    'cp/trex_dp_port_events.cpp',
294                                    'dp/trex_stateless_dp_core.cpp',
295                                    'messaging/trex_stateless_messaging.cpp',
296                                    'rx/trex_stateless_rx_core.cpp',
297                                    'rx/trex_stateless_rx_port_mngr.cpp'
298                                    ])
299# JSON package
300json_src = SrcGroup(dir='external_libs/json',
301                    src_list=[
302                        'jsoncpp.cpp'
303                        ])
304
305yaml_src = SrcGroup(dir='external_libs/yaml-cpp/src/',
306        src_list=[
307            'aliasmanager.cpp',
308            'binary.cpp',
309            'contrib/graphbuilder.cpp',
310            'contrib/graphbuilderadapter.cpp',
311            'conversion.cpp',
312            'directives.cpp',
313            'emitfromevents.cpp',
314            'emitter.cpp',
315            'emitterstate.cpp',
316            'emitterutils.cpp',
317            'exp.cpp',
318            'iterator.cpp',
319            'node.cpp',
320            'nodebuilder.cpp',
321            'nodeownership.cpp',
322            'null.cpp',
323            'ostream.cpp',
324            'parser.cpp',
325            'regex.cpp',
326            'scanner.cpp',
327            'scanscalar.cpp',
328            'scantag.cpp',
329            'scantoken.cpp',
330            'simplekey.cpp',
331            'singledocparser.cpp',
332            'stream.cpp',
333            'tag.cpp']);
334
335
336version_src = SrcGroup(
337    dir='linux_dpdk',
338    src_list=[
339        'version.c',
340    ])
341
342
343dpdk_src = SrcGroup(dir='src/dpdk/',
344                src_list=[
345                 '../dpdk_funcs.c',
346                 'drivers/net/af_packet/rte_eth_af_packet.c',
347                 'drivers/net/cxgbe/base/t4_hw.c',
348                 'drivers/net/cxgbe/cxgbe_ethdev.c',
349                 'drivers/net/cxgbe/cxgbe_main.c',
350                 'drivers/net/cxgbe/sge.c',
351                 'drivers/net/e1000/base/e1000_80003es2lan.c',
352                 'drivers/net/e1000/base/e1000_82540.c',
353                 'drivers/net/e1000/base/e1000_82541.c',
354                 'drivers/net/e1000/base/e1000_82542.c',
355                 'drivers/net/e1000/base/e1000_82543.c',
356                 'drivers/net/e1000/base/e1000_82571.c',
357                 'drivers/net/e1000/base/e1000_82575.c',
358                 'drivers/net/e1000/base/e1000_api.c',
359                 'drivers/net/e1000/base/e1000_i210.c',
360                 'drivers/net/e1000/base/e1000_ich8lan.c',
361                 'drivers/net/e1000/base/e1000_mac.c',
362                 'drivers/net/e1000/base/e1000_manage.c',
363                 'drivers/net/e1000/base/e1000_mbx.c',
364                 'drivers/net/e1000/base/e1000_nvm.c',
365                 'drivers/net/e1000/base/e1000_osdep.c',
366                 'drivers/net/e1000/base/e1000_phy.c',
367                 'drivers/net/e1000/base/e1000_vf.c',
368                 'drivers/net/e1000/em_ethdev.c',
369                 'drivers/net/e1000/em_rxtx.c',
370                 'drivers/net/e1000/igb_ethdev.c',
371                 'drivers/net/e1000/igb_pf.c',
372                 'drivers/net/e1000/igb_rxtx.c',
373                 'drivers/net/enic/base/vnic_cq.c',
374                 'drivers/net/enic/base/vnic_dev.c',
375                 'drivers/net/enic/base/vnic_intr.c',
376                 'drivers/net/enic/base/vnic_rq.c',
377                 'drivers/net/enic/base/vnic_rss.c',
378                 'drivers/net/enic/base/vnic_wq.c',
379                 'drivers/net/enic/enic_clsf.c',
380                 'drivers/net/enic/enic_ethdev.c',
381                 'drivers/net/enic/enic_main.c',
382                 'drivers/net/enic/enic_res.c',
383                 'drivers/net/enic/enic_rxtx.c',
384                 'drivers/net/fm10k/base/fm10k_api.c',
385                 'drivers/net/fm10k/base/fm10k_common.c',
386                 'drivers/net/fm10k/base/fm10k_mbx.c',
387                 'drivers/net/fm10k/base/fm10k_pf.c',
388                 'drivers/net/fm10k/base/fm10k_tlv.c',
389                 'drivers/net/fm10k/base/fm10k_vf.c',
390                 'drivers/net/fm10k/fm10k_ethdev.c',
391                 'drivers/net/fm10k/fm10k_rxtx.c',
392                 'drivers/net/fm10k/fm10k_rxtx_vec.c',
393                 'drivers/net/ixgbe/base/ixgbe_82598.c',
394                 'drivers/net/ixgbe/base/ixgbe_82599.c',
395                 'drivers/net/ixgbe/base/ixgbe_api.c',
396                 'drivers/net/ixgbe/base/ixgbe_common.c',
397                 'drivers/net/ixgbe/base/ixgbe_dcb.c',
398                 'drivers/net/ixgbe/base/ixgbe_dcb_82598.c',
399                 'drivers/net/ixgbe/base/ixgbe_dcb_82599.c',
400                 'drivers/net/ixgbe/base/ixgbe_mbx.c',
401                 'drivers/net/ixgbe/base/ixgbe_phy.c',
402                 'drivers/net/ixgbe/base/ixgbe_vf.c',
403                 'drivers/net/ixgbe/base/ixgbe_x540.c',
404                 'drivers/net/ixgbe/base/ixgbe_x550.c',
405                 'drivers/net/ixgbe/ixgbe_ethdev.c',
406                 'drivers/net/ixgbe/ixgbe_fdir.c',
407                 'drivers/net/ixgbe/ixgbe_pf.c',
408                 'drivers/net/ixgbe/ixgbe_rxtx.c',
409                 'drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c',
410
411                 'drivers/net/mlx5/mlx5_mr.c',
412                 'drivers/net/mlx5/mlx5_ethdev.c',
413                 'drivers/net/mlx5/mlx5_mac.c',
414                 'drivers/net/mlx5/mlx5_rxmode.c',
415                 'drivers/net/mlx5/mlx5_rxtx.c',
416                 'drivers/net/mlx5/mlx5_stats.c',
417                 'drivers/net/mlx5/mlx5_txq.c',
418                 'drivers/net/mlx5/mlx5.c',
419                 'drivers/net/mlx5/mlx5_fdir.c',
420                 'drivers/net/mlx5/mlx5_rss.c',
421                 'drivers/net/mlx5/mlx5_rxq.c',
422                 'drivers/net/mlx5/mlx5_trigger.c',
423                 'drivers/net/mlx5/mlx5_vlan.c',
424
425                 'drivers/net/i40e/base/i40e_adminq.c',
426                 'drivers/net/i40e/base/i40e_common.c',
427                 'drivers/net/i40e/base/i40e_dcb.c',
428                 'drivers/net/i40e/base/i40e_diag.c',
429                 'drivers/net/i40e/base/i40e_hmc.c',
430                 'drivers/net/i40e/base/i40e_lan_hmc.c',
431                 'drivers/net/i40e/base/i40e_nvm.c',
432#                 'drivers/net/i40e/i40e_ethdev_vf.c',
433                 'drivers/net/i40e/i40e_pf.c',
434                 'drivers/net/i40e/i40e_rxtx.c',
435                 'drivers/net/i40e/i40e_rxtx_vec.c',
436                 'drivers/net/i40e/i40e_fdir.c',
437                 'drivers/net/i40e/i40e_ethdev.c',
438                 'drivers/net/null/rte_eth_null.c',
439                 'drivers/net/ring/rte_eth_ring.c',
440                 'drivers/net/virtio/virtio_ethdev.c',
441                 'drivers/net/virtio/virtio_pci.c',
442                 'drivers/net/virtio/virtio_rxtx.c',
443                 'drivers/net/virtio/virtio_rxtx_simple.c',
444                 'drivers/net/virtio/virtqueue.c',
445                 '/drivers/net/vmxnet3/vmxnet3_ethdev.c',
446                 '/drivers/net/vmxnet3/vmxnet3_rxtx.c',
447                 'lib/librte_cfgfile/rte_cfgfile.c',
448                 'lib/librte_eal/common/arch/x86/rte_cpuflags.c',
449                 'lib/librte_eal/common/arch/x86/rte_spinlock.c',
450                 'lib/librte_eal/common/eal_common_cpuflags.c',
451                 'lib/librte_eal/common/eal_common_dev.c',
452                 'lib/librte_eal/common/eal_common_devargs.c',
453                 'lib/librte_eal/common/eal_common_errno.c',
454                 'lib/librte_eal/common/eal_common_hexdump.c',
455                 'lib/librte_eal/common/eal_common_launch.c',
456                 'lib/librte_eal/common/eal_common_lcore.c',
457                 'lib/librte_eal/common/eal_common_log.c',
458                 'lib/librte_eal/common/eal_common_memory.c',
459                 'lib/librte_eal/common/eal_common_memzone.c',
460                 'lib/librte_eal/common/eal_common_options.c',
461                 'lib/librte_eal/common/eal_common_pci.c',
462                 'lib/librte_eal/common/eal_common_pci_uio.c',
463                 'lib/librte_eal/common/eal_common_string_fns.c',
464                 'lib/librte_eal/common/eal_common_tailqs.c',
465                 'lib/librte_eal/common/eal_common_thread.c',
466                 'lib/librte_eal/common/eal_common_timer.c',
467                 'lib/librte_eal/common/malloc_elem.c',
468                 'lib/librte_eal/common/malloc_heap.c',
469                 'lib/librte_eal/common/rte_keepalive.c',
470                 'lib/librte_eal/common/rte_malloc.c',
471                 'lib/librte_eal/linuxapp/eal/eal.c',
472                 'lib/librte_eal/linuxapp/eal/eal_alarm.c',
473                 'lib/librte_eal/linuxapp/eal/eal_debug.c',
474                 'lib/librte_eal/linuxapp/eal/eal_hugepage_info.c',
475                 'lib/librte_eal/linuxapp/eal/eal_interrupts.c',
476                 'lib/librte_eal/linuxapp/eal/eal_ivshmem.c',
477                 'lib/librte_eal/linuxapp/eal/eal_lcore.c',
478                 'lib/librte_eal/linuxapp/eal/eal_log.c',
479                 'lib/librte_eal/linuxapp/eal/eal_memory.c',
480                 'lib/librte_eal/linuxapp/eal/eal_pci.c',
481                 'lib/librte_eal/linuxapp/eal/eal_pci_uio.c',
482                 'lib/librte_eal/linuxapp/eal/eal_pci_vfio.c',
483                 'lib/librte_eal/linuxapp/eal/eal_thread.c',
484                 'lib/librte_eal/linuxapp/eal/eal_timer.c',
485                 'lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c',
486                 'lib/librte_eal/linuxapp/eal/eal_vfio.c',
487                 'lib/librte_ether/rte_ethdev.c',
488                 'lib/librte_hash/rte_cuckoo_hash.c',
489                 'lib/librte_kvargs/rte_kvargs.c',
490                 'lib/librte_mbuf/rte_mbuf.c',
491                 'lib/librte_mempool/rte_mempool.c',
492                 'lib/librte_mempool/rte_mempool_ops.c',
493                 'lib/librte_mempool/rte_mempool_ring.c',
494                 'lib/librte_pipeline/rte_pipeline.c',
495                 'lib/librte_ring/rte_ring.c',
496            ]);
497
498bp_dpdk =SrcGroups([
499                dpdk_src
500                ]);
501
502# this is the library dp going to falcon (and maybe other platforms)
503bp =SrcGroups([
504                main_src,
505                cmn_src ,
506                net_src ,
507                yaml_src,
508                rpc_server_src,
509                json_src,
510                stateless_src,
511                version_src
512                ]);
513
514l2fwd_main_src = SrcGroup(dir='src',
515        src_list=[
516             'l2fwd/main.c'
517             ]);
518
519
520l2fwd =SrcGroups([
521                l2fwd_main_src]);
522
523
524# common flags for both new and old configurations
525common_flags = ['-DWIN_UCODE_SIM',
526                '-D_BYTE_ORDER',
527                '-D_LITTLE_ENDIAN',
528                '-DLINUX',
529                '-g',
530                '-Wno-format',
531                '-Wno-deprecated-declarations',
532                '-DRTE_DPDK',
533                '-D__STDC_LIMIT_MACROS',
534                '-D__STDC_FORMAT_MACROS',
535                '-include','../src/pal/linux_dpdk/dpdk0716/rte_config.h'
536               ]
537
538common_flags_new = common_flags + [
539                    '-march=native',
540                    '-DRTE_MACHINE_CPUFLAG_SSE',
541                    '-DRTE_MACHINE_CPUFLAG_SSE2',
542                    '-DRTE_MACHINE_CPUFLAG_SSE3',
543                    '-DRTE_MACHINE_CPUFLAG_SSSE3',
544                    '-DRTE_MACHINE_CPUFLAG_SSE4_1',
545                    '-DRTE_MACHINE_CPUFLAG_SSE4_2',
546                    '-DRTE_MACHINE_CPUFLAG_AES',
547                    '-DRTE_MACHINE_CPUFLAG_PCLMULQDQ',
548                    '-DRTE_MACHINE_CPUFLAG_AVX',
549                    '-DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2,RTE_CPUFLAG_AES,RTE_CPUFLAG_PCLMULQDQ,RTE_CPUFLAG_AVX',
550                   ]
551
552common_flags_old = common_flags + [
553                      '-march=corei7',
554                      '-DUCS_210',
555                      '-mtune=generic',
556                      '-DRTE_MACHINE_CPUFLAG_SSE',
557                      '-DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE',
558                      ];
559
560
561
562
563includes_path =''' ../src/pal/linux_dpdk/
564                   ../src/pal/common/
565                   ../src/
566
567                   ../src/rpc-server/
568                   ../src/stateless/cp/
569                   ../src/stateless/dp/
570                   ../src/stateless/rx/
571                   ../src/stateless/messaging/
572
573                   ../external_libs/yaml-cpp/include/
574                   ../external_libs/zmq/include/
575                   ../external_libs/json/
576
577../src/dpdk/drivers/net/af_packet/
578../src/dpdk/drivers/net/bnx2x/
579../src/dpdk/drivers/net/bonding/
580../src/dpdk/drivers/net/cxgbe/
581../src/dpdk/drivers/net/cxgbe/base/
582../src/dpdk/drivers/net/e1000/
583../src/dpdk/drivers/net/e1000/base/
584../src/dpdk/drivers/net/fm10k/
585../src/dpdk/drivers/net/fm10k/base/
586../src/dpdk/drivers/net/i40e/
587../src/dpdk/drivers/net/i40e/base/
588../src/dpdk/drivers/net/ixgbe/
589../src/dpdk/drivers/net/ixgbe/base/
590../src/dpdk/drivers/net/mlx4/
591../src/dpdk/drivers/net/mlx5/
592../src/dpdk/drivers/net/mpipe/
593../src/dpdk/drivers/net/null/
594../src/dpdk/drivers/net/pcap/
595../src/dpdk/drivers/net/ring/
596../src/dpdk/drivers/net/szedata2/
597../src/dpdk/drivers/net/virtio/
598../src/dpdk/drivers/net/xenvirt/
599../src/dpdk/lib/librte_acl/
600../src/dpdk/lib/librte_cfgfile/
601../src/dpdk/lib/librte_compat/
602../src/dpdk/lib/librte_distributor/
603../src/dpdk/lib/librte_eal/
604../src/dpdk/lib/librte_eal/common/
605../src/dpdk/lib/librte_eal/common/include/
606../src/dpdk/lib/librte_eal/common/include/arch/
607../src/dpdk/lib/librte_eal/common/include/arch/x86/
608../src/dpdk/lib/librte_eal/common/include/generic/
609../src/dpdk/lib/librte_eal/linuxapp/
610../src/dpdk/lib/librte_eal/linuxapp/eal/
611../src/dpdk/lib/librte_eal/linuxapp/eal/include/
612../src/dpdk/lib/librte_eal/linuxapp/eal/include/exec-env/
613../src/dpdk/lib/librte_eal/linuxapp/igb_uio/
614../src/dpdk/lib/librte_eal/linuxapp/xen_dom0/
615../src/dpdk/lib/librte_ether/
616../src/dpdk/lib/librte_hash/
617../src/dpdk/lib/librte_kvargs/
618../src/dpdk/lib/librte_mbuf/
619../src/dpdk/lib/librte_mempool/
620../src/dpdk/lib/librte_net/
621../src/dpdk/lib/librte_pipeline/
622../src/dpdk/lib/librte_ring/
623              ''';
624
625
626dpdk_includes_verb_path =''
627
628dpdk_includes_path =''' ../src/
629                        ../src/pal/linux_dpdk/
630                        ../src/pal/linux_dpdk/dpdk
631../src/dpdk/drivers/
632../src/dpdk/drivers/net/
633../src/dpdk/drivers/net/af_packet/
634../src/dpdk/drivers/net/bnx2x/
635../src/dpdk/drivers/net/bonding/
636../src/dpdk/drivers/net/cxgbe/
637../src/dpdk/drivers/net/cxgbe/base/
638../src/dpdk/drivers/net/e1000/
639../src/dpdk/drivers/net/e1000/base/
640../src/dpdk/drivers/net/enic/
641../src/dpdk/drivers/net/enic/base/
642../src/dpdk/drivers/net/fm10k/
643../src/dpdk/drivers/net/fm10k/base/
644../src/dpdk/drivers/net/i40e/
645../src/dpdk/drivers/net/i40e/base/
646../src/dpdk/drivers/net/ixgbe/
647../src/dpdk/drivers/net/ixgbe/base/
648../src/dpdk/drivers/net/mlx4/
649../src/dpdk/drivers/net/mlx5/
650../src/dpdk/drivers/net/mpipe/
651../src/dpdk/drivers/net/null/
652../src/dpdk/drivers/net/pcap/
653../src/dpdk/drivers/net/ring/
654../src/dpdk/drivers/net/virtio/
655../src/dpdk/drivers/net/vmxnet3/
656../src/dpdk/drivers/net/vmxnet3/base
657../src/dpdk/drivers/net/xenvirt/
658../src/dpdk/lib/
659../src/dpdk/lib/librte_acl/
660../src/dpdk/lib/librte_cfgfile/
661../src/dpdk/lib/librte_compat/
662../src/dpdk/lib/librte_distributor/
663../src/dpdk/lib/librte_eal/
664../src/dpdk/lib/librte_eal/common/
665../src/dpdk/lib/librte_eal/common/include/
666../src/dpdk/lib/librte_eal/common/include/arch/
667../src/dpdk/lib/librte_eal/common/include/arch/x86/
668../src/dpdk/lib/librte_eal/common/include/generic/
669../src/dpdk/lib/librte_eal/linuxapp/
670../src/dpdk/lib/librte_eal/linuxapp/eal/
671../src/dpdk/lib/librte_eal/linuxapp/eal/include/
672../src/dpdk/lib/librte_eal/linuxapp/eal/include/exec-env/
673../src/dpdk/lib/librte_eal/linuxapp/igb_uio/
674../src/dpdk/lib/librte_eal/linuxapp/xen_dom0/
675../src/dpdk/lib/librte_ether/
676../src/dpdk/lib/librte_hash/
677../src/dpdk/lib/librte_kvargs/
678../src/dpdk/lib/librte_mbuf/
679../src/dpdk/lib/librte_mempool/
680../src/dpdk/lib/librte_pipeline/
681../src/dpdk/lib/librte_ring/
682../src/dpdk/lib/librte_net/
683../src/dpdk/lib/librte_port/
684../src/dpdk/lib/librte_pipeline/
685../src/dpdk/lib/librte_table/
686../src/dpdk/
687''';
688
689
690
691
692DPDK_FLAGS=['-D_GNU_SOURCE', '-DPF_DRIVER', '-DX722_SUPPORT', '-DX722_A0_SUPPORT', '-DVF_DRIVER', '-DINTEGRATED_VF'];
693
694client_external_libs = [
695        'enum34-1.0.4',
696        'jsonrpclib-pelix-0.2.5',
697        'pyyaml-3.11',
698        'pyzmq-14.5.0',
699        'scapy-2.3.1',
700        'texttable-0.8.4',
701        ]
702
703rpath_linkage = []
704
705RELEASE_    = "release"
706DEBUG_      = "debug"
707PLATFORM_64 = "64"
708PLATFORM_32 = "32"
709
710
711class build_option:
712
713    def __init__(self,platform,debug_mode,is_pie):
714      self.mode     = debug_mode;   ##debug,release
715      self.platform = platform; #['32','64']
716      self.is_pie = is_pie
717
718    def __str__(self):
719       s=self.mode+","+self.platform;
720       return (s);
721
722    def lib_name(self,lib_name_p,full_path):
723        if full_path:
724            return b_path+lib_name_p;
725        else:
726            return lib_name_p;
727    #private functions
728    def toLib (self,name,full_path = True):
729        lib_n = "lib"+name+".a";
730        return (self.lib_name(lib_n,full_path));
731
732    def toExe(self,name,full_path = True):
733        return (self.lib_name(name,full_path));
734
735    def is64Platform (self):
736        return ( self.platform == PLATFORM_64);
737
738    def isRelease (self):
739        return ( self.mode  == RELEASE_);
740
741    def isPIE (self):
742        return self.is_pie
743
744    def update_executable_name (self,name):
745        return self.update_name(name,"-")
746
747    def update_non_exe_name (self,name):
748        return self.update_name(name,"_")
749
750    def update_name (self,name,delimiter):
751        trg = copy.copy(name);
752        if self.is64Platform():
753            trg += delimiter + "64";
754        else:
755            trg += delimiter + "32";
756
757        if self.isRelease () :
758            trg += "";
759        else:
760            trg +=  delimiter + "debug";
761
762        if self.isPIE():
763            trg += delimiter + "o"
764        return trg;
765
766    def get_target (self):
767        return self.update_executable_name("_t-rex");
768
769    def get_target_l2fwd (self):
770        return self.update_executable_name("l2fwd");
771
772    def get_dpdk_target (self):
773        return self.update_executable_name("dpdk");
774
775    def get_common_flags (self):
776        if self.isPIE():
777            flags = copy.copy(common_flags_old)
778        else:
779            flags = copy.copy(common_flags_new);
780
781        if self.is64Platform () :
782            flags += ['-m64'];
783        else:
784            flags += ['-m32'];
785
786        if self.isRelease () :
787            flags += ['-O3'];
788        else:
789            flags += ['-O0','-D_DEBUG'];
790
791        return (flags)
792
793    def get_cxx_flags (self):
794        flags = self.get_common_flags()
795
796        # support c++ 2011
797        flags += ['-std=c++0x']
798
799        flags += ['-Wall',
800                  '-Werror',
801                  '-Wno-literal-suffix',
802                  '-Wno-sign-compare',
803                  '-Wno-strict-aliasing']
804
805        return (flags)
806
807    def get_c_flags (self):
808        flags = self.get_common_flags()
809        if  self.isRelease () :
810            flags += ['-DNDEBUG'];
811
812        # for C no special flags yet
813        return (flags)
814
815    def get_link_flags(self):
816        base_flags = ['-rdynamic'];
817        if self.is64Platform():
818            base_flags += ['-m64'];
819            base_flags += ['-lrt'];
820        else:
821            base_flags += ['-lrt'];
822
823        return base_flags;
824
825
826
827build_types = [
828               build_option(debug_mode= DEBUG_, platform = PLATFORM_64, is_pie = False),
829               build_option(debug_mode= RELEASE_,platform = PLATFORM_64, is_pie = False),
830               build_option(debug_mode= DEBUG_, platform = PLATFORM_64, is_pie = True),
831               build_option(debug_mode= RELEASE_,platform = PLATFORM_64, is_pie = True),
832              ]
833
834
835def build_prog (bld, build_obj):
836
837    #rte_libs =[
838    #         'dpdk'];
839
840    #rte_libs1 = rte_libs+rte_libs+rte_libs;
841
842    #for obj in rte_libs:
843    #    bld.read_shlib( name=obj , paths=[top+rte_lib_path] )
844
845    # add electric fence only for debug image
846    debug_file_list='';
847    if not build_obj.isRelease ():
848        debug_file_list +=ef_src.file_list(top)
849
850    bld.objects(
851      features='c ',
852      includes = dpdk_includes_path+dpdk_includes_verb_path,
853
854      cflags   = (build_obj.get_c_flags()+DPDK_FLAGS ),
855      source   = bp_dpdk.file_list(top),
856      target=build_obj.get_dpdk_target()
857      );
858
859    bld.program(features='cxx cxxprogram',
860                includes =includes_path,
861                cxxflags =(build_obj.get_cxx_flags()+['-std=gnu++11',]),
862                linkflags = build_obj.get_link_flags() ,
863                lib=['pthread','dl', 'z'],
864                use =[build_obj.get_dpdk_target(),'zmq','ibverbs'],
865                source = bp.file_list(top) + debug_file_list,
866                rpath = rpath_linkage,
867                target = build_obj.get_target())
868
869
870
871def build_type(bld,build_obj):
872    build_prog(bld, build_obj);
873
874
875def post_build(bld):
876    print("copy objects")
877    exec_p ="../scripts/"
878    for obj in build_types:
879        install_single_system(bld, exec_p, obj);
880
881def build(bld):
882    global dpdk_includes_verb_path;
883    bld.add_pre_fun(pre_build)
884    bld.add_post_fun(post_build);
885
886    zmq_lib_path='external_libs/zmq/'
887    bld.read_shlib( name='zmq' , paths=[top+zmq_lib_path] )
888    if bld.env['LIB_IBVERBS']:
889        Logs.pprint('GREEN', 'Info: Using external libverbs.')
890        bld.read_shlib(name='ibverbs')
891    else:
892        Logs.pprint('GREEN', 'Info: Using internal libverbs.')
893        ibverbs_lib_path='external_libs/ibverbs/'
894        dpdk_includes_verb_path =' \n ../external_libs/ibverbs/include/ \n'
895        bld.read_shlib( name='ibverbs' , paths=[top+ibverbs_lib_path] )
896        check_ibverbs_deps(bld)
897
898    for obj in build_types:
899        build_type(bld,obj);
900
901
902def build_info(bld):
903    pass;
904
905def install_single_system (bld, exec_p, build_obj):
906    o='build_dpdk/linux_dpdk/';
907    src_file =  os.path.realpath(o+build_obj.get_target())
908    if os.path.exists(src_file):
909        dest_file = exec_p +build_obj.get_target()
910        print(dest_file)
911        if not os.path.lexists(dest_file):
912            relative_path = os.path.relpath(src_file, exec_p)
913            os.symlink(relative_path, dest_file);
914
915
916def pre_build(bld):
917    print("update version files")
918    create_version_files ()
919
920
921def write_file (file_name,s):
922    f=open(file_name,'w')
923    f.write(s)
924    f.close()
925
926
927def get_build_num ():
928    s='';
929    if os.path.isfile(BUILD_NUM_FILE):
930        f=open(BUILD_NUM_FILE,'r');
931        s+=f.readline().rstrip();
932        f.close();
933    return s;
934
935def create_version_files ():
936    git_sha="N/A"
937    try:
938      r=getstatusoutput("git log --pretty=format:'%H' -n 1")
939      if r[0]==0:
940          git_sha=r[1]
941    except :
942        pass;
943
944
945    s =''
946    s +="#ifndef __TREX_VER_FILE__           \n"
947    s +="#define __TREX_VER_FILE__           \n"
948    s +="#ifdef __cplusplus                  \n"
949    s +=" extern \"C\" {                        \n"
950    s +=" #endif                             \n";
951    s +='#define  VERSION_USER  "%s"          \n' % os.environ.get('USER', 'unknown')
952    s +='extern const char * get_build_date(void);  \n'
953    s +='extern const char * get_build_time(void);  \n'
954    s +='#define VERSION_UIID      "%s"       \n' % uuid.uuid1()
955    s +='#define VERSION_GIT_SHA   "%s"       \n' % git_sha
956    s +='#define VERSION_BUILD_NUM "%s"       \n' % get_build_num()
957    s +="#ifdef __cplusplus                  \n"
958    s +=" }                        \n"
959    s +=" #endif                             \n";
960    s +="#endif \n"
961
962    write_file (H_VER_FILE ,s)
963
964    s ='#include "version.h"          \n'
965    s +='#define VERSION_UIID1      "%s"       \n' % uuid.uuid1()
966    s +="const char * get_build_date(void){ \n"
967    s +="    return (__DATE__);       \n"
968    s +="}      \n"
969    s +=" \n"
970    s +="const char * get_build_time(void){ \n"
971    s +="    return (__TIME__ );       \n"
972    s +="}      \n"
973
974    write_file (C_VER_FILE,s)
975
976def build_test(bld):
977    create_version_files ()
978
979def _copy_single_system (bld, exec_p, build_obj):
980    o='build_dpdk/linux_dpdk/';
981    src_file =  os.path.realpath(o+build_obj.get_target())
982    print(src_file)
983    if os.path.exists(src_file):
984        dest_file = exec_p +build_obj.get_target()
985        print(dest_file)
986        os.system("cp %s %s " %(src_file,dest_file));
987        os.system("chmod +x %s " %(dest_file));
988
989def _copy_single_system1 (bld, exec_p, build_obj):
990    o='../scripts/';
991    src_file =  os.path.realpath(o+build_obj.get_target()[1:])
992    print(src_file)
993    if os.path.exists(src_file):
994        dest_file = exec_p +build_obj.get_target()[1:]
995        os.system("cp %s %s " %(src_file,dest_file));
996        os.system("chmod +x %s " %(dest_file));
997
998
999def copy_single_system (bld, exec_p, build_obj):
1000    _copy_single_system (bld, exec_p, build_obj)
1001
1002def copy_single_system1 (bld, exec_p, build_obj):
1003    _copy_single_system1 (bld, exec_p, build_obj)
1004
1005
1006files_list=[
1007            'libzmq.so.3',
1008            'trex-cfg',
1009            'bp-sim-64',
1010            'bp-sim-64-debug',
1011            't-rex-64-debug-gdb',
1012            'stl-sim',
1013            'find_python.sh',
1014            'run_regression',
1015            'run_functional_tests',
1016            'dpdk_nic_bind.py',
1017            'dpdk_setup_ports.py',
1018            'doc_process.py',
1019            'trex_daemon_server',
1020            'master_daemon.py',
1021            'trex-console',
1022            'daemon_server'
1023            ];
1024
1025files_dir=['cap2','avl','cfg','ko','automation', 'external_libs', 'python-lib','stl','exp','dumy_libs']
1026
1027
1028class Env(object):
1029    @staticmethod
1030    def get_env(name) :
1031        s= os.environ.get(name);
1032        if s == None:
1033            print("You should define $ %s" % name)
1034            raise Exception("Env error");
1035        return (s);
1036
1037    @staticmethod
1038    def get_release_path () :
1039        s= Env().get_env('TREX_LOCAL_PUBLISH_PATH');
1040        s +=get_build_num ()+"/"
1041        return  s;
1042
1043    @staticmethod
1044    def get_remote_release_path () :
1045        s= Env().get_env('TREX_REMOTE_PUBLISH_PATH');
1046        return  s;
1047
1048    @staticmethod
1049    def get_local_web_server () :
1050        s= Env().get_env('TREX_WEB_SERVER');
1051        return  s;
1052
1053    # extral web
1054    @staticmethod
1055    def get_trex_ex_web_key() :
1056        s= Env().get_env('TREX_EX_WEB_KEY');
1057        return  s;
1058
1059    @staticmethod
1060    def get_trex_ex_web_path() :
1061        s= Env().get_env('TREX_EX_WEB_PATH');
1062        return  s;
1063
1064    @staticmethod
1065    def get_trex_ex_web_user() :
1066        s= Env().get_env('TREX_EX_WEB_USER');
1067        return  s;
1068
1069    @staticmethod
1070    def get_trex_ex_web_srv() :
1071        s= Env().get_env('TREX_EX_WEB_SRV');
1072        return  s;
1073
1074    @staticmethod
1075    def get_trex_regression_workspace():
1076        return Env().get_env('TREX_REGRESSION_WORKSPACE')
1077
1078
1079def check_release_permission():
1080    if os.getenv('USER') not in USERS_ALLOWED_TO_RELEASE:
1081        raise Exception('You are not allowed to release TRex. Please contact Hanoch.')
1082
1083# build package in parent dir. can provide custom name and folder with --pkg-dir and --pkg-file
1084def pkg(self):
1085    build_num = get_build_num()
1086    pkg_dir = self.options.pkg_dir
1087    if not pkg_dir:
1088        pkg_dir = os.pardir
1089    pkg_file = self.options.pkg_file
1090    if not pkg_file:
1091        pkg_file = '%s.tar.gz' % build_num
1092    tmp_path = os.path.join(pkg_dir, '_%s' % pkg_file)
1093    dst_path = os.path.join(pkg_dir, pkg_file)
1094    build_path = os.path.join(os.pardir, build_num)
1095
1096    # clean old dir if exists
1097    os.system('rm -rf %s' % build_path)
1098    release(self, build_path + '/')
1099    os.system("cp %s/%s.tar.gz %s" % (build_path, build_num, tmp_path))
1100    os.system("mv %s %s" % (tmp_path, dst_path))
1101
1102    # clean new dir
1103    os.system('rm -rf %s' % build_path)
1104
1105
1106def release(bld, custom_dir = None):
1107    """ release to local folder  """
1108    if custom_dir:
1109        exec_p = custom_dir
1110    else:
1111        check_release_permission()
1112        exec_p = Env().get_release_path()
1113    print("copy images and libs")
1114    os.system(' mkdir -p '+exec_p);
1115
1116    for obj in build_types:
1117        copy_single_system (bld,exec_p,obj);
1118        copy_single_system1 (bld,exec_p,obj)
1119
1120    for obj in files_list:
1121        src_file =  '../scripts/'+obj
1122        dest_file = exec_p +'/'+obj
1123        os.system("cp %s %s " %(src_file,dest_file));
1124
1125    for obj in files_dir:
1126        src_file =  '../scripts/'+obj+'/'
1127        dest_file = exec_p +'/'+obj+'/'
1128        os.system("cp -rv %s %s " %(src_file,dest_file));
1129        os.system("chmod 755 %s " %(dest_file));
1130
1131    rel=get_build_num ()
1132
1133    # create client package
1134    os.system('mkdir -p %s/trex_client/external_libs' % exec_p)
1135    for ext_lib in client_external_libs:
1136        os.system('cp ../scripts/external_libs/%s %s/trex_client/external_libs/ -r' % (ext_lib, exec_p))
1137    os.system('cp ../scripts/automation/trex_control_plane/stf %s/trex_client/ -r' % exec_p)
1138    os.system('cp ../scripts/automation/trex_control_plane/stl %s/trex_client/ -r' % exec_p)
1139    with open('%s/trex_client/stl/examples/stl_path.py' % exec_p) as f:
1140        stl_path_content = f.read()
1141    if 'STL_PROFILES_PATH' not in stl_path_content:
1142        raise Exception('Could not find STL_PROFILES_PATH in stl/examples/stl_path.py')
1143    stl_path_content = re.sub('STL_PROFILES_PATH.*?\n', "STL_PROFILES_PATH = os.path.join(os.pardir, 'profiles')\n", stl_path_content)
1144    with open('%s/trex_client/stl/examples/stl_path.py' % exec_p, 'w') as f:
1145        f.write(stl_path_content)
1146    os.system('cp ../scripts/stl %s/trex_client/stl/profiles -r' % exec_p)
1147    shutil.make_archive(os.path.join(exec_p, 'trex_client_%s' % rel), 'gztar', exec_p, 'trex_client')
1148    os.system('rm -r %s/trex_client' % exec_p)
1149
1150    os.system('cd %s/..;tar --exclude="*.pyc" -zcvf %s/%s.tar.gz %s' %(exec_p,os.getcwd(),rel,rel))
1151    os.system("mv %s/%s.tar.gz %s" % (os.getcwd(),rel,exec_p));
1152
1153
1154def publish(bld, custom_source = None):
1155    check_release_permission()
1156    exec_p = Env().get_release_path()
1157    rel=get_build_num ()
1158
1159    release_name ='%s.tar.gz' % (rel);
1160    if custom_source:
1161        from_ = custom_source
1162    else:
1163        from_ = exec_p+'/'+release_name;
1164    os.system("rsync -av %s %s:%s/%s " %(from_,Env().get_local_web_server(),Env().get_remote_release_path (), release_name))
1165    os.system("ssh %s 'cd %s;rm be_latest; ln -P %s be_latest'  " %(Env().get_local_web_server(),Env().get_remote_release_path (),release_name))
1166    os.system("ssh %s 'cd %s;rm latest; ln -P %s latest'  " %(Env().get_local_web_server(),Env().get_remote_release_path (),release_name))
1167
1168
1169def publish_ext(bld, custom_source = None):
1170    check_release_permission()
1171    exec_p = Env().get_release_path()
1172    rel=get_build_num ()
1173
1174    release_name ='%s.tar.gz' % (rel);
1175    if custom_source:
1176        from_ = custom_source
1177    else:
1178        from_ = exec_p+'/'+release_name;
1179    cmd='rsync -avz --progress -e "ssh -i %s" --rsync-path=/usr/bin/rsync %s %s@%s:%s/release/%s' % (Env().get_trex_ex_web_key(),from_, Env().get_trex_ex_web_user(),Env().get_trex_ex_web_srv(),Env().get_trex_ex_web_path() ,release_name)
1180    print(cmd)
1181    os.system( cmd )
1182    os.system("ssh -i %s -l %s %s 'cd %s/release/;rm be_latest; ln -P %s be_latest'  " %(Env().get_trex_ex_web_key(),Env().get_trex_ex_web_user(),Env().get_trex_ex_web_srv(),Env().get_trex_ex_web_path(),release_name))
1183    os.system("ssh -i %s -l %s %s 'cd %s/release/;rm latest; ln -P %s latest'  " %(Env().get_trex_ex_web_key(),Env().get_trex_ex_web_user(),Env().get_trex_ex_web_srv(),Env().get_trex_ex_web_path(),release_name))
1184
1185# publish latest passed regression package (or custom commit from  --publish_commit option) as be_latest to trex-tgn.cisco.com and internal wiki
1186def publish_both(self):
1187    check_release_permission()
1188    packages_dir = Env().get_env('TREX_LOCAL_PUBLISH_PATH') + '/experiment/packages'
1189    publish_commit = self.options.publish_commit
1190    if publish_commit:
1191        package_file = '%s/%s.tar.gz' % (packages_dir, publish_commit)
1192    else:
1193        last_passed_commit_file = Env().get_trex_regression_workspace() + '/reports/last_passed_commit'
1194        with open(last_passed_commit_file) as f:
1195            last_passed_commit = f.read().strip()
1196        package_file = '%s/%s.tar.gz' % (packages_dir, last_passed_commit)
1197    publish(self, custom_source = package_file)
1198    publish_ext(self, custom_source = package_file)
1199
1200# print detailed latest passed regression commit + brief info of 5 commits before it
1201def show(bld):
1202    last_passed_commit_file = Env().get_trex_regression_workspace() + '/reports/last_passed_commit'
1203    with open(last_passed_commit_file) as f:
1204        last_passed_commit = f.read().strip()
1205
1206    # last passed nightly
1207    command = 'timeout 10 git show %s --quiet' % last_passed_commit
1208    result, output = getstatusoutput(command)
1209    if result == 0:
1210        print('Last passed regression commit:\n%s\n' % output)
1211    else:
1212        raise Exception('Error getting commit info with command: %s' % command)
1213
1214    # brief list of 5 commits before passed
1215    result, output = getstatusoutput('git --version')
1216    if result != 0 or output.startswith('git version 1'):
1217        # old format, no color etc.
1218        command = "timeout 10 git log --no-merges -n 5 --pretty=format:'%%h  %%an  %%ci  %%s' %s^@" % last_passed_commit
1219    else:
1220        # new format, with color, padding, truncating etc.
1221        command = "timeout 10 git log --no-merges -n 5 --pretty=format:'%%C(auto)%%h%%Creset  %%<(10,trunc)%%an  %%ci  %%<(100,trunc)%%s' %s^@ " % last_passed_commit
1222    result, output = getstatusoutput(command)
1223    if result == 0:
1224        print(output)
1225    else:
1226        raise Exception('Error getting commits info with command: %s' % command)
1227
1228def test (bld):
1229    r=getstatusoutput("git log --pretty=format:'%H' -n 1")
1230    if r[0]==0:
1231        print(r[1])
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245