From 7cb526e4da4892d68a0938383849e1bb26ff2857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thi=20Do=C3=A3n?= Date: Wed, 15 Mar 2023 13:17:19 +0900 Subject: [PATCH] Only expose `include/nlohmann/json.hpp` as public header All other headers are not meant to be included by a client of this library and should be declared in `srcs`. --- BUILD.bazel | 4 ++-- cmake/scripts/gen_bazel_build_file.cmake | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 15d84f16b..3ab4b1e78 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,6 +1,6 @@ cc_library( name = "json", - hdrs = [ + srcs = [ "include/nlohmann/adl_serializer.hpp", "include/nlohmann/byte_container_with_subtype.hpp", "include/nlohmann/detail/abi_macros.hpp", @@ -41,12 +41,12 @@ cc_library( "include/nlohmann/detail/string_concat.hpp", "include/nlohmann/detail/string_escape.hpp", "include/nlohmann/detail/value_t.hpp", - "include/nlohmann/json.hpp", "include/nlohmann/json_fwd.hpp", "include/nlohmann/ordered_map.hpp", "include/nlohmann/thirdparty/hedley/hedley.hpp", "include/nlohmann/thirdparty/hedley/hedley_undef.hpp", ], + hdrs = ["include/nlohmann/json.hpp"], includes = ["include"], visibility = ["//visibility:public"], alwayslink = True, diff --git a/cmake/scripts/gen_bazel_build_file.cmake b/cmake/scripts/gen_bazel_build_file.cmake index e754d387d..8e4bc96e4 100644 --- a/cmake/scripts/gen_bazel_build_file.cmake +++ b/cmake/scripts/gen_bazel_build_file.cmake @@ -4,11 +4,12 @@ set(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/../..") set(BUILD_FILE "${PROJECT_ROOT}/BUILD.bazel") file(GLOB_RECURSE HEADERS LIST_DIRECTORIES false RELATIVE "${PROJECT_ROOT}" "include/*.hpp") +list(REMOVE_ITEM HEADERS "include/nlohmann/json.hpp") file(WRITE "${BUILD_FILE}" [=[ cc_library( name = "json", - hdrs = [ + srcs = [ ]=]) foreach(header ${HEADERS}) @@ -17,6 +18,7 @@ endforeach() file(APPEND "${BUILD_FILE}" [=[ ], + hdrs = ["include/nlohmann/json.hpp"], includes = ["include"], visibility = ["//visibility:public"], alwayslink = True,