targets/docs: Use tokenized asserts/logs
Switches the docs target to use tokenized logging/asserts to better
represent expected real-world binary sizes.
Change-Id: I049b67a0d3dcceff4fa3ff9f349fbdd3b024d78f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/112313
Pigweed-Auto-Submit: Armando Montanez <amontanez@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/targets/docs/BUILD.bazel b/targets/docs/BUILD.bazel
new file mode 100644
index 0000000..e342830
--- /dev/null
+++ b/targets/docs/BUILD.bazel
@@ -0,0 +1,24 @@
+# Copyright 2020 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"])
+
+filegroup(
+ name = "tokenized_log_handler",
+ srcs = [
+ "tokenized_log_handler.cc",
+ ],
+)
diff --git a/targets/docs/BUILD.gn b/targets/docs/BUILD.gn
index 7628d56..42ca57d 100644
--- a/targets/docs/BUILD.gn
+++ b/targets/docs/BUILD.gn
@@ -21,6 +21,15 @@
import("$dir_pw_toolchain/arm_gcc/toolchains.gni")
import("$dir_pw_toolchain/generate_toolchain.gni")
+pw_source_set("tokenized_log_handler") {
+ deps = [
+ "$dir_pw_bytes",
+ "$dir_pw_sys_io",
+ "$dir_pw_tokenizer:global_handler_with_payload.facade",
+ ]
+ sources = [ "tokenized_log_handler.cc" ]
+}
+
# Toolchain for generating upstream Pigweed documentation.
generate_toolchain("docs") {
# Use the stm32f429i-disc1 toolchain for pw_size_diff targets.
@@ -39,6 +48,11 @@
# Disable NC tests in case the base toolchain has them enabled.
pw_compilation_testing_NEGATIVE_COMPILATION_ENABLED = false
+
+ pw_assert_BACKEND = dir_pw_assert_log
+ pw_log_BACKEND = dir_pw_log_tokenized
+ pw_tokenizer_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND =
+ get_path_info(":tokenized_log_handler", "abspath")
}
}
diff --git a/targets/docs/tokenized_log_handler.cc b/targets/docs/tokenized_log_handler.cc
new file mode 100644
index 0000000..347af5d
--- /dev/null
+++ b/targets/docs/tokenized_log_handler.cc
@@ -0,0 +1,23 @@
+// Copyright 2022 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+#include "pw_bytes/span.h"
+#include "pw_sys_io/sys_io.h"
+#include "pw_tokenizer/tokenize_to_global_handler_with_payload.h"
+
+extern "C" void pw_tokenizer_HandleEncodedMessageWithPayload(
+ pw_tokenizer_Payload, const uint8_t encoded_message[], size_t size_bytes) {
+ pw::sys_io::WriteBytes(pw::ConstByteSpan(
+ reinterpret_cast<const std::byte*>(encoded_message), size_bytes));
+}