1# Copyright 2024 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 15include("$ENV{PW_ROOT}/pw_build/pigweed.cmake") 16include("$ENV{PW_ROOT}/pw_perf_test/backend.cmake") 17include("$ENV{PW_ROOT}/pw_sync/backend.cmake") 18include("$ENV{PW_ROOT}/pw_thread/backend.cmake") 19 20# Libraries 21 22pw_add_library(pw_allocator.examples.named_u32 INTERFACE 23 HEADERS 24 named_u32.h 25 PUBLIC_INCLUDES 26 public 27 PUBLIC_DEPS 28 pw_bytes 29 pw_string 30) 31 32pw_add_library(pw_allocator.examples.custom_allocator STATIC 33 HEADERS 34 custom_allocator.h 35 PUBLIC_INCLUDES 36 public 37 PUBLIC_DEPS 38 pw_allocator.allocator 39 SOURCES 40 custom_allocator.cc 41 PRIVATE_DEPS 42 pw_log 43 pw_result 44) 45 46pw_add_library(pw_allocator.examples.custom_allocator_test_harness INTERFACE 47 HEADERS 48 custom_allocator_test_harness.h 49 PUBLIC_INCLUDES 50 public 51 PUBLIC_DEPS 52 pw_allocator.examples.custom_allocator 53 pw_allocator.test_harness 54 pw_allocator.testing 55) 56 57 # Examples 58 59pw_add_test(pw_allocator.examples.basic 60 PRIVATE_DEPS 61 pw_allocator.examples.named_u32 62 pw_allocator.allocator 63 pw_allocator.testing 64 SOURCES 65 basic.cc 66) 67 68pw_add_test(pw_allocator.examples.block_allocator 69 PRIVATE_DEPS 70 pw_allocator.examples.named_u32 71 pw_allocator.first_fit 72 SOURCES 73 block_allocator.cc 74) 75 76if((NOT "${pw_perf_test.timer_interface_BACKEND}" STREQUAL "")) 77 pw_add_test(pw_allocator.examples.custom_allocator_perf_test 78 PRIVATE_DEPS 79 pw_allocator.examples.custom_allocator_test_harness 80 pw_perf_test 81 pw_random 82 SOURCES 83 custom_allocator_perf_test.cc 84 ) 85endif() 86 87pw_add_test(pw_allocator.examples.custom_allocator_test 88 PRIVATE_DEPS 89 pw_allocator.examples.custom_allocator 90 pw_allocator.examples.custom_allocator_test_harness 91 pw_allocator.examples.named_u32 92 pw_allocator.fuzzing 93 pw_allocator.testing 94 pw_containers.vector 95 pw_fuzzer.fuzztest 96 SOURCES 97 custom_allocator_test.cc 98) 99 100pw_add_test(pw_allocator.examples.linker_sections 101 PRIVATE_DEPS 102 pw_allocator.examples.named_u32 103 pw_allocator.allocator 104 pw_allocator.block_allocator 105 SOURCES 106 linker_sections.cc 107) 108 109pw_add_test(pw_allocator.examples.metrics 110 PRIVATE_DEPS 111 pw_allocator.examples.named_u32 112 pw_allocator.testing 113 pw_allocator.tracking_allocator 114 pw_tokenizer 115 SOURCES 116 metrics.cc 117) 118 119if((NOT "${pw_sync.interrupt_spin_lock_BACKEND}" STREQUAL "") AND 120 (NOT "${pw_thread.test_thread_context_BACKEND}" STREQUAL "")) 121 pw_add_test(pw_allocator.examples.spin_lock 122 PRIVATE_DEPS 123 pw_allocator.examples.named_u32 124 pw_allocator.synchronized_allocator 125 pw_allocator.testing 126 pw_sync.interrupt_spin_lock 127 pw_thread.test_thread_context 128 pw_thread.thread 129 pw_thread.thread_core 130 pw_assert 131 SOURCES 132 spin_lock.cc 133 ) 134endif() 135