Skip to content

Commit 2bcf11c

Browse files
Use external nlohmann-json library instead of copying the files in the project
Distro have packages for the json library that we use. Instead of having to maintain a local file in the repo, we will rely on external files on the system. We changed the #include reference to point the the standard files and added a check in the configure to make sure the file is available. Also updated the github actions to install the right packages and updated the README to add the package to the install instructions
1 parent d21d157 commit 2bcf11c

20 files changed

+22
-24659
lines changed

.github/workflows/c-cpp.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
if: matrix.os == 'ubuntu-latest'
2222
run: |
2323
sudo apt-get update
24-
sudo apt-get install libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev libcapnp-dev capnproto
24+
sudo apt-get install libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev libcapnp-dev capnproto nlohmann-json3-dev
2525
- name: Install deps
2626
if: matrix.os == 'macOS-latest'
2727
run: |
@@ -32,6 +32,7 @@ jobs:
3232
brew install boost
3333
brew install capnp
3434
brew install spdlog
35+
brew install nlohmann-json
3536
- name: Gen configure
3637
run: autoreconf -i
3738
- name: configure

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Install deps
6060
run: |
6161
sudo apt-get update
62-
sudo apt-get install libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev libcapnp-dev capnproto
62+
sudo apt-get install libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev libcapnp-dev capnproto nlohmann-json3-dev
6363
- name: Gen configure
6464
run: autoreconf -i
6565
- name: configure

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM debian:bullseye-slim
1+
FROM debian:bookworm-slim
22
WORKDIR /source
33
# Install dependencies in an intermediate image
44
RUN apt-get update && \
55
apt-get -y --no-install-recommends install build-essential autoconf automake autoconf-archive pkg-config capnproto libcapnp-dev \
6-
libboost-all-dev libtool libspdlog-dev
6+
libboost-all-dev libtool libspdlog-dev nlohmann-json3-dev
77

88
# Copy and build source
99
COPY . /source

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ https://chairemobilite.github.io/trRouting/
2828
brew install boost
2929
brew install capnp
3030
brew install spdlog
31+
brew install nlohmann-json
3132
```
3233

3334
## Ubuntu 16.04 Install
3435

3536
[Install Cap'nProto](https://capnproto.org/install.html)
3637
```
37-
sudo apt-get install clang libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev
38+
sudo apt-get install clang libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev nlohmann-json3-dev
3839
```
3940

4041
## Compilation

configure.ac

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ AS_IF([test x"$CAPNP_BIN" = x"no"], [AC_MSG_ERROR([Please install capnp binary.]
2929

3030
PKG_CHECK_MODULES(SPDLOG, spdlog)
3131

32+
PKG_CHECK_MODULES(JSON, nlohmann_json)
33+
3234
# TODO: Add link to doc of this override flag
3335
CPPFLAGS+=" -DBOOST_BIND_GLOBAL_PLACEHOLDERS"
3436

35-
CPPFLAGS+=" $CAPNP_CFLAGS $PTHREAD_CFLAGS $SPDLOG_CFLAGS"
37+
CPPFLAGS+=" $CAPNP_CFLAGS $PTHREAD_CFLAGS $SPDLOG_CFLAGS $JSON_CLAGS"
3638

3739
# Add BOOST flags
3840
LDFLAGS+=" $BOOST_LDFLAGS $BOOST_REGEX_LIB $BOOST_SYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_DATE_TIME_LIB"

connection_scan_algorithm/include/result_to_v2.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef TR_RESULT_TO_V2_RESPONSE
22
#define TR_RESULT_TO_V2_RESPONSE
33

4-
#include "json.hpp"
4+
#include <nlohmann/json.hpp>
55
#include "routing_result.hpp"
66

77
namespace TrRouting

connection_scan_algorithm/include/result_to_v2_accessibility.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef TR_RESULT_TO_V2_ACCESSIBILITY_RESPONSE
22
#define TR_RESULT_TO_V2_ACCESSIBILITY_RESPONSE
33

4-
#include "json.hpp"
4+
#include <nlohmann/json.hpp>
55
#include "routing_result.hpp"
66

77
namespace TrRouting

connection_scan_algorithm/include/result_to_v2_summary.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef TR_RESULT_TO_V2_SUMMARY_RESPONSE
22
#define TR_RESULT_TO_V2_SUMMARY_RESPONSE
33

4-
#include "json.hpp"
4+
#include <nlohmann/json.hpp>
55
#include "routing_result.hpp"
66

77
namespace TrRouting

connection_scan_algorithm/src/od_trips_routing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <random>
22
#include "spdlog/spdlog.h"
3+
#include <nlohmann/json.hpp>
34

45
#include "calculator.hpp"
56
#include "toolbox.hpp"

connection_scan_algorithm/src/result_to_v2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "json.hpp"
1+
#include <nlohmann/json.hpp>
22
#include "constants.hpp"
33
#include "result_constants.hpp"
44
#include "result_to_v2.hpp"

connection_scan_algorithm/src/result_to_v2_accessibility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "json.hpp"
1+
#include <nlohmann/json.hpp>
22
#include "constants.hpp"
33
#include "result_constants.hpp"
44
#include "result_to_v2_accessibility.hpp"

connection_scan_algorithm/src/result_to_v2_summary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "json.hpp"
1+
#include <nlohmann/json.hpp>
22
#include "constants.hpp"
33
#include "result_to_v2_summary.hpp"
44
#include "toolbox.hpp"

0 commit comments

Comments
 (0)