pw_log_string: Add backend
pw_log_string is similar to pw_log_basic in that it simply takes raw
data at logging callsites and pipes it to an extern C symbol. The
difference is that pw_log_string does NOT provide an implementation of
said C symbol. This allows string-based log handling to be dictated by
the project.
Change-Id: Id40262a090a1c17db25425389fe52dce3c546c39
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/77182
Reviewed-by: Carlos Chinchilla <cachinchilla@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Armando Montanez <amontanez@google.com>
diff --git a/pw_log_string/BUILD.gn b/pw_log_string/BUILD.gn
new file mode 100644
index 0000000..67ab903
--- /dev/null
+++ b/pw_log_string/BUILD.gn
@@ -0,0 +1,64 @@
+# 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.
+
+import("//build_overrides/pigweed.gni")
+
+import("$dir_pw_build/error.gni")
+import("$dir_pw_build/target_types.gni")
+import("$dir_pw_docgen/docs.gni")
+import("backend.gni")
+
+config("public_include_path") {
+ include_dirs = [ "public" ]
+}
+
+config("backend_config") {
+ include_dirs = [ "public_overrides" ]
+}
+
+# This source set only provides pw_log_string's backend interface. The implementation is
+# pulled in through pw_build_LINK_DEPS.
+pw_source_set("pw_log_string") {
+ public_configs = [
+ ":backend_config",
+ ":public_include_path",
+ ]
+ public = [
+ "public/pw_log_string/log_string.h",
+ "public_overrides/pw_log_backend/log_backend.h",
+ ]
+ public_deps = [ dir_pw_preprocessor ]
+}
+
+# The log backend deps that might cause circular dependencies, since
+# pw_log is so ubiquitous. These deps are kept separate so they can be
+# depended on from elsewhere.
+if (pw_log_string_BACKEND != "") {
+ pw_source_set("pw_log_string.impl") {
+ deps = [ pw_log_string_BACKEND ]
+ }
+} else {
+ pw_error("pw_log_string.impl") {
+ message = string_join(
+ " ",
+ [
+ "To use pw_log_string, please direct pw_log_string_BACKEND",
+ "to the source set that implements the C API.",
+ ])
+ }
+}
+
+pw_doc_group("docs") {
+ sources = [ "docs.rst" ]
+}