From e40c188e2ef1b0dfd77681e7586914baf1fe4828 Mon Sep 17 00:00:00 2001 From: Piotr Korkus Date: Tue, 16 Dec 2025 09:58:52 +0100 Subject: [PATCH 1/2] bazel: bump modules --- MODULE.bazel | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index bd26548..ef0294b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -24,7 +24,7 @@ module( bazel_dep(name = "score_starpls_lsp", version = "0.1.0", dev_dependency = True) # Python rules. -bazel_dep(name = "rules_python", version = "1.0.0", dev_dependency = True) +bazel_dep(name = "rules_python", version = "1.7.0", dev_dependency = True) PYTHON_VERSION = "3.12" @@ -36,13 +36,13 @@ python.toolchain( use_repo(python) # C++ GoogleTest dependencies. -bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True) +bazel_dep(name = "googletest", version = "1.17.0", dev_dependency = True) # Rust rules. -bazel_dep(name = "rules_rust", version = "0.56.0") +bazel_dep(name = "rules_rust", version = "0.67.0") # C/C++ rules. -bazel_dep(name = "rules_cc", version = "0.1.1", dev_dependency = True) +bazel_dep(name = "rules_cc", version = "0.2.14") # Rust module dependencies. rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") @@ -55,4 +55,4 @@ rust.toolchain( bazel_dep(name = "score_baselibs", version = "0.1.2", dev_dependency = True) # Score Rust crates. -bazel_dep(name = "score_crates", version = "0.0.4") +bazel_dep(name = "score_crates", version = "0.0.6") From 9c2af533a43fc1ce902cea8ca1ac6e57d83f3769 Mon Sep 17 00:00:00 2001 From: Piotr Korkus Date: Tue, 16 Dec 2025 09:58:52 +0100 Subject: [PATCH 2/2] bazel: remove baselibs dependency replace with direct nlohamann json usage --- .bazelrc | 1 - MODULE.bazel | 4 ++-- test_scenarios_cpp/BUILD | 2 +- test_scenarios_cpp/include/tracing.hpp | 17 ++++++++--------- test_scenarios_cpp/src/tracing.cpp | 14 ++++---------- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/.bazelrc b/.bazelrc index fd762dc..51cac5a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,7 +2,6 @@ build --java_language_version=17 build --tool_java_language_version=17 build --java_runtime_version=remotejdk_17 build --tool_java_runtime_version=remotejdk_17 -build --@score_baselibs//score/json:base_library=nlohmann test --test_output=errors diff --git a/MODULE.bazel b/MODULE.bazel index ef0294b..df27b2a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -51,8 +51,8 @@ rust.toolchain( versions = ["1.85.0"], ) -# C++ base libs. -bazel_dep(name = "score_baselibs", version = "0.1.2", dev_dependency = True) +# Json for C++. +bazel_dep(name = "nlohmann_json", version = "3.12.0") # Score Rust crates. bazel_dep(name = "score_crates", version = "0.0.6") diff --git a/test_scenarios_cpp/BUILD b/test_scenarios_cpp/BUILD index 5dce066..3461231 100644 --- a/test_scenarios_cpp/BUILD +++ b/test_scenarios_cpp/BUILD @@ -35,7 +35,7 @@ cc_library( ], includes = ["include/"], visibility = ["//visibility:public"], - deps = ["@score_baselibs//score/json:json_parser"], + deps = ["@nlohmann_json//:json"], ) cc_test( diff --git a/test_scenarios_cpp/include/tracing.hpp b/test_scenarios_cpp/include/tracing.hpp index c1475ab..67abaf8 100644 --- a/test_scenarios_cpp/include/tracing.hpp +++ b/test_scenarios_cpp/include/tracing.hpp @@ -20,7 +20,7 @@ #include #include "monotonic_clock.hpp" -#include "score/json/json_writer.h" +#include #define _TRACING(target, level, fields...) \ do { \ @@ -58,8 +58,7 @@ class Subscriber { template void event(const std::optional& target, const Level& level, std::pair... fields) const { - using namespace score::json; - Object fields_object{object_create(fields...)}; + nlohmann::json fields_object = object_create(fields...); handle_event(target, level, std::move(fields_object)); } @@ -69,15 +68,15 @@ class Subscriber { MonotonicClock timer_; void handle_event(const std::optional& target, const Level& level, - score::json::Object&& fields) const; + nlohmann::json&& fields) const; - score::json::Object object_create() const { return score::json::Object{}; } + nlohmann::json object_create() const { return nlohmann::json::object(); } template - score::json::Object object_create(std::pair field, - std::pair... fields) const { - auto object{object_create(fields...)}; - object.insert(field); + nlohmann::json object_create(std::pair field, + std::pair... fields) const { + auto object = object_create(fields...); + object[field.first] = field.second; return object; } }; diff --git a/test_scenarios_cpp/src/tracing.cpp b/test_scenarios_cpp/src/tracing.cpp index 0a82116..20b9545 100644 --- a/test_scenarios_cpp/src/tracing.cpp +++ b/test_scenarios_cpp/src/tracing.cpp @@ -65,15 +65,13 @@ Subscriber::Subscriber(Level max_level, bool thread_ids) : max_level_{max_level}, thread_ids_{thread_ids} {} void Subscriber::handle_event(const std::optional& target, const Level& level, - score::json::Object&& fields) const { - using namespace score::json; - + nlohmann::json&& fields) const { // Drop handling if below max level. if (level < max_level_) { return; } - Object event; + nlohmann::json event; // Add timestamp. event.emplace("timestamp", timer_.format_time()); @@ -98,17 +96,13 @@ void Subscriber::handle_event(const std::optional& target, const Le } // Make JSON string. - JsonWriter writer; - auto buffer_result{writer.ToBuffer(event)}; - if (!buffer_result) { - throw std::runtime_error{"Failed to stringify JSON"}; - } + std::string json_str = event.dump(); // Minify JSON and add "\n". // "\n" + 'std::flush' is used instead of 'std::endl'. // This is to avoid message mangling in multithreaded scenarios. std::stringstream ss; - ss << minify_json(*buffer_result) << "\n"; + ss << minify_json(json_str) << "\n"; // Print output. std::cout << ss.str() << std::flush;