wscript improvements

pull/9/head
bebopagogo 2020-02-29 23:17:23 -05:00
parent 7b4e85bfe8
commit 417f10367b
2 changed files with 37 additions and 39 deletions

@ -1 +1 @@
Subproject commit d130d1a990e853a783bfdf694e8c91862802e9d6 Subproject commit e8478fe08f301f7b02e4c10422f584c6144c2e9a

70
wscript
View File

@ -75,7 +75,12 @@ def build(ctx):
# Setup to install NORM header file # Setup to install NORM header file
ctx.install_files("${PREFIX}/include/", "include/normApi.h") ctx.install_files("${PREFIX}/include/", "include/normApi.h")
normSrc = ['src/common/{0}.cpp'.format(x) for x in [ ctx.objects(
target = 'normObjs',
includes = ['include', 'protolib/include'],
export_includes = ['include'],
use = ctx.env.USE_BUILD_NORM + ctx.env.USE_BUILD_PROTOLIB,
source = ['src/common/{0}.cpp'.format(x) for x in [
'galois', 'galois',
'normApi', 'normApi',
'normEncoder', 'normEncoder',
@ -88,22 +93,19 @@ def build(ctx):
'normObject', 'normObject',
'normSegment', 'normSegment',
'normSession', 'normSession',
]] ]],
)
# Use static lib for Unix examples for convenience # Protolib is incorporated into static and dynmamic NORM libs
# (so we don't have to worry about LD_LIBRARY_PATH)
ctx.shlib( ctx.shlib(
target = 'norm', target = 'norm',
name = 'norm_shlib', name = 'norm_shlib',
includes = ['include'], includes = ['include'],
export_includes = ['include'], export_includes = ['include'],
use = ctx.env.USE_BUILD_NORM + ['protolib_st'], use = ['protoObjs', 'normObjs'],
#stlib = ['protokit'],
defines = ['NORM_USE_DLL'] if 'windows' == system else [], defines = ['NORM_USE_DLL'] if 'windows' == system else [],
# Hack so clang links to libprotokit.a static library instead of dynamic
linkflags = ['protolib/libprotokit.a'] if ctx.env.COMPILER_CXX == 'clang++' else [],
vnum = VERSION, vnum = VERSION,
source = normSrc, source = [],
features = 'cxx cxxshlib', features = 'cxx cxxshlib',
install_path = '${LIBDIR}', install_path = '${LIBDIR}',
) )
@ -113,9 +115,9 @@ def build(ctx):
name = 'norm_stlib', name = 'norm_stlib',
includes = ['include'], includes = ['include'],
export_includes = ['include'], export_includes = ['include'],
use = ctx.env.USE_BUILD_NORM + ['protolib_st'], use = ['protoObjs', 'normObjs'],
vnum = VERSION, vnum = VERSION,
source = normSrc, source = [],
features = 'cxx cxxstlib', features = 'cxx cxxstlib',
install_path = '${LIBDIR}', install_path = '${LIBDIR}',
) )
@ -132,8 +134,7 @@ def build(ctx):
ctx.shlib( ctx.shlib(
target = 'mil_navy_nrl_norm', target = 'mil_navy_nrl_norm',
includes = ['include'], includes = ['include'],
use = ['norm_shlib', 'protolib_st', 'JAVA'], use = ['norm_shlib', 'JAVA'],
stlib = ['protokit'],
vnum = VERSION, vnum = VERSION,
defines = ['NORM_USE_DLL'] if 'windows' == system else [], defines = ['NORM_USE_DLL'] if 'windows' == system else [],
source = ['src/java/jni/{0}.cpp'.format(x) for x in [ source = ['src/java/jni/{0}.cpp'.format(x) for x in [
@ -157,13 +158,20 @@ def build(ctx):
) )
# Links to static library since it uses C++ objects directly instead of API # Links to static library since it uses C++ objects directly instead of API
# Hack to force clang to statically link stuff
if 'clang++' == ctx.env.COMPILER_CXX:
use = ['protoObjs', 'normObjs']
else:
use = ['norm.stlib']
normapp = ctx.program( normapp = ctx.program(
# Need to explicitly set a different name, because # Need to explicitly set a different name, because
# the library is also named "norm" # the library is also named "norm"
name = 'normapp', name = 'normapp',
target = 'normapp', target = 'normapp',
#includes = ['include'], includes = ['include', 'protolib/include'],
use = ['protolib_st', 'norm_stlib'], use = use,
defines = [], defines = [],
source = ['src/common/{0}.cpp'.format(x) for x in [ source = ['src/common/{0}.cpp'.format(x) for x in [
'normPostProcess', 'normPostProcess',
@ -173,10 +181,6 @@ def build(ctx):
posted = True, posted = True,
) )
# Hack to force clang to link static libnorm.a
if ctx.env.COMPILER_CXX == 'clang++':
normapp.linkflags ='libnorm.a'
if system in ('linux', 'darwin', 'freebsd', 'gnu', 'gnu/kfreebsd'): if system in ('linux', 'darwin', 'freebsd', 'gnu', 'gnu/kfreebsd'):
normapp.source.append('src/unix/unixPostProcess.cpp') normapp.source.append('src/unix/unixPostProcess.cpp')
@ -217,45 +221,39 @@ def build(ctx):
# Generate pkg-config file # Generate pkg-config file
# Add additional static compilation dependencies based on the system. # Add additional static compilation dependencies based on the system.
# libpcap is used by protolib on GNU/Hurd based systems. # libpcap is used by protolib on GNU/Hurd based systems.
'''
static_libs = '' static_libs = ''
if ctx.options.enable_static_library: if ctx.options.enable_static_library:
static_libs += ' -lstdc++ -lprotokit' static_libs += ' -lstdc++ -lprotokit'
if system == "gnu": if system == "gnu":
static_libs += ' -lpcap' static_libs += ' -lpcap'
ctx(source='norm.pc.in', STATIC_LIBS = static_libs) ctx(source='norm.pc.in', STATIC_LIBS = static_libs)
'''
def _make_simple_example(ctx, name, path='examples'): def _make_simple_example(ctx, name, path='examples'):
'''Makes a task from a single source file in the examples directory. '''Makes a task from a single source file in the examples directory.
Note these tasks are not built by default.
Note these tasks are not built by default. Use the --targets flag. Use the waf build --targets flag.
''' '''
source = ['{0}/{1}.cpp'.format(path, name)]
# Hack to force clang to statically link stuff
if 'clang++' == ctx.env.COMPILER_CXX:
use = ['protoObjs', 'normObjs']
else:
use = ['norm.stlib']
if 'normClient' == name or 'normServer' == name: if 'normClient' == name or 'normServer' == name:
source.append('%s/normSocket.cpp' % path) source.append('%s/normSocket.cpp' % path)
example = ctx.program( example = ctx.program(
target = name, target = name,
includes = ['include', 'protolib/include'], includes = ['include', 'protolib/include'],
use = ['protolib_st'], use = use,
defines = [], defines = [],
source = source, source = ['{0}/{1}.cpp'.format(path, name)],
# Don't build examples by default # Don't build examples by default
posted = True, posted = True,
# Don't install examples # Don't install examples
install_path = False, install_path = False,
) )
# TBD - figure out how build NORM DLL and stil
# enable Windows examples to link against static lib
if 'windows' == system: if 'windows' == system:
example.use.append('norm_stlib')
example.defines.append('_CONSOLE') example.defines.append('_CONSOLE')
else:
example.use.append('norm_stlib')
# Hack to force clang to link static libnorm.a
if ctx.env.COMPILER_CXX == 'clang++':
example.linkflags ='libnorm.a'