|  | # Copyright 2023 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_bloat/bloat.gni") | 
|  | import("$dir_pw_build/target_types.gni") | 
|  | import("$dir_pw_thread/backend.gni") | 
|  | import("$dir_pw_toolchain/subtoolchain.gni") | 
|  |  | 
|  | config("public_include_path") { | 
|  | include_dirs = [ "public" ] | 
|  | } | 
|  |  | 
|  | pw_source_set("base") { | 
|  | public = [ "public/pw_async_bench/base.h" ] | 
|  | sources = [ "base.cc" ] | 
|  | public_configs = [ ":public_include_path" ] | 
|  | public_deps = [ | 
|  | "$dir_pw_async:dispatcher", | 
|  | "$dir_pw_async:task", | 
|  | ] | 
|  | } | 
|  |  | 
|  | pw_source_set("callback") { | 
|  | public = [ | 
|  | "public/pw_async_bench/callback.h", | 
|  | "public/pw_async_bench/callback_echo.h", | 
|  | "public/pw_async_bench/callback_impl.h", | 
|  | ] | 
|  | sources = [ | 
|  | "callback.cc", | 
|  | "callback_echo.cc", | 
|  | "callback_impl.cc", | 
|  | ] | 
|  | public_configs = [ ":public_include_path" ] | 
|  | public_deps = [ | 
|  | ":base", | 
|  | "$dir_pw_async:heap_dispatcher", | 
|  | "$dir_pw_result", | 
|  | "$dir_pw_status", | 
|  | ] | 
|  | } | 
|  |  | 
|  | pw_executable("callback_executable") { | 
|  | sources = [ "callback_executable.cc" ] | 
|  | deps = [ | 
|  | ":callback", | 
|  | "$dir_pw_async_basic:dispatcher", | 
|  | "$dir_pw_bloat:bloat_this_binary", | 
|  | "$dir_pw_result", | 
|  | "$dir_pw_status", | 
|  | "$dir_pw_thread:thread", | 
|  | ] | 
|  | } | 
|  |  | 
|  | pw_source_set("bivariant") { | 
|  | public = [ "public/pw_async_bench/bivariant.h" ] | 
|  | sources = [] | 
|  | } | 
|  |  | 
|  | pw_source_set("poll") { | 
|  | public = [ | 
|  | "public/pw_async_bench/poll.h", | 
|  | "public/pw_async_bench/poll_echo.h", | 
|  | "public/pw_async_bench/poll_impl.h", | 
|  | ] | 
|  | sources = [ | 
|  | "poll.cc", | 
|  | "poll_echo.cc", | 
|  | "poll_impl.cc", | 
|  | ] | 
|  | public_configs = [ ":public_include_path" ] | 
|  | public_deps = [ | 
|  | ":base", | 
|  | ":bivariant", | 
|  | "$dir_pw_result", | 
|  | ] | 
|  | } | 
|  |  | 
|  | pw_executable("poll_executable") { | 
|  | sources = [ "poll_executable.cc" ] | 
|  | deps = [ | 
|  | ":bivariant", | 
|  | ":poll", | 
|  | "$dir_pw_async_basic:dispatcher", | 
|  | "$dir_pw_bloat:bloat_this_binary", | 
|  | "$dir_pw_result", | 
|  | "$dir_pw_status", | 
|  | "$dir_pw_thread:thread", | 
|  | ] | 
|  | } | 
|  |  | 
|  | executable("empty_base") { | 
|  | sources = [ "empty_main.cc" ] | 
|  | } | 
|  |  | 
|  | # This target currently causes `pw bloat` to fail because there are too | 
|  | # many differences between the two executables and the `empty_base`. | 
|  | # | 
|  | # pw_size_diff("callback_to_poll_diff") { | 
|  | #   base = ":empty_base" | 
|  | #   data_sources = "symbols,segments" | 
|  | #   binaries = [ | 
|  | #     { | 
|  | #       target = ":callback_executable" | 
|  | #       label = "Echo using callbacks" | 
|  | #     }, | 
|  | #     { | 
|  | #       target = ":poll_executable" | 
|  | #       label = "Echo using poll" | 
|  | #     }, | 
|  | #   ] | 
|  | # } | 
|  |  | 
|  | pw_size_diff("callback_to_poll_diff") { | 
|  | base = ":callback_executable" | 
|  | data_sources = "symbols,segments" | 
|  | binaries = [ | 
|  | { | 
|  | target = ":poll_executable" | 
|  | label = "Echo using poll" | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | group("size_benchmarks") { | 
|  | deps = [ | 
|  | ":callback_executable", | 
|  | ":callback_to_poll_diff", | 
|  | ":poll_executable", | 
|  | ] | 
|  | } |