Skip to content

Commit

Permalink
Merge pull request #142 from mdaus/sync_externals
Browse files Browse the repository at this point in the history
Sync externals
  • Loading branch information
clydestanfield authored Sep 24, 2019
2 parents a9a86b1 + 253b036 commit 4d15605
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 13 deletions.
31 changes: 20 additions & 11 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 Down Expand Up @@ -545,7 +551,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 +649,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 @@ -1193,6 +1199,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
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
22 changes: 22 additions & 0 deletions externals/coda-oss/modules/c++/types/include/types/Range.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ struct Range
}
}

/*!
* Determine if a given range touches our range. Touching ranges do not
* overlap, but can be placed next to one another (irrespective of order)
* with no missing values in between.
*
* If either of the ranges is empty, touching is defined as always false.
*
* \param rhs Range to compare with
*
* \return True if the ranges touch, false otherwise
*/
bool touches(const types::Range& rhs) const
{
if (empty() || rhs.empty())
{
return false;
}

return (mStartElement == rhs.endElement()) ||
(rhs.mStartElement == endElement());
}

/*!
* \param startElementToTest The start element
* \param numElementsToTest The total number of elements to check
Expand Down
44 changes: 44 additions & 0 deletions externals/coda-oss/modules/c++/types/unittests/test_range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,54 @@ TEST_CASE(TestGetNumSharedElements)
// Ranges are the same - should share [100, 150)
TEST_ASSERT_EQ(range.getNumSharedElements(100, 50), 50);
}

TEST_CASE(TestTouches)
{
// Ranges do not overlap or touch -- touches(...) returns false
{
const types::Range A(5, 4); // [5, 8]
const types::Range B(12, 1); // [12, 12]
TEST_ASSERT_FALSE(A.touches(B));
TEST_ASSERT_FALSE(B.touches(A));
}

// Ranges overlap -- touches(...) returns false
{
const types::Range A(5, 4); // [5, 8]
const types::Range B(8, 1); // [8, 8]
TEST_ASSERT_FALSE(A.touches(B));
TEST_ASSERT_FALSE(B.touches(A));
}

// Ranges touch -- touches(...) returns true
{
const types::Range A(5, 4); // [5, 8]
const types::Range B(9, 1); // [9, 9]
TEST_ASSERT_TRUE(A.touches(B));
TEST_ASSERT_TRUE(B.touches(A));
}

// One of the ranges is empty -- touches(...) returns false
{
const types::Range A(10, 0); // [10, 0)
const types::Range B(10, 10); // [10, 20)
TEST_ASSERT_FALSE(A.touches(B));
TEST_ASSERT_FALSE(B.touches(A));
}

// Both of the ranges are empty -- touches(...) returns false
{
const types::Range A(10, 0); // [10, 0)
const types::Range B(10, 0); // [10, 20)
TEST_ASSERT_FALSE(A.touches(B));
TEST_ASSERT_FALSE(B.touches(A));
}
}
}

int main(int /*argc*/, char** /*argv*/)
{
TEST_CHECK(TestGetNumSharedElements);
TEST_CHECK(TestTouches);
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def runUnitTests(projectName, installDirName='install'):
for test in os.listdir(os.path.join(unitTestDir, childDir)):
testPathname = os.path.join(unitTestDir, childDir, test)
print(testPathname)
if call([executableName(testPathname)]) != 0:
if testPathname.endswith('.py'):
command = ['python', testPathname]
else:
command = [executableName(testPathname)]
if call(command) != 0:
success = False

return success
1 change: 1 addition & 0 deletions externals/coda-oss/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def options(opt):
opt.recurse(DIRS)

def configure(conf):
conf.options.swigver = '3.0.12'
conf.load(TOOLS, tooldir='./build/')
conf.recurse(DIRS)

Expand Down

0 comments on commit 4d15605

Please sign in to comment.