Skip to content

Commit

Permalink
Squashed 'externals/coda-oss/' changes from df07c512d..26de66952
Browse files Browse the repository at this point in the history
26de66952 Merge branch 'main' into cpp17
605d24898 duplicate existing HDF5 unittests using HighFive (#657)
134233279 add 'override'; fix ASAN-detected memory leaks (#656)

git-subtree-dir: externals/coda-oss
git-subtree-split: 26de66952d92ee80c1e76232dc9819d062454109
  • Loading branch information
Dan Smith authored and Dan Smith committed Feb 27, 2023
1 parent a623088 commit 3185aa7
Show file tree
Hide file tree
Showing 58 changed files with 630 additions and 127 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,18 @@ if (${CMAKE_PROJECT_NAME} STREQUAL coda-oss)
if (MSVC)
add_compile_options(/WX) # warnings as errors
add_compile_options(/MP) # multi-processor compile

if (ENABLE_ASAN)
# https://docs.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-160
add_compile_options(/fsanitize=address)
endif()
elseif (UNIX)
add_compile_options(-Werror) # warnings as errors
if (ENABLE_ASAN)
# https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down
11 changes: 9 additions & 2 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@
```
# coda-oss Release Notes

## [Release 2023-??-??](https://github.com/mdaus/coda-oss/releases/tag/2023-??-??)
* *zlib* updated to [1.2.13](https://github.com/madler/zlib/releases/tag/v1.2.13).
* new `mem::ComplexView` class to make it easier to process complex data stored in parallel.
* adjust compiler flags for clean *CMake* builds.
* wrap common "file open" routines (e.g., `fopen()`) to support `sys::expandEnvironmentVariables()`.
* add header-only [HighFive](https://github.com/BlueBrain/HighFive) HDF5-wrapper library.

## [Release 2022-12-14](https://github.com/mdaus/coda-oss/releases/tag/2022-12-14)
* removed remaining vestigates of `std::auto_ptr`, provide `mem::AutoPtr` for the tiny handful of
* removed remaining vestiges of `std::auto_ptr`, provide `mem::AutoPtr` for the tiny handful of
places (e.g., SWIG bindings) that still need copying.
* `xml::lite::Element` overloads to make creting new XML documents easier; see unittests for examples.
* try even harder to find unittest files in various scenarios.
Expand All @@ -30,7 +37,7 @@
* Utilitiy routines for finding various files when unit-testing.
* Removed C++14 work-arounds needed in C++11. Legacy C++ exception specificatons removed.
* Rebuild `waf` for FIPS error; added more debug options.

## [Release 2022-08-30](https://github.com/mdaus/coda-oss/releases/tag/2022-08-30)
* XML is now always written as UTF-8; the code will still try to read Windows-1252.
* `Uri`s are no longer validated by default.
Expand Down
2 changes: 2 additions & 0 deletions UnitTest/UnitTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
Expand All @@ -33,6 +34,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ elseif (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wzero-as-null-pointer-constant")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-final-types -Wsuggest-final-methods")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-final-types -Wsuggest-final-methods")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
endif()

# add an interface library for unittests
Expand Down
8 changes: 4 additions & 4 deletions modules/c++/cli/unittests/test_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ TEST_CASE(testRequired)
parser.addArgument("-v --verbose", "Toggle verbose", cli::STORE_TRUE);
parser.addArgument("-c --config", "Specify a config file", cli::STORE)->setRequired(true);

std::unique_ptr<cli::Results> results;
TEST_EXCEPTION(results.reset(parser.parse(str::split(""))));
TEST_EXCEPTION(results.reset(parser.parse(str::split("-c"))));
results.reset(parser.parse(str::split("-c configFile")));
const std::string program(testName);
TEST_EXCEPTION(parser.parse(program, str::split("")));
TEST_EXCEPTION(parser.parse(program, str::split("-c")));
const auto results = parser.parse(program, str::split("-c configFile"));
TEST_ASSERT_EQ(results->get<std::string>("config"), "configFile");
}

Expand Down
2 changes: 2 additions & 0 deletions modules/c++/coda-oss-lite.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,14 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
4 changes: 4 additions & 0 deletions modules/c++/except/source/Backtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ struct BacktraceHelper final
BacktraceHelper(char** stackSymbols)
: mStackSymbols(stackSymbols)
{}
BacktraceHelper(const BacktraceHelper&) = delete;
BacktraceHelper& operator=(const BacktraceHelper&) = delete;
BacktraceHelper(BacktraceHelper&&) = default;
BacktraceHelper& operator=(BacktraceHelper&&) = default;

~BacktraceHelper()
{
Expand Down
4 changes: 2 additions & 2 deletions modules/c++/hdf5.lite/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
set(MODULE_NAME hdf5.lite)

if(CODA_ENABLE_HDF5)
set(MODULE_DEPS except-c++ types-c++ io-c++ coda_oss-c++)
list(APPEND MODULE_DEPS hdf5-c++)
set(MODULE_DEPS highfive-c++ hdf5-c++)
list(APPEND MODULE_DEPS except-c++ types-c++ io-c++ coda_oss-c++)

coda_add_module(
${MODULE_NAME}
Expand Down
12 changes: 6 additions & 6 deletions modules/c++/hdf5.lite/include/hdf5/lite/Write.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#pragma once

/*!
* \file Read.h
* \brief HDF File-reading API
* \file Write.h
* \brief HDF File-writing API
*
* These are simple routines to write HDF5 files; they're loosely modeled after the MATLab API
* https://www.mathworks.com/help/matlab/ref/h5create.html
Expand All @@ -51,20 +51,20 @@ CODA_OSS_API void createFile(const coda_oss::filesystem::path&, const std::strin
CODA_OSS_API void createFile(const coda_oss::filesystem::path&, const std::string& ds, SpanRC<const double>);
inline void createFile(const coda_oss::filesystem::path& path, const std::string& ds, SpanRC<double> data_)
{
SpanRC<const double> data(data_.data(), data_.dims());
createFile(path, ds, data);
SpanRC<const double> data(data_.data(), data_.dims());
createFile(path, ds, data);
}
CODA_OSS_API void createFile(const coda_oss::filesystem::path&, const std::string& ds, SpanRC<const float>);
inline void createFile(const coda_oss::filesystem::path& path, const std::string& ds, SpanRC<float> data_)
{
SpanRC<const float> data(data_.data(), data_.dims());
createFile(path, ds, data);
createFile(path, ds, data);
}

CODA_OSS_API void writeFile(const coda_oss::filesystem::path&, const std::string& loc, SpanRC<const double>);
inline void writeFile(const coda_oss::filesystem::path& path, const std::string& ds, SpanRC<double> data_)
{
SpanRC<const double> data(data_.data(), data_.dims());
SpanRC<const double> data(data_.data(), data_.dims());
writeFile(path, ds, data);
}
CODA_OSS_API void writeFile(const coda_oss::filesystem::path&, const std::string& loc, SpanRC<const float>);
Expand Down
75 changes: 75 additions & 0 deletions modules/c++/hdf5.lite/include/hdf5/lite/highfive.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* =========================================================================
* This file is part of hdf5.lite-c++
* =========================================================================
*
* (C) Copyright 2022, Maxar Technologies, Inc.
*
* hdf5.lite-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/

#ifndef CODA_OSS_hdf5_lite_highfive_h_INCLUDED_
#define CODA_OSS_hdf5_lite_highfive_h_INCLUDED_
#pragma once

/*!
* \file highfive.h
* \brief Utility routines for using HighFive
*/

#include <string>

#include "highfive/H5Easy.hpp"
#include "highfive/H5DataSet.hpp"

#include "SpanRC.h"

namespace hdf5
{
namespace lite
{
template <typename T>
inline HighFive::DataSet writeDataSet(H5Easy::File& file, SpanRC<T> data, const std::string& dataset_name /*, TODO ...*/)
{
const std::vector<size_t> dims{data.dims().row, data.dims().col};
const HighFive::DataSpace dataspace{dims};
auto retval = file.createDataSet<T>(dataset_name, dataspace);
retval.write_raw(data.data());
return retval;
}

template <typename T>
inline SpanRC<T> readDataSet(HighFive::DataSet& dataSet, std::vector<T>& result /*, TODO ...*/)
{
const auto dimensions = dataSet.getSpace().getDimensions();
const types::RowCol<size_t> dims(dimensions[0], dimensions[1]);

result.resize(dims.area());
dataSet.read(result.data());

return SpanRC<T>(result.data(), dims);
}

template <typename T>
inline SpanRC<T> load(H5Easy::File& file, const std::string& dataset_name, std::vector<T>& result /*, TODO ...*/)
{
auto dataSet = file.getDataSet(dataset_name);
return readDataSet(dataSet, result);
}

}
}

#endif // CODA_OSS_hdf5_lite_highfive_h_INCLUDED_
2 changes: 1 addition & 1 deletion modules/c++/hdf5.lite/unittests/test_hdf5write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ TEST_CASE(test_hdf5Write)
for (size_t i = 0; i < result.size(); i++)
{
const auto expected = static_cast<double>(i);
TEST_ASSERT_ALMOST_EQ(result[i], expected);
TEST_ASSERT_EQ(result[i], expected);
}
}

Expand Down
Loading

0 comments on commit 3185aa7

Please sign in to comment.