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 28071a8
Showing 20 changed files with 21 additions and 24,658 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
@@ -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: |
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ WORKDIR /source
# Install dependencies in an intermediate image
RUN apt-get update && \
apt-get -y --no-install-recommends install build-essential autoconf automake autoconf-archive pkg-config capnproto libcapnp-dev \
libboost-all-dev libtool libspdlog-dev
libboost-all-dev libtool libspdlog-dev nlohmann-json3-dev

# Copy and build source
COPY . /source
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -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"
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
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
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
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"
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"
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"
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"
Loading

0 comments on commit 28071a8

Please sign in to comment.