Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Use find_package for nlohmann_json #2880

Closed
wants to merge 6 commits into from
Closed

WIP: Use find_package for nlohmann_json #2880

wants to merge 6 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 16, 2019

This begins the work of #2802 (comment)

Fixes #2874

This PR, whenever possible, attempts to install nlohmann_json via the package manager. If it is unavailable, then we install it from source. Note that since different distros package different versions, then it might be a good idea to install a newer version from source. However, the disadvantage of this is that many package maintainers would prefer the packaged version, even if it is old, because it will contain patches and packaging standards relevant to that distro. On the other side of the argument, supporting a version as old as 2.1.1 would be absurd.

I have only tested one Dockerfile manually on my system; testing all of it would be time consuming. I'm relying on the first round of Kokoro builds to spot any errors. I apologize in advance.


This change is Reviewable

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 16, 2019
@coryan coryan added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jul 16, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jul 16, 2019
@coryan
Copy link
Contributor

coryan commented Jul 16, 2019

I have only tested one Dockerfile manually on my system; testing all of it would be time consuming. I'm relying on the first round of Kokoro builds to spot any errors. I apologize in advance.

No need to apologize, that is why we have robots to do this work. If you do get errors please test your fixes locally first though.

Copy link
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general the changes look great. I have a question, but I have not thought about this much: I really do not know what the answer is.

Reviewed 34 of 34 files at r1.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @remyabel)


google/cloud/storage/CMakeLists.txt, line 47 at r1 (raw file):

endif ()

find_package(nlohmann_json CONFIG REQUIRED)

I think that means if anybody installs nlohmann_json without installing the CMake dependencies the find_package() would fail. Can we just say find_package(nlohmann_json REQUIRED)?


google/cloud/storage/CMakeLists.txt, line 338 at r1 (raw file):

        internal/logging_resumable_upload_session_test.cc
        internal/metadata_parser_test.cc
        internal/nljson_use_after_third_party_test.cc

Can we preserve these tests?


google/cloud/storage/internal/nljson.h, line 43 at r1 (raw file):

#define nlohmann google_cloud_storage_internal_nlohmann_3_4_0
#include "google/cloud/storage/internal/nlohmann_json.hpp"

I am not sure, but maybe we want to preserve this? Obviously we need to change this line to #include <nlohmann/json.hpp> but maybe we can preserve the stuff around it?

@ghost
Copy link
Author

ghost commented Jul 16, 2019

Hmm, this will be less straight forward than I thought. I'm running into strange compilation errors:

In file included from /home/build/google-cloud-cpp/google/cloud/storage/internal/nljson_use_after_third_party_test.cc:23:
/home/build/google-cloud-cpp/google/cloud/storage/internal/nljson.h:70:26: error: variable or field 'PrintTo' declared void
   70 | inline void PrintTo(json const& j, std::ostream* os) { *os << j.dump(); }
      |                          ^~~~~
/home/build/google-cloud-cpp/google/cloud/storage/internal/nljson.h:70:21: error: 'json' was not declared in this scope
   70 | inline void PrintTo(json const& j, std::ostream* os) { *os << j.dump(); }
      |                     ^~~~
/home/build/google-cloud-cpp/google/cloud/storage/internal/nljson.h:70:21: note: suggested alternatives:
In file included from /home/build/google-cloud-cpp/google/cloud/storage/internal/nljson_use_after_third_party_test.cc:20:
/usr/include/json.hpp:871:7: note:   'nlohmann::json'
  871 | using json = basic_json<>;
      |       ^~~~
In file included from /home/build/google-cloud-cpp/google/cloud/storage/internal/nljson_use_after_third_party_test.cc:20:
/usr/include/json.hpp:2259:29: note:   'nlohmann::detail::input_format_t::json'
 2259 | enum class input_format_t { json, cbor, msgpack, ubjson, bson };
      |                             ^~~~
In file included from /home/build/google-cloud-cpp/google/cloud/storage/internal/nljson_use_after_third_party_test.cc:23:
/home/build/google-cloud-cpp/google/cloud/storage/internal/nljson.h:70:48: error: expected primary-expression before '*' token
   70 | inline void PrintTo(json const& j, std::ostream* os) { *os << j.dump(); }
      |                                                ^
/home/build/google-cloud-cpp/google/cloud/storage/internal/nljson.h:70:50: error: 'os' was not declared in this scope; did you mean 'cos'?
   70 | inline void PrintTo(json const& j, std::ostream* os) { *os << j.dump(); }
      |                                                  ^~
      |                                                  cos

I think this might be a compatibility issue with 3.6.1.

@ghost
Copy link
Author

ghost commented Jul 16, 2019

I am closing this for now. There are a surprising amount of obstacles here:

Step 55/81 : RUN cmake -H. -Bcmake-out
 ---> Running in 55baf1f8a701
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.8 or higher is required.  You are running version 3.5.1

@ghost ghost closed this Jul 16, 2019
@ghost ghost deleted the find-package-nljson branch July 23, 2019 19:26
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nlohmann json is available as a package, no need to download it
4 participants