Skip to content

Commit e77a6c6

Browse files
Squashed 'externals/coda-oss/' changes from 2352e4859..f4b0a7109 (#761)
f4b0a7109 Make fixed polys more user friendly (#788) 036b17d68 Add nlohmann json driver module and initial type impls (#787) 06aaa4d42 Parallel file reads through io::FileInputStreamOS (#784) 7aec15050 Changes the default value for 'install_pydir' (#781) 46a9764ae Restore ci to working order (#783) 3c5e1735e attempt allow build of pull requests (#782) 026e8dd77 Allow derived classes that offer additional functionality (such as locking) (#780) git-subtree-dir: externals/coda-oss git-subtree-split: f4b0a7109f0c1e23b4d7fda37dece809b0f438b2 Co-authored-by: Vaughn Holmes <vaughn.holmes@maxar.com>
1 parent 57dd311 commit e77a6c6

File tree

37 files changed

+26910
-73
lines changed

37 files changed

+26910
-73
lines changed

externals/coda-oss/.github/workflows/build_unittest.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: build_unittest
22

3-
on: [push]
3+
on:
4+
push:
5+
pull_request:
6+
branches:
7+
- main
8+
49

510
jobs:
611
build-cmake-windows:
@@ -11,6 +16,8 @@ jobs:
1116
name: ${{ matrix.os }}-${{ matrix.python-version }}-CMake
1217
runs-on: ${{ matrix.os }}
1318
steps:
19+
- name: Skip Duplicate Actions
20+
uses: fkirc/skip-duplicate-actions@v5.3.1
1421
- uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout
1522
- name: Set up Python
1623
uses: actions/setup-python@v5 # https://github.com/marketplace/actions/setup-python
@@ -63,6 +70,8 @@ jobs:
6370
runs-on: ${{ matrix.os }}
6471

6572
steps:
73+
- name: Skip Duplicate Actions
74+
uses: fkirc/skip-duplicate-actions@v5.3.1
6675
- uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout
6776
- name: configure
6877
run: |
@@ -93,11 +102,13 @@ jobs:
93102
build-linux-cmake-default:
94103
strategy:
95104
matrix:
96-
os: [ubuntu-latest]
105+
os: [ubuntu-22.04]
97106
python-version: ['3.7']
98107
name: ${{ matrix.os }}-${{ matrix.python-version }}-CMake
99108
runs-on: ${{ matrix.os }}
100109
steps:
110+
- name: Skip Duplicate Actions
111+
uses: fkirc/skip-duplicate-actions@v5.3.1
101112
- uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout
102113
- name: Set up Python
103114
uses: actions/setup-python@v5 # https://github.com/marketplace/actions/setup-python
@@ -130,12 +141,14 @@ jobs:
130141
build-linux-cmake:
131142
strategy:
132143
matrix:
133-
os: [ubuntu-latest]
144+
os: [ubuntu-22.04]
134145
configuration: [Debug, Release]
135146
avx: [AVX512F]
136147
name: ${{ matrix.os }}-${{ matrix.configuration }}-${{ matrix.avx }}-CMake
137148
runs-on: ${{ matrix.os }}
138149
steps:
150+
- name: Skip Duplicate Actions
151+
uses: fkirc/skip-duplicate-actions@v5.3.1
139152
- uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout
140153
- name: configure
141154
run: |
@@ -155,19 +168,21 @@ jobs:
155168
build-waf:
156169
strategy:
157170
matrix:
158-
os: [ubuntu-latest, windows-2019]
171+
os: [windows-2019, ubuntu-22.04]
159172
python-version: ['3.7']
160173
debugging: ['--enable-debugging', '']
161174
name: ${{ matrix.os }}-${{ matrix.python-version }}-waf${{ matrix.debugging }}
162175
runs-on: ${{ matrix.os }}
163176
steps:
177+
- name: Skip Duplicate Actions
178+
uses: fkirc/skip-duplicate-actions@v5.3.1
164179
- uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout
165180
- name: Set up Python
166181
uses: actions/setup-python@v5 # https://github.com/marketplace/actions/setup-python
167182
with:
168183
python-version: ${{ matrix.python-version }}
169184
- name: configure_with_swig
170-
if: ${{ matrix.os == 'ubuntu-latest' }}
185+
if: ${{ matrix.os == 'ubuntu-22.04' }}
171186
run: |
172187
pip install numpy
173188
mkdir install${{ matrix.os }}Waf-Github

externals/coda-oss/build/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ def configure(self):
12711271
env['install_libdir'] = Options.options.libdir if Options.options.libdir else join(Options.options.prefix, 'lib')
12721272
env['install_bindir'] = Options.options.bindir if Options.options.bindir else join(Options.options.prefix, 'bin')
12731273
env['install_sharedir'] = Options.options.sharedir if Options.options.sharedir else join(Options.options.prefix, 'share')
1274-
env['install_pydir'] = Options.options.pydir if Options.options.pydir else '${PYTHONDIR}'
1274+
env['install_pydir'] = Options.options.pydir if Options.options.pydir else join(Options.options.prefix, 'lib/python/site-packages')
12751275

12761276
# Swig memory leak output
12771277
if Options.options.swig_silent_leak:

externals/coda-oss/cmake/CodaBuild.cmake

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -314,25 +314,46 @@ function(coda_fetch_driver)
314314
message(FATAL_ERROR "received unexpected argument(s): ${ARG_UNPARSED_ARGUMENTS}")
315315
endif()
316316

317-
set(target_name ${CMAKE_PROJECT_NAME}_${ARG_NAME})
318-
# Use 'FetchContent' to download and unpack the files. Set it up here.
319-
FetchContent_Declare(${target_name}
320-
URL "${CMAKE_CURRENT_SOURCE_DIR}/${ARG_ARCHIVE}"
321-
URL_HASH ${ARG_HASH}
322-
)
323-
FetchContent_GetProperties(${target_name})
324-
# The returned properties use the lower-cased name
325-
string(TOLOWER ${target_name} target_name_lc)
326-
if (NOT ${target_name_lc}_POPULATED) # This makes sure we only fetch once.
327-
message("Populating content for external dependency ${driver_name}")
328-
# Now (at configure time) unpack the content.
329-
FetchContent_Populate(${target_name})
330-
# Remember where we put stuff
331-
set("${target_name_lc}_SOURCE_DIR" "${${target_name_lc}_SOURCE_DIR}"
332-
CACHE INTERNAL "source directory for ${target_name_lc}")
333-
set("${target_name_lc}_BINARY_DIR" "${${target_name_lc}_BINARY_DIR}"
334-
CACHE INTERNAL "binary directory for ${target_name_lc}")
335-
endif()
317+
# Use a new policy context so we can set some policy values that prevent
318+
# warning messages from printing
319+
cmake_policy(PUSH)
320+
if (POLICY CMP0135)
321+
# Newer cmake versions (>=3.24) change how the timestamps of
322+
# extracted files are set. The new behavior is fine but a warning
323+
# is printed if we do not either explicitly set the policy or set
324+
# the minimum cmake version.
325+
cmake_policy(SET CMP0135 NEW)
326+
endif()
327+
if (POLICY CMP0169)
328+
# Newer cmake versions (>=3.30) have deprecated
329+
# FetchContent_Populate and suggest using a different pattern.
330+
# The _Populate version calls add_directory() which we do not want,
331+
# so we cannot use it. Until we find a different solution, just
332+
# ignore this warning.
333+
cmake_policy(SET CMP0169 OLD)
334+
endif()
335+
336+
set(target_name ${CMAKE_PROJECT_NAME}_${ARG_NAME})
337+
# Use 'FetchContent' to download and unpack the files. Set it up here.
338+
FetchContent_Declare(${target_name}
339+
URL "${CMAKE_CURRENT_SOURCE_DIR}/${ARG_ARCHIVE}"
340+
URL_HASH ${ARG_HASH}
341+
)
342+
FetchContent_GetProperties(${target_name})
343+
# The returned properties use the lower-cased name
344+
string(TOLOWER ${target_name} target_name_lc)
345+
if (NOT ${target_name_lc}_POPULATED) # This makes sure we only fetch once.
346+
message("Populating content for external dependency ${driver_name}")
347+
# Now (at configure time) unpack the content.
348+
FetchContent_Populate(${target_name})
349+
# Remember where we put stuff
350+
set("${target_name_lc}_SOURCE_DIR" "${${target_name_lc}_SOURCE_DIR}"
351+
CACHE INTERNAL "source directory for ${target_name_lc}")
352+
set("${target_name_lc}_BINARY_DIR" "${${target_name_lc}_BINARY_DIR}"
353+
CACHE INTERNAL "binary directory for ${target_name_lc}")
354+
endif()
355+
cmake_policy(POP)
356+
336357
endfunction()
337358

338359

externals/coda-oss/modules/c++/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ add_subdirectory("hdf5.lite")
8080
add_subdirectory("gsl")
8181
add_subdirectory("std")
8282

83+
if(ENABLE_NLOHMANN)
84+
add_subdirectory("coda_oss.json")
85+
endif()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set(MODULE_NAME coda_oss.json)
2+
3+
coda_add_module(${MODULE_NAME}
4+
VERSION 1.0
5+
DEPS math.linear-c++ math.poly-c++ types-c++ mem-c++ nlohmann-c++)
6+
7+
coda_add_tests(
8+
MODULE_NAME ${MODULE_NAME}
9+
DIRECTORY "unittests"
10+
UNITTEST
11+
SOURCES
12+
test_json_math.cpp
13+
test_json_mem.cpp
14+
test_json_std.cpp
15+
test_json_types.cpp)
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/* =========================================================================
2+
* This file is part of coda-oss.json-c++
3+
* =========================================================================
4+
*
5+
* (C) Copyright 2025 ARKA Group, L.P. All rights reserved
6+
*
7+
* types-c++ is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as published by
9+
* the Free Software Foundation; either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this program; If not,
19+
* see <http://www.gnu.org/licenses/>.
20+
*/
21+
22+
#pragma once
23+
#ifndef CODA_OSS_json_math_h_INCLUDED_
24+
#define CODA_OSS_json_math_h_INCLUDED_
25+
26+
#include <import/math/linear.h>
27+
#include <import/math/poly.h>
28+
29+
namespace math
30+
{
31+
namespace linear
32+
{
33+
template<typename BasicJsonType, size_t N, typename T>
34+
void to_json(BasicJsonType& j, const VectorN<N, T>& v)
35+
{
36+
std::array<T, N> arr;
37+
for (size_t idx = 0; idx < N; idx++)
38+
{
39+
arr[idx] = v.matrix()[idx][0];
40+
}
41+
j = arr;
42+
}
43+
template<typename BasicJsonType, size_t N, typename T>
44+
void from_json(const BasicJsonType& j, VectorN<N, T>& v)
45+
{
46+
v = j.template get<std::vector<T>>();
47+
}
48+
49+
template<typename BasicJsonType, size_t M, size_t N, typename T>
50+
void to_json(BasicJsonType& j, const MatrixMxN<M, N, T>& v)
51+
{
52+
std::array<std::array<T, N>, M> arr;
53+
for (size_t iRow = 0; iRow < M; iRow++)
54+
{
55+
for (size_t iCol = 0; iCol < N; iCol++)
56+
{
57+
arr[iRow][iCol] = v.mRaw[iRow][iCol];
58+
}
59+
}
60+
j = arr;
61+
}
62+
template<typename BasicJsonType, size_t M, size_t N, typename T>
63+
void from_json(const BasicJsonType& j, MatrixMxN<M, N, T>& v)
64+
{
65+
auto temp = j.template get< std::array< std::array<T, N>, M> > ();
66+
T arr[M * N];
67+
for (size_t iRow = 0; iRow < M; iRow++)
68+
{
69+
for (size_t iCol = 0; iCol < N; iCol++)
70+
{
71+
arr[iRow * N + iCol] = temp[iRow][iCol];
72+
}
73+
}
74+
v = arr;
75+
}
76+
77+
} // namespace linear
78+
79+
namespace poly
80+
{
81+
template<typename BasicJsonType, typename T>
82+
void to_json(BasicJsonType& j, const OneD<T>& poly)
83+
{
84+
if (poly.empty())
85+
{
86+
return;
87+
}
88+
j = poly.coeffs();
89+
}
90+
template<typename BasicJsonType, typename T>
91+
void from_json(const BasicJsonType& j, OneD<T>& poly)
92+
{
93+
if (j.is_null())
94+
{
95+
poly = OneD<T>();
96+
return;
97+
}
98+
poly = OneD<T>(j.template get<std::vector<T>>());
99+
}
100+
101+
template<typename BasicJsonType, typename T>
102+
void to_json(BasicJsonType& j, const TwoD<T>& poly)
103+
{
104+
if (poly.empty())
105+
{
106+
return;
107+
}
108+
std::vector<std::vector<T>> coeffs(poly.orderX() + 1);
109+
for (size_t ix = 0; ix <= poly.orderX(); ix++)
110+
{
111+
coeffs[ix] = poly.coeffs()[ix].coeffs();
112+
}
113+
j = coeffs;
114+
}
115+
template<typename BasicJsonType, typename T>
116+
void from_json(const BasicJsonType& j, TwoD<T>& poly)
117+
{
118+
if (j.is_null())
119+
{
120+
poly = TwoD<T>();
121+
return;
122+
}
123+
poly = TwoD<T>(j.template get<std::vector<OneD<T>>>());
124+
}
125+
} // namespace poly
126+
} // namespace math
127+
128+
#endif
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* =========================================================================
2+
* This file is part of coda-oss.json-c++
3+
* =========================================================================
4+
*
5+
* (C) Copyright 2025 ARKA Group, L.P. All rights reserved
6+
*
7+
* types-c++ is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as published by
9+
* the Free Software Foundation; either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this program; If not,
19+
* see <http://www.gnu.org/licenses/>.
20+
*/
21+
22+
#pragma once
23+
#ifndef CODA_OSS_json_mem_h_INCLUDED_
24+
#define CODA_OSS_json_mem_h_INCLUDED_
25+
26+
#include <mem/ScopedPtr.h>
27+
28+
namespace mem
29+
{
30+
template<typename T, typename TCopyIsClone, typename BasicJsonType>
31+
void to_json(BasicJsonType& j, const ScopedPtr<T, TCopyIsClone>& p)
32+
{
33+
// If 'p' is not `nullptr`, serialize a type T
34+
if (p) j = *p;
35+
}
36+
template<typename T, typename TCopyIsClone, typename BasicJsonType>
37+
void from_json(const BasicJsonType& j, ScopedPtr<T, TCopyIsClone>& p)
38+
{
39+
// If the json is `null` reset with a`nullptr`
40+
// otherwise, deserialize a 'T'
41+
p.reset(j.is_null() ? nullptr : new T(j.template get<T>()));
42+
}
43+
} // namespace mem
44+
45+
#endif

0 commit comments

Comments
 (0)