From 75f3cc721ef4eb0225720a1eb1f51547db272622 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Fri, 11 Oct 2024 14:26:48 -0700 Subject: [PATCH] Use new @jsonhpp//:singleheader-json also available in 3.11.3.bcr.1 We used to patch the module to allow the single header version of the library to be available. Not needed anymore thanks to @lromor who added it in BCR in https://github.com/bazelbuild/bazel-central-registry/pull/2865 Now, use the same name for the old-WORKSPACE based build and the new MODULE based build; for that the name we provide in bazel/jsonhpp.BUILD, and all uses in the repo, had to be changed. While at it: fix formatting in MODULE.bazel. --- .github/bin/run-clang-format.sh | 2 +- MODULE.bazel | 39 +++++++++++++++------------------ bazel/jsonhpp.BUILD | 2 +- bazel/nlohmann_module.patch | 23 ------------------- common/lsp/BUILD | 14 ++++++------ common/text/BUILD | 4 ++-- verilog/CST/BUILD | 4 ++-- verilog/analysis/BUILD | 4 ++-- verilog/tools/ls/BUILD | 10 ++++----- verilog/tools/syntax/BUILD | 2 +- 10 files changed, 39 insertions(+), 65 deletions(-) delete mode 100644 bazel/nlohmann_module.patch diff --git a/.github/bin/run-clang-format.sh b/.github/bin/run-clang-format.sh index 33e1116ad..7abc539c8 100755 --- a/.github/bin/run-clang-format.sh +++ b/.github/bin/run-clang-format.sh @@ -37,7 +37,7 @@ find . -name "*.h" -o -name "*.cc" \ # If we have buildifier installed, use that on BUILD files if command -v ${BUILDIFIER} >/dev/null; then echo "Run $(buildifier --version)" - ${BUILDIFIER} -lint=fix WORKSPACE $(find . -name BUILD -o -name "*.bzl") + ${BUILDIFIER} -lint=fix WORKSPACE MODULE.bazel $(find . -name BUILD -o -name "*.bzl") fi # Check if we got any diff diff --git a/MODULE.bazel b/MODULE.bazel index f1dc33971..c108a9110 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -4,74 +4,71 @@ module( bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "bazel_skylib", version = "1.5.0") - bazel_dep(name = "rules_license", version = "0.0.8") bazel_dep(name = "rules_proto", version = "6.0.0-rc2") bazel_dep(name = "rules_cc", version = "0.0.9") # Register m4 rules and toolchain. bazel_dep(name = "rules_m4", version = "0.2.3") + m4 = use_extension( "@rules_m4//m4/extensions:m4_repository_ext.bzl", "m4_repository_ext", ) m4.repository( name = "m4", - version = "1.4.18", extra_copts = ["-O3"], + version = "1.4.18", ) use_repo(m4, "m4") + register_toolchains("@m4//:toolchain") # Register bison rules and toolchain. bazel_dep(name = "rules_bison", version = "0.2.2") + bison = use_extension( "@rules_bison//bison/extensions:bison_repository_ext.bzl", "bison_repository_ext", ) bison.repository( name = "bison", - version = "3.3.2", extra_copts = ["-O3"], + version = "3.3.2", ) use_repo(bison, "bison") + register_toolchains("@bison//:toolchain") # Register flex rules and toolchain. bazel_dep(name = "rules_flex", version = "0.2.1") + flex = use_extension( "@rules_flex//flex/extensions:flex_repository_ext.bzl", "flex_repository_ext", ) flex.repository( name = "flex", - version = "2.6.4", extra_copts = ["-O3"], + version = "2.6.4", ) use_repo(flex, "flex") + register_toolchains("@flex//:toolchain") -# abseil-cpp can not be updated beyond the following curringly, as newer -# ones use googletest that is not compatible with bazel 6 anymore. -bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name="com_google_absl") +# abseil-cpp and googletest can not be updated beyond the following currently, +# as newer googletest is not compatible with bazel 6 anymore, and abseil-cpp +# depends on it :( -- to support all active bazel's, we're stuck till Dec 2025. +bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name = "com_google_absl") single_version_override( module_name = "abseil-cpp", patch_strip = 1, - version = "20240116.2", patches = ["//bazel:absl.patch"], + version = "20240116.2", ) -# Json module only provide the multi-header target, but that will -# make misc-inlude-cleaner complain about not direct includes. -bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name="jsonhpp") -single_version_override( - module_name = "nlohmann_json", - patches = ["//bazel:nlohmann_module.patch"], -) - -bazel_dep(name = "re2", version = "2023-09-01", repo_name="com_googlesource_code_re2") - -# Newer versions require bazel 7, so this is the last we can use currently. -bazel_dep(name = "googletest", version = "1.14.0.bcr.1", repo_name="com_google_googletest") -bazel_dep(name = "protobuf", version = "26.0", repo_name="com_google_protobuf") +bazel_dep(name = "googletest", version = "1.14.0.bcr.1", repo_name = "com_google_googletest") +bazel_dep(name = "nlohmann_json", version = "3.11.3.bcr.1", repo_name = "jsonhpp") +bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf") +bazel_dep(name = "re2", version = "2023-09-01", repo_name = "com_googlesource_code_re2") bazel_dep(name = "zlib", version = "1.3.1") diff --git a/bazel/jsonhpp.BUILD b/bazel/jsonhpp.BUILD index dae48c5f8..21a6ced12 100644 --- a/bazel/jsonhpp.BUILD +++ b/bazel/jsonhpp.BUILD @@ -5,7 +5,7 @@ licenses(["unencumbered"]) # Public Domain or MIT exports_files(["LICENSE"]) cc_library( - name = "json", + name = "singleheader-json", hdrs = [ "single_include/nlohmann/json.hpp", ], diff --git a/bazel/nlohmann_module.patch b/bazel/nlohmann_module.patch deleted file mode 100644 index 9f6ddd231..000000000 --- a/bazel/nlohmann_module.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- BUILD.bazel 2024-09-27 08:43:50.907170239 -0700 -+++ BUILD.bazel 2024-09-27 08:46:27.441297623 -0700 -@@ -1,5 +1,5 @@ - cc_library( -- name = "json", -+ name = "json-multiheader", - hdrs = [ - "include/nlohmann/adl_serializer.hpp", - "include/nlohmann/byte_container_with_subtype.hpp", -@@ -51,3 +51,13 @@ - visibility = ["//visibility:public"], - alwayslink = True, - ) -+cc_library( -+ name = "json", -+ hdrs = [ -+ "single_include/nlohmann/json.hpp", -+ ], -+ includes = ["single_include"], -+ visibility = ["//visibility:public"], -+ copts = ["-fexceptions"], -+ features = ["-use_header_modules"], # precompiled headers incompatible with -fexceptions. -+) diff --git a/common/lsp/BUILD b/common/lsp/BUILD index 8273dc263..c7b520128 100644 --- a/common/lsp/BUILD +++ b/common/lsp/BUILD @@ -53,7 +53,7 @@ cc_library( deps = [ "//common/util:logging", "@com_google_absl//absl/strings:string_view", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -70,7 +70,7 @@ cc_test( "@com_google_absl//absl/strings:string_view", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -85,7 +85,7 @@ genrule( cc_library( name = "lsp-protocol", hdrs = ["lsp-protocol.h"], - deps = ["@jsonhpp//:json"], + deps = ["@jsonhpp//:singleheader-json"], ) cc_library( @@ -167,7 +167,7 @@ cc_binary( "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:string_view", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -181,7 +181,7 @@ cc_binary( ":message-stream-splitter", "@com_google_absl//absl/status", "@com_google_absl//absl/strings:string_view", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -224,7 +224,7 @@ genrule( cc_library( name = "jcxxgen-testfile", hdrs = ["jcxxgen-testfile.h"], - deps = ["@jsonhpp//:json"], + deps = ["@jsonhpp//:singleheader-json"], ) cc_test( @@ -240,6 +240,6 @@ cc_test( "@com_google_absl//absl/strings", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) diff --git a/common/text/BUILD b/common/text/BUILD index 475db5d5b..89fa06ff1 100644 --- a/common/text/BUILD +++ b/common/text/BUILD @@ -37,7 +37,7 @@ cc_library( hdrs = ["token_info_json.h"], deps = [ ":token-info", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -415,7 +415,7 @@ cc_test( "@com_google_absl//absl/strings:string_view", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) diff --git a/verilog/CST/BUILD b/verilog/CST/BUILD index 30ff07d94..3ee9d0a9d 100644 --- a/verilog/CST/BUILD +++ b/verilog/CST/BUILD @@ -902,7 +902,7 @@ cc_library( "//verilog/parser:verilog-token-classifications", "//verilog/parser:verilog-token-enum", "@com_google_absl//absl/strings:string_view", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -955,6 +955,6 @@ cc_test( "//verilog/analysis:verilog-analyzer", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) diff --git a/verilog/analysis/BUILD b/verilog/analysis/BUILD index f48c1be4e..76c8fc013 100644 --- a/verilog/analysis/BUILD +++ b/verilog/analysis/BUILD @@ -75,7 +75,7 @@ cc_library( "//common/analysis:file-analyzer", "//common/strings:line-column-map", "@com_google_absl//absl/strings:string_view", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -132,7 +132,7 @@ cc_test( "//common/util:logging", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) diff --git a/verilog/tools/ls/BUILD b/verilog/tools/ls/BUILD index d218c7f2a..0bac38938 100644 --- a/verilog/tools/ls/BUILD +++ b/verilog/tools/ls/BUILD @@ -106,7 +106,7 @@ cc_library( "//verilog/parser:verilog-token-enum", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:string_view", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -138,7 +138,7 @@ cc_library( "//verilog/CST:package", "//verilog/CST:seq-block", "//verilog/CST:verilog-nonterminals", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -239,7 +239,7 @@ cc_library( "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/status", "@com_google_absl//absl/strings:string_view", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -260,7 +260,7 @@ cc_test( "@com_google_absl//absl/strings:string_view", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) @@ -312,6 +312,6 @@ cc_test( "@com_google_absl//absl/strings:string_view", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], ) diff --git a/verilog/tools/syntax/BUILD b/verilog/tools/syntax/BUILD index 57899bc0b..7a95c1560 100644 --- a/verilog/tools/syntax/BUILD +++ b/verilog/tools/syntax/BUILD @@ -39,7 +39,7 @@ cc_binary( "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:string_view", - "@jsonhpp//:json", + "@jsonhpp//:singleheader-json", ], )