Skip to content

Commit

Permalink
utils: move Linux specific functions from vr_util.c to unix_util.c
Browse files Browse the repository at this point in the history
Changes required to support Contrail on Windows.
- Move functions from nl_util.c which depend on Linux APIs to unix_util.c.
- Compile unix_util.c with libvrutil.
- Prepare SConscript for building utils on Windows.

Change-Id: I9125ee53854fbeed896d377f78e96c457dfb64e8
Partial-Bug: #1734699
  • Loading branch information
Dariusz Sosnowski committed Dec 18, 2017
1 parent b95f348 commit 30f7c26
Show file tree
Hide file tree
Showing 4 changed files with 1,126 additions and 1,077 deletions.
47 changes: 36 additions & 11 deletions utils/SConscript
Expand Up @@ -2,6 +2,8 @@
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#

import sys

Import('VRouterEnv')

env = VRouterEnv.Clone()
Expand All @@ -14,7 +16,8 @@ if system_header_path:
env.Append(CPPPATH = system_header_path + '/include/')

# CFLAGS
env.Append(CCFLAGS = '-g')
if not sys.platform.startswith('win'):
env.Append(CCFLAGS = '-g')

if 'install' in COMMAND_LINE_TARGETS:
VRutilsEnv.Append(SRC_INSTALL_TARGET = '/utils/')
Expand All @@ -29,12 +32,21 @@ for sdir in subdirs:
libvrutil = 'vrutil'
libvrutil_objs = [env.Object('nl_util.lo', 'nl_util.c'), env.Object('udp_util.lo', 'udp_util.c'),
env.Object('ini_parser.lo', 'ini_parser.c'), env.Object('vr_util.lo', 'vr_util.c')]

if sys.platform.startswith('win'):
libvrutil_objs.append(env.Object('windows_util.lo', 'windows_util.c'))
else:
libvrutil_objs.append(env.Object('unix_util.lo', 'unix_util.c'))

env.StaticLibrary(libvrutil, libvrutil_objs)

env.Replace(LIBPATH = env['TOP_LIB'])
env.Append(LIBPATH = ['.', '../sandesh'])
env.Replace(LIBS = [libvrutil, 'sandesh-c', 'dp_sandesh_c'])

if sys.platform.startswith('win'):
env.Append(LIBS = ['windowsstubs', 'ws2_32', 'Iphlpapi'])

# Build individual utils
vif_sources = ['vif.c']
vif = env.Program(target = 'vif', source = vif_sources)
Expand All @@ -45,9 +57,6 @@ rt = env.Program(target = 'rt', source = rt_sources)
nh_sources = ['nh.c']
nh = env.Program(target = 'nh', source = nh_sources)

mirror_sources = ['mirror.c']
mirror = env.Program(target = 'mirror', source = mirror_sources)

mpls_sources = ['mpls.c']
mpls = env.Program(target = 'mpls', source = mpls_sources)

Expand All @@ -66,18 +75,34 @@ vxlan = env.Program(target = 'vxlan', source = vxlan_sources)
vrouter_sources = ['vrouter.c']
vrouter = env.Program(target = 'vrouter', source = vrouter_sources)

vrmemstats_sources = ['vrmemstats.c']
vrmemstats = env.Program(target = 'vrmemstats', source = vrmemstats_sources)
# to make sure that all are built when you do 'scons' @ the top level
binaries = [vif, rt, nh, mpls, flow, vrfstats, dropstats, vxlan,
vrouter]

if not sys.platform.startswith('win'):
# 'mirror', 'vrmemstats', 'qosmap' utilities are not yet ported for Windows
mirror_sources = ['mirror.c']
mirror = env.Program(target = 'mirror', source = mirror_sources)

qosmap_sources = ['qosmap.c']
qosmap = env.Program(target = 'qosmap', source = qosmap_sources)
vrmemstats_sources = ['vrmemstats.c']
vrmemstats = env.Program(target = 'vrmemstats', source = vrmemstats_sources)

# to make sure that all are built when you do 'scons' @ the top level
binaries = [vif, rt, nh, mirror, mpls, flow, vrfstats, dropstats,
vxlan, vrouter, vrmemstats, qosmap]
qosmap_sources = ['qosmap.c']
qosmap = env.Program(target = 'qosmap', source = qosmap_sources)

binaries.append([mirror, vrmemstats, qosmap])

scripts = ['vifdump']
env.Default(binaries)

if sys.platform.startswith('win'):
# Use WiX for MSI generation
utils_msi = env.WiX('utils.msi', ['windows/utils_msi.wxs'])

Import('vtest')
env.Depends(utils_msi, binaries + vtest)
env.Default(utils_msi)

env.Alias('install', env.Install(env['INSTALL_BIN'], binaries + scripts))
# Local Variables:
# mode: python
Expand Down

0 comments on commit 30f7c26

Please sign in to comment.