Skip to content

Commit

Permalink
Squashed 'externals/nitro/' changes from 2516908..8e598b2
Browse files Browse the repository at this point in the history
8e598b2 Merge pull request #152 from mdaus/sync_externals
db2bd21 Replace header
8c23930 Merge commit '5049aeb61891a8297c756b27841e2f227fe961f7' into sync_externals
5049aeb Squashed 'externals/coda-oss/' changes from 0efc30c..d5dafc3
6903461 Merge pull request #151 from mdaus/sync_externals
91e7d1a Squashed 'externals/coda-oss/' changes from 4995c9e..0efc30c
7360c64 Merge commit '91e7d1ae2034a182b88c3700fe83a1e4e6cf1f7d' into sync_externals
abe6ee5 Merge pull request #150 from mdaus/remove_test_warnings
c7d92fa Remove warnings
64fa972 Merge pull request #149 from mdaus/shared_build_fix
e8abef5 Merge pull request #148 from mdaus/sync_externals
8575413 Build CGM
f266587 Cleanup
d248ef3 Add VS dirs to gitignore
75022cb Cleanup
a6f5d69 Cleanup
d30fb8a Fix indentation
346236c Merge commit '24048fe232bca15801857cf5a2de1f703155cf77' into sync_externals
24048fe Squashed 'externals/coda-oss/' changes from eee482d..4995c9e
8e05b64 Add jpeg shared library
7c87020 Build DLL for j2k
ff1462a Merge pull request #147 from mdaus/sync_externals
373cbaf Squashed 'externals/coda-oss/' changes from 7e0a53e..eee482d
218e877 Merge commit '373cbaf9b839f6d7c1bcda12c299bfbbf8e400c0' into sync_externals
a863cf0 Merge pull request #146 from mdaus/fix_multiband_nitfs
09da561 Clean up tests
bee1c81 Fix copy/paste bug; add test for 16bpp data
04afc7d Merge pull request #145 from mdaus/fix_multiband_nitfs
de2a8b2 Strip trailing whitespace
e4d655e Cleanup
1f646f6 Enforce band order
c9d7b87 Old C limitations
ffdf6ed More failing test cases
7d38397 Make fewer assumptions about bandlist order
bbaadc5 Finish fixing Multiband P read
d19069f Quick workaround for testing
cb7091e Fix test; add failing test for buggy case
614c607 Fix formatting and tests
eab11fa Merge branch 'fix_multiband_nitfs' of https://github.com/mdaus/nitro into fix_multiband_nitfs
263824f Draft failing test and regression test
c4f861d Misc cleanups
69aab7b Merge pull request #143 from mdaus/fix_multiband_nitfs
9eff3a1 Regenerate Python bindings; rename test with name conflict
5382800 Disallow direct block write for multiband images
bbd316f Handle unexpected block size
4d15605 Merge pull request #142 from mdaus/sync_externals
b9fb90d Squashed 'externals/coda-oss/' changes from dbabd95d..7e0a53e4
253b036 Merge commit 'b9fb90dcae51d25cd6cb0b3ec7f9cf514d09da8f' into sync_externals
a9a86b1 Merge pull request #138 from mdaus/sync_externals
18fc2b8 Squashed 'externals/coda-oss/' changes from 163168f..dbabd95
50a541f Merge commit '18fc2b8147553d0fbf899faa79739242132bde4d' into sync_externals

git-subtree-dir: externals/nitro
git-subtree-split: 8e598b2
  • Loading branch information
JonathanMeans committed Oct 16, 2019
1 parent 255f509 commit af94235
Show file tree
Hide file tree
Showing 88 changed files with 3,652 additions and 1,215 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

# Build artifacts
target/
*.pyc
*.swp
.depproj
.vs

# Drivers
modules/c/j2k/external/openjpeg/openjpeg-2.0.0/
modules/c/j2k/external/jasper/jasper-1.900.1-mod/

1 change: 1 addition & 0 deletions externals/coda-oss/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Build artifacts

install/
target/

# Waf
Expand Down
115 changes: 49 additions & 66 deletions externals/coda-oss/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,21 @@ def module(self, **modArgs):
lang=lang, path=testNode, includes=includes, defines=defines,
install_path='${PREFIX}/tests/%s' % modArgs['name'])

pythonTestNode = path.parent.parent.make_node('python').make_node(str(path)).make_node('tests')
if os.path.exists(pythonTestNode.abspath()) and not Options.options.libs_only:
tests = [str(test) for test in pythonTestNode.ant_glob('*.py') if
str(test) not in listify(modArgs.get('test_filter', ''))]
for test in tests:
bld(features='install_tgt',
files=[test], dir=pythonTestNode,
name=test, target=test,
install_path='${PREFIX}/tests/%s' % modArgs['name'])

