1# Copyright 2022 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/error.gni") 18import("$dir_pw_build/facade.gni") 19import("$dir_pw_build/target_types.gni") 20import("$dir_pw_docgen/docs.gni") 21import("backend.gni") 22 23config("public_include_path") { 24 include_dirs = [ "public" ] 25} 26 27config("backend_config") { 28 include_dirs = [ "public_overrides" ] 29} 30 31# This source set only provides pw_log's backend interface by invoking the 32# :handler facade. 33pw_source_set("pw_log_string") { 34 public_configs = [ 35 ":backend_config", 36 ":public_include_path", 37 ] 38 public = [ 39 "public/pw_log_string/log_string.h", 40 "public_overrides/pw_log_backend/log_backend.h", 41 ] 42 public_deps = [ 43 ":handler", 44 "$dir_pw_preprocessor", 45 ] 46} 47 48pw_source_set("pw_log_string.impl") { 49 deps = [ ":handler.impl" ] 50} 51 52# This facade is a C API for string based logging which may be used to back 53# pw_log or for example to mix tokenized and string based logging. 54pw_facade("handler") { 55 backend = pw_log_string_HANDLER_BACKEND 56 public_configs = [ ":public_include_path" ] 57 public = [ "public/pw_log_string/handler.h" ] 58 public_deps = [ "$dir_pw_preprocessor" ] 59 sources = [ "handler.cc" ] 60 61 require_link_deps = [ ":handler.impl" ] 62} 63 64# Logging is low-level and ubiquitous. Because of this, it can often cause 65# circular dependencies. This target collects dependencies from the backend that 66# cannot be used because they would cause circular deps. 67# 68# This group ("$dir_pw_log_string:handler_impl") must be listed in 69# pw_build_LINK_DEPS if pw_log_string_HANDLER_BACKEND is set. 70# 71# pw_log_string:handler backends must provide their own "impl" target that 72# collects their actual dependencies. The backend "impl" group may be empty 73# if everything can go directly in the backend target without causing circular 74# dependencies. 75if (pw_log_string_HANDLER_BACKEND != "") { 76 pw_source_set("handler.impl") { 77 deps = [ get_label_info(pw_log_string_HANDLER_BACKEND, 78 "label_no_toolchain") + ".impl" ] 79 } 80} else { 81 pw_error("handler.impl") { 82 message = 83 string_join(" ", 84 [ 85 "To use pw_log_string:handler, please direct", 86 "pw_log_string_HANDLER_BACKEND to the source set that", 87 "implements the C API.", 88 ]) 89 } 90} 91 92pw_doc_group("docs") { 93 sources = [ "docs.rst" ] 94} 95