Make jsoncpp a formal dependency (#10739)

* Adding jsoncpp submodule

* Adding bazel dependency

* Hook up jsoncpp in Bazel builds

* Hook up jsoncpp dependency in CMake

* Fix conformance binary path

* Move jsoncpp import to the end of the file to avoid confusing add_test
pull/10754/head
Mike Kruskal 2 years ago committed by GitHub
parent 19d74e7369
commit 5308cf0aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .gitmodules
  2. 17
      cmake/conformance.cmake
  3. 18
      conformance/BUILD.bazel
  4. 2
      conformance/binary_json_conformance_suite.cc
  5. 2
      conformance/binary_json_conformance_suite.h
  6. 2075
      conformance/third_party/jsoncpp/json.h
  7. 5192
      conformance/third_party/jsoncpp/jsoncpp.cpp
  8. 8
      protobuf_deps.bzl
  9. 1
      third_party/jsoncpp

3
.gitmodules vendored

@ -6,3 +6,6 @@
path = third_party/abseil-cpp
url = https://github.com/abseil/abseil-cpp.git
branch = lts_2022_06_23
[submodule "third_party/jsoncpp"]
path = third_party/jsoncpp
url = https://github.com/open-source-parsers/jsoncpp.git

@ -1,4 +1,14 @@
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/jsoncpp/CMakeLists.txt")
message(FATAL_ERROR
"Cannot find third_party/jsoncpp directory that's needed to "
"build conformance tests. If you use git, make sure you have cloned "
"submodules:\n"
" git submodule update --init --recursive\n"
"If instead you want to skip them, run cmake with:\n"
" cmake -Dprotobuf_BUILD_CONFORMANCE=OFF\n")
endif()
add_custom_command(
OUTPUT
${protobuf_SOURCE_DIR}/conformance/conformance.pb.h
@ -33,8 +43,6 @@ add_executable(conformance_test_runner
${protobuf_SOURCE_DIR}/conformance/conformance_test_main.cc
${protobuf_SOURCE_DIR}/conformance/text_format_conformance_suite.cc
${protobuf_SOURCE_DIR}/conformance/text_format_conformance_suite.h
${protobuf_SOURCE_DIR}/conformance/third_party/jsoncpp/json.h
${protobuf_SOURCE_DIR}/conformance/third_party/jsoncpp/jsoncpp.cpp
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.h
@ -74,3 +82,8 @@ add_test(NAME conformance_cpp_test
--output_dir ${protobuf_TEST_XML_OUTDIR}
${CMAKE_CURRENT_BINARY_DIR}/conformance_cpp
DEPENDS conformance_test_runner conformance_cpp)
set(JSONCPP_WITH_TESTS OFF CACHE BOOL "Disable tests")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp third_party/jsoncpp)
target_include_directories(conformance_test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp/include)
target_link_libraries(conformance_test_runner jsoncpp_lib)

@ -126,13 +126,6 @@ internal_ruby_proto_library(
],
)
cc_library(
name = "jsoncpp",
srcs = ["third_party/jsoncpp/jsoncpp.cpp"],
hdrs = ["third_party/jsoncpp/json.h"],
includes = ["."],
)
cc_library(
name = "conformance_test",
srcs = [
@ -156,7 +149,7 @@ cc_library(
hdrs = ["binary_json_conformance_suite.h"],
deps = [
":conformance_test",
":jsoncpp",
"@jsoncpp//:jsoncpp",
":test_messages_proto2_proto_cc",
":test_messages_proto3_proto_cc",
"@com_google_absl//absl/status",
@ -368,19 +361,10 @@ pkg_files(
visibility = ["//pkg:__pkg__"],
)
pkg_files(
name = "dist_scripts",
srcs = ["conformance_test_runner.sh"],
attributes = pkg_attributes(mode = "0555"),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
pkg_filegroup(
name = "all_dist_files",
srcs = [
":dist_files",
":dist_scripts",
],
visibility = ["//pkg:__pkg__"],
)

@ -36,7 +36,7 @@
#include "google/protobuf/util/type_resolver_util.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "third_party/jsoncpp/json.h"
#include "json/json.h"
#include "conformance/conformance.pb.h"
#include "conformance_test.h"
#include "google/protobuf/test_messages_proto2.pb.h"

@ -32,7 +32,7 @@
#define CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H
#include "google/protobuf/descriptor.h"
#include "third_party/jsoncpp/json.h"
#include "json/json.h"
#include "conformance_test.h"
namespace google {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -54,6 +54,14 @@ def protobuf_deps():
urls = ["https://github.com/madler/zlib/archive/v1.2.12.tar.gz"],
)
if not native.existing_rule("jsoncpp"):
_github_archive(
name = "jsoncpp",
repo = "https://github.com/open-source-parsers/jsoncpp",
commit = "5defb4ed1a4293b8e2bf641e16b156fb9de498cc",
sha256 = "a03d3136ff6dd092143bba8d3ded641e87b44e6c0b1f632b368f6cc8587524b5",
)
if not native.existing_rule("rules_cc"):
_github_archive(
name = "rules_cc",

@ -0,0 +1 @@
Subproject commit 5defb4ed1a4293b8e2bf641e16b156fb9de498cc
Loading…
Cancel
Save