# Create install target for python tests
if not Options.options.libs_only:
for testDirname in ['tests', 'unittests']:
pythonTestNode = path.parent.parent.make_node('python').\
make_node(str(path)).make_node(testDirname)
if os.path.exists(pythonTestNode.abspath()):
tests = [str(test) for test in pythonTestNode.ant_glob('*.py') if
str(test) not in listify(modArgs.get('test_filter', ''))]
for test in tests:
installPath = '${PREFIX}/%s/%s' % (testDirname, modArgs['name'])
bld(features='install_tgt',
files=[test], dir=pythonTestNode,
name=test, target=test,
install_path=installPath)


testNode = path.make_node('unittests')
Expand All @@ -305,24 +311,14 @@ def module(self, **modArgs):
for test in testNode.ant_glob('*%s' % sourceExtensions):
if str(test) not in listify(modArgs.get('unittest_filter', '')):
testName = splitext(str(test))[0]
exe = self(features='%s %sprogram' % (libExeType, libExeType),
exe = self(features='%s %sprogram test' % (libExeType, libExeType),
env=env.derive(), name=testName, target=testName, source=str(test), use=test_deps,
uselib = modArgs.get('unittest_uselib', modArgs.get('uselib', '')),
lang=lang, path=testNode, defines=defines,
includes=includes,
install_path='${PREFIX}/unittests/%s' % modArgs['name'])
if Options.options.unittests or Options.options.all_tests:
exe.features += ' test'

tests.append(testName)

# add a post-build hook to run the unit tests
# I use partial so I can pass arguments to a post build hook
#if Options.options.unittests:
# bld.add_post_fun(partial(CPPBuildContext.runUnitTests,
# tests=tests,
# path=self.getBuildDir(testNode)))

confDir = path.make_node('conf')
if exists(confDir.abspath()):
lib.targets_to_add.append(
Expand All @@ -339,7 +335,7 @@ def plugin(self, **modArgs):
plugin (via the plugin kwarg).
"""
bld = self
env = self._getEnv(modArgs)
env = self._getEnv(modArgs).derive()

modArgs = dict((k.lower(), v) for k, v in list(modArgs.items()))
lang = modArgs.get('lang', 'c++')
Expand Down Expand Up @@ -370,7 +366,7 @@ def plugin(self, **modArgs):
lib = bld(features='%s %sshlib add_targets no_implib' % (libExeType, libExeType),
target=libName, name=targetName, source=source,
includes=includes, export_includes=exportIncludes,
use=uselib_local, uselib=uselib, env=env.derive(),
use=uselib_local, uselib=uselib, env=env,
defines=defines, path=path, targets_to_add=targetsToAdd,
install_path=join(env['install_sharedir'], plugin, 'plugins'))

Expand Down Expand Up @@ -545,7 +541,7 @@ def swigModule(self, **modArgs):
# actually check it in so other developers can still use the Python
# bindings even if they don't have Swig
flags = '-python -c++'
if sys.version_info[0] >= 3:
if sys.version_info[0] >= 3 and not env['PYTHON_AGNOSTIC']:
flags += ' -py3'
bld(features = 'cxx cshlib pyext add_targets swig_linkage includes',
source = swigSource,
Expand Down Expand Up @@ -643,7 +639,7 @@ def next(self):
except IndexError:
# pop next directory from stack
if len(self.stack) == 0:
raise StopIteration
return
self.directory = self.stack.pop()
if isdir(self.directory):
self.files = os.listdir(self.directory)
Expand Down Expand Up @@ -724,6 +720,11 @@ def unzipper(inFile, outDir):
outFile.flush()
outFile.close()


def deprecated_callback(option, opt, value, parser):
Logs.warn('Warning: {0} is deprecated'.format(opt))


def options(opt):
opt.load('compiler_cc')
opt.load('compiler_cxx')
Expand All @@ -747,8 +748,7 @@ def options(opt):
default=False, help='Treat compiler warnings as errors')
opt.add_option('--enable-debugging', action='store_true', dest='debugging',
help='Enable debugging')
opt.add_option('--enable-cpp11', action='store_true', default=False, dest='enablecpp11',
help='Enable C++11 features')
opt.add_option('--enable-cpp11', action='callback', callback=deprecated_callback)
#TODO - get rid of enable64 - it's useless now
opt.add_option('--enable-64bit', action='store_true', dest='enable64',
help='Enable 64bit builds')
Expand All @@ -772,8 +772,6 @@ def options(opt):
help='Build all libs as shared libs')
opt.add_option('--disable-symlinks', action='store_false', dest='symlinks',
default=True, help='Disable creating symlinks for libs')
opt.add_option('--unittests', action='store_true', dest='unittests',
help='Build-time option to run unit tests after the build has completed')
opt.add_option('--no-headers', action='store_false', dest='install_headers',
default=True, help='Don\'t install module headers')
opt.add_option('--no-libs', action='store_false', dest='install_libs',
Expand Down Expand Up @@ -884,12 +882,7 @@ def configureCompilerOptions(self):
config['cxx']['optz_fast'] = '-O2'
config['cxx']['optz_fastest'] = '-O3'

gxxCompileFlags='-fPIC'
if self.env['cpp11support'] and \
((cxxCompiler == 'g++' and gccHasCpp11()) or \
(cxxCompiler == 'icpc' and iccHasCpp11())):
gxxCompileFlags+=' -std=c++11'

gxxCompileFlags='-fPIC -std=c++11'
self.env.append_value('CXXFLAGS', gxxCompileFlags.split())

# DEFINES and LINKFLAGS will apply to both gcc and g++
Expand Down Expand Up @@ -1193,6 +1186,9 @@ def configure(self):
if self.env['DETECTED_BUILD_PY']:
return

if sys.version_info < (2, 7, 0):
self.fatal('build.py requires at least Python 2.7')

sys_platform = getPlatform(default=Options.platform)
winRegex = r'win32'

Expand Down Expand Up @@ -1281,14 +1277,17 @@ def configure(self):
env.append_unique('LINKFLAGS', Options.options.linkflags.split())
if Options.options._defs:
env.append_unique('DEFINES', Options.options._defs.split(','))
#if its already defined in a wscript, don't touch.
if not env['cpp11support']:
env['cpp11support'] = Options.options.enablecpp11
env['cpp11support'] = True
configureCompilerOptions(self)

env['PLATFORM'] = sys_platform

env['LIB_TYPE'] = Options.options.shared_libs and 'shlib' or 'stlib'
env['declspec_decoration'] = ''
env['windows_dll'] = False
if Options.options.shared_libs and env['COMPILER_CXX'] == 'msvc':
env['declspec_decoration'] = '__declspec(dllexport)'
env['windows_dll'] = True

env['install_headers'] = Options.options.install_headers
env['install_libs'] = Options.options.install_libs
Expand Down Expand Up @@ -1439,7 +1438,6 @@ def process_swig_linkage(tsk):
tsk.env.LIB = newlib



#
# This task generator creates tasks that install an __init__.py
# for our python packages. Right now all it does it create an
Expand Down Expand Up @@ -1711,33 +1709,6 @@ def getSolarisFlags(compilerName):

return (bitFlag32, bitFlag64)

def gccHasCpp11():
try:
output = subprocess.check_output("g++ --help=c++",
stderr=subprocess.STDOUT,
shell=True,
universal_newlines=True)
except subprocess.CalledProcessError:
# If gcc is too old for --help=, then it is too old for C++11
return False
for line in output.split('\n'):
if re.search(r'-std=c\+\+11', line):
return True
return False

def iccHasCpp11():
try:
output = subprocess.check_output("icpc -help",
stderr=subprocess.STDOUT,
shell=True,
universal_newlines=True)
except subprocess.CalledProcessError:
# If icc is too old for -help, then it is too old for C++11
return False
for line in output.split('\n'):
if re.search(r'c\+\+11', line):
return True
return False

def getWscriptTargets(bld, env, path):
# Here we're taking a look at the current stack and adding on all the
Expand Down Expand Up @@ -1802,6 +1773,19 @@ def addSourceTargets(bld, env, path, target):

target.targets_to_add += wscriptTargets

def enableWafUnitTests(bld, set_exit_code=True):
"""
If called, run all C++ unit tests after building
:param set_exit_code Flag to set a non-zero exit code if a unit test fails
"""
# TODO: This does not work for Python files.
# The "nice" way to handle this is possibly not
# supported in this version of Waf.
bld.add_post_fun(waf_unit_test.summary)
if set_exit_code:
bld.add_post_fun(waf_unit_test.set_exit_code)


class SwitchContext(Context.Context):
"""
Easily switch output directories without reconfiguration.
Expand Down Expand Up @@ -1876,4 +1860,3 @@ class CPPPackageContext(package, CPPContext):
def __init__(self, **kw):
self.waf_command = 'python waf'
super(CPPPackageContext, self).__init__(**kw)

2 changes: 1 addition & 1 deletion externals/coda-oss/build/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def collect_source(self):
for x in include_dirs:
if isinstance(x, str):
x = tg.path.find_node(x)
if x:
if x and os.path.isdir(x.abspath()):
lst = [y for y in x.ant_glob(HEADERS_GLOB, flat=False)]
include_files.extend(lst)

Expand Down
10 changes: 9 additions & 1 deletion externals/coda-oss/build/swig.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,16 @@ def options(opt):
opt.add_option('--disable-swig', action='store_false', dest='swig',
help='Disable swig')
opt.add_option('--swig-version', action='store', dest='swigver',
default=None, help='Specify the minimum swig version')
default='3.0.0', help='Specify the minimum swig version')
opt.add_option('--require-swig', action='store_true', dest='require_swig',
help='Require swig (configure option)', default=False)
opt.add_option('--python-version-agnostic', action='store_true',
dest='pyver_agnostic',
help='The default behavior for generated Python code is to '
'enable Python 3-specific features if the detected Python '
'is version 3. Pass this flag to force the generated code '
'to work with either version of Python in all cases.')


def configure(conf):
if Options.options.swig:
Expand All @@ -209,3 +216,4 @@ def configure(conf):
conf.check_swig_version(minver=swigver)
conf.env.SWIGPATH_ST = '-I%s'
conf.env.SWIGDEFINES_ST = '-D%s'
conf.env['PYTHON_AGNOSTIC'] = Options.options.pyver_agnostic
Binary file modified externals/coda-oss/build/waf
Binary file not shown.
9 changes: 9 additions & 0 deletions externals/coda-oss/modules/c++/config/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This module represents the "configure" step for the entire C++ set of libraries.
It exists independently to ensure it can always build first with no
circular dependencies. Its sole responsibility is to generate "coda_oss_config.h"

Key defines in "coda_oss_config.h":
- CODA_EXPORT: Expands to __declspec(dllexport) when building
shared libraries on Windows

- __CODA_CPP11: Defined if the library is compiled with C++11 support
88 changes: 88 additions & 0 deletions externals/coda-oss/modules/c++/config/wscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
NAME = 'config'
MAINTAINER = '[email protected]'
VERSION = '1.2'
USELIB = 'THREAD DL RT SOCKET'

import os
from build import writeConfig
from waflib import Utils

options = distclean = lambda p: None

def configure(conf):
# this check defines HAVE_CLOCK_GETTIME, undefine it to keep it out of dumpenv
if conf.check_cc(lib='rt', uselib_store='RT', function_name='clock_gettime', header_name='time.h', mandatory=False):
conf.undefine('HAVE_CLOCK_GETTIME')

# callback function to check for all #defines used by the sys module
def sys_callback(conf):
conf.check_cc(header_name='pthread.h', mandatory=False)
conf.check_cc(header_name='execinfo.h', mandatory=False)
conf.check_cc(function_name='clock_gettime', header_name='time.h', mandatory=False)
conf.check_cc(header_name="atomic.h", mandatory=False)
conf.check_cc(header_name="sys/time.h", mandatory=False)
conf.check_cc(function_name='localtime_r', header_name="time.h", mandatory=False)
conf.check_cc(function_name='gmtime_r', header_name="time.h", mandatory=False)
conf.check_cc(function_name='setenv', header_name="stdlib.h", mandatory=False)
conf.check_cc(function_name='posix_memalign', header_name="stdlib.h", mandatory=False)
conf.check_cc(function_name='memalign', header_name="stdlib.h", mandatory=False)
types_str = '''
#include <stdio.h>
int isBigEndian()
{
long one = 1;
return !(*((char *)(&one)));
}
int main()
{
if (isBigEndian()) printf("bigendian=True\\n");
else printf("bigendian=False\\n");
printf("sizeof_size_t=%d\\n", sizeof(size_t));
return 0;
}
'''

# Visual Studio 2013 has nullptr but not constexpr. Need to check for
# both in here to make sure we have full C++11 support... otherwise,
# long-term we may need multiple separate configure checks and
# corresponding defines
cpp11_str = '''
int main()
{
constexpr void* FOO = nullptr;
}
'''
#find out the size of some types, etc.
# TODO: This is not using the 32 vs. 64 bit linker flags, so if you're
# building with --enable-32bit on 64 bit Linux, sizeof(size_t) will
# erroneously be 8 here.
output = conf.check(fragment=types_str, execute=1, msg='Checking system type sizes', define_ret=True)
t = Utils.str_to_dict(output or '')
for k, v in t.items():
try:
v = int(v)
except:
v = v.strip()
if v == 'True':
v = True
elif v == 'False':
v = False
conf.define(k.upper(), v)
conf.check_cxx(fragment=cpp11_str,
execute=1,
msg='Checking for C++11 support',
define_name='__CODA_CPP11',
mandatory=True)
conf.define('CODA_EXPORT', conf.env['declspec_decoration'], quote=False)

writeConfig(conf, sys_callback, 'coda_oss',
path=os.path.join('include', 'config'),
outfile='coda_oss_config.h')


def build(bld):
includeDirname = os.path.join(bld.env['install_includedir'], 'config')
configPathname = bld.path.get_bld().ant_glob('**/coda_oss_config.h')
bld.install_files(dest=includeDirname,
files=configPathname)
bld.module(**globals())
Loading

0 comments on commit af94235

Please sign in to comment.