Skip to content

Commit

Permalink
Use external nlohmann-json library instead of copying the files in th…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
greenscientist committed Nov 25, 2023
1 parent dae309b commit ad30d7c
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 24,657 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev libcapnp-dev capnproto
sudo apt-get install libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev libcapnp-dev capnproto nlohmann-json3-dev
- name: Install deps
if: matrix.os == 'macOS-latest'
run: |
Expand All @@ -32,6 +32,7 @@ jobs:
brew install boost
brew install capnp
brew install spdlog
brew install nlohmann-json
- name: Gen configure
run: autoreconf -i
- name: configure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev libcapnp-dev capnproto
sudo apt-get install libboost-all-dev libexpat1-dev libjsoncpp-dev libspdlog-dev libcapnp-dev capnproto nlohmann-json3-dev
- name: Gen configure
run: autoreconf -i
- name: configure
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ https://chairemobilite.github.io/trRouting/
brew install boost
brew install capnp
brew install spdlog
brew install nlohmann-json
```

## Ubuntu 16.04 Install

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

## Compilation
Expand Down
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ AS_IF([test x"$CAPNP_BIN" = x"no"], [AC_MSG_ERROR([Please install capnp binary.]

PKG_CHECK_MODULES(SPDLOG, spdlog)

PKG_CHECK_MODULES(JSON, nlohmann_json)

# TODO: Add link to doc of this override flag
CPPFLAGS+=" -DBOOST_BIND_GLOBAL_PLACEHOLDERS"

CPPFLAGS+=" $CAPNP_CFLAGS $PTHREAD_CFLAGS $SPDLOG_CFLAGS"
CPPFLAGS+=" $CAPNP_CFLAGS $PTHREAD_CFLAGS $SPDLOG_CFLAGS $JSON_CLAGS"

# Add BOOST flags
LDFLAGS+=" $BOOST_LDFLAGS $BOOST_REGEX_LIB $BOOST_SYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_DATE_TIME_LIB"
Expand Down
2 changes: 1 addition & 1 deletion connection_scan_algorithm/include/result_to_v2.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TR_RESULT_TO_V2_RESPONSE
#define TR_RESULT_TO_V2_RESPONSE

#include "json.hpp"
#include <nlohmann/json.hpp>
#include "routing_result.hpp"

namespace TrRouting
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TR_RESULT_TO_V2_ACCESSIBILITY_RESPONSE
#define TR_RESULT_TO_V2_ACCESSIBILITY_RESPONSE

#include "json.hpp"
#include <nlohmann/json.hpp>
#include "routing_result.hpp"

namespace TrRouting
Expand Down
2 changes: 1 addition & 1 deletion connection_scan_algorithm/include/result_to_v2_summary.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TR_RESULT_TO_V2_SUMMARY_RESPONSE
#define TR_RESULT_TO_V2_SUMMARY_RESPONSE

#include "json.hpp"
#include <nlohmann/json.hpp>
#include "routing_result.hpp"

namespace TrRouting
Expand Down
1 change: 1 addition & 0 deletions connection_scan_algorithm/src/od_trips_routing.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <random>
#include "spdlog/spdlog.h"
#include <nlohmann/json.hpp>

#include "calculator.hpp"
#include "toolbox.hpp"
Expand Down
2 changes: 1 addition & 1 deletion connection_scan_algorithm/src/result_to_v2.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "json.hpp"
#include <nlohmann/json.hpp>
#include "constants.hpp"
#include "result_constants.hpp"
#include "result_to_v2.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "json.hpp"
#include <nlohmann/json.hpp>
#include "constants.hpp"
#include "result_constants.hpp"
#include "result_to_v2_accessibility.hpp"
Expand Down
2 changes: 1 addition & 1 deletion connection_scan_algorithm/src/result_to_v2_summary.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "json.hpp"
#include <nlohmann/json.hpp>
#include "constants.hpp"
#include "result_to_v2_summary.hpp"
#include "toolbox.hpp"
Expand Down
Loading

0 comments on commit ad30d7c

Please sign in to comment.