1# Copyright 2019 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_bloat/bloat.gni") 18import("$dir_pw_build/target_types.gni") 19import("$dir_pw_docgen/docs.gni") 20import("$dir_pw_unit_test/test.gni") 21 22config("public_include_path") { 23 include_dirs = [ "public" ] 24} 25 26pw_source_set("pw_result") { 27 public_configs = [ ":public_include_path" ] 28 public_deps = [ 29 "$dir_pw_assert", 30 "$dir_pw_preprocessor", 31 "$dir_pw_status", 32 ] 33 public = [ "public/pw_result/result.h" ] 34 sources = [ "public/pw_result/internal/result_internal.h" ] 35} 36 37pw_test_group("tests") { 38 tests = [ 39 ":result_test", 40 ":expected_test", 41 ] 42} 43 44pw_test("result_test") { 45 deps = [ 46 ":pw_result", 47 dir_pw_status, 48 ] 49 sources = [ 50 "result_test.cc", 51 "statusor_test.cc", 52 ] 53} 54 55pw_source_set("expected") { 56 public_configs = [ ":public_include_path" ] 57 public = [ "public/pw_result/expected.h" ] 58 sources = [ "public/pw_result/internal/expected_impl.h" ] 59} 60 61pw_test("expected_test") { 62 deps = [ ":expected" ] 63 sources = [ "expected_test.cc" ] 64} 65 66pw_doc_group("docs") { 67 sources = [ "docs.rst" ] 68 report_deps = [ ":result_size" ] 69} 70 71pw_size_diff("result_size") { 72 title = "pw::Result vs. pw::Status and out pointer" 73 74 binaries = [ 75 { 76 target = "size_report:result_simple" 77 base = "size_report:pointer_simple" 78 label = "Simple function" 79 }, 80 { 81 target = "size_report:result_noinline" 82 base = "size_report:pointer_noinline" 83 label = "Simple function without inlining" 84 }, 85 { 86 target = "size_report:result_read" 87 base = "size_report:pointer_read" 88 label = "Returning a larger object (std::span)" 89 }, 90 { 91 target = "size_report:monadic_and_then" 92 base = "size_report:ladder_and_then" 93 label = "Using and_then instead of if ladder" 94 }, 95 { 96 target = "size_report:monadic_or_else" 97 base = "size_report:ladder_or_else" 98 label = "Using or_else instead of if ladder" 99 }, 100 { 101 target = "size_report:monadic_transform" 102 base = "size_report:ladder_transform" 103 label = "Using transform instead of if ladder" 104 }, 105 ] 106} 107