1 # Copyright 2019 The Pigweed Authors
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
7 # https://www.apache.org/licenses/LICENSE-2.0
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
15 import("//build_overrides/pigweed.gni")
17 import("$dir_pw_bloat/bloat.gni")
18 import("$dir_pw_build/target_types.gni")
19 import("$dir_pw_docgen/docs.gni")
20 import("$dir_pw_unit_test/test.gni")
22 config("default_config") {
23 include_dirs = [ "public" ]
26 pw_source_set("pw_string") {
27 public_configs = [ ":default_config" ]
29 "public/pw_string/format.h",
30 "public/pw_string/string_builder.h",
31 "public/pw_string/to_string.h",
32 "public/pw_string/type_to_string.h",
33 "public/pw_string/util.h",
41 "$dir_pw_preprocessor",
46 pw_test_group("tests") {
49 ":string_builder_test",
51 ":type_to_string_test",
55 "$dir_pw_preprocessor:tests",
56 "$dir_pw_status:tests",
60 pw_test("format_test") {
61 deps = [ ":pw_string" ]
62 sources = [ "format_test.cc" ]
65 pw_test("string_builder_test") {
66 deps = [ ":pw_string" ]
67 sources = [ "string_builder_test.cc" ]
70 pw_test("to_string_test") {
71 deps = [ ":pw_string" ]
72 sources = [ "to_string_test.cc" ]
75 pw_test("type_to_string_test") {
76 deps = [ ":pw_string" ]
77 sources = [ "type_to_string_test.cc" ]
80 pw_test("util_test") {
81 deps = [ ":pw_string" ]
82 sources = [ "util_test.cc" ]
85 pw_doc_group("docs") {
86 sources = [ "docs.rst" ]
88 ":format_size_report",
89 ":string_builder_size_report",
93 pw_size_report("format_size_report") {
94 title = "Using pw::string::Format instead of snprintf"
98 target = "size_report:single_write_format"
99 base = "size_report:single_write_snprintf"
100 label = "Format instead of snprintf once, return size"
103 target = "size_report:multiple_writes_format"
104 base = "size_report:multiple_writes_snprintf"
105 label = "Format instead of snprintf 10 times, handle errors"
108 target = "size_report:many_writes_format"
109 base = "size_report:many_writes_snprintf"
110 label = "Format instead of snprintf 50 times, no error handling"
115 pw_size_report("string_builder_size_report") {
116 title = "Using pw::StringBuilder instead of snprintf"
120 target = "size_report:build_string_with_string_builder"
121 base = "size_report:build_string_with_snprintf"
122 label = "Total StringBuilder cost when used alongside snprintf"
125 target = "size_report:build_string_with_string_builder_no_base_snprintf"
126 base = "size_report:build_string_with_snprintf_no_base_snprintf"
127 label = "StringBuilder cost when completely replacing snprintf"
130 target = "size_report:build_string_incremental_with_string_builder"
131 base = "size_report:build_string_incremental_with_snprintf"
132 label = "Incremental cost relative to snprintf for 10 strings"