1# Copyright 2020 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/target_types.gni") 18import("$dir_pw_docgen/docs.gni") 19import("$dir_pw_unit_test/test.gni") 20 21declare_args() { 22 pw_allocator_POISON_HEAP = false 23} 24 25config("default_config") { 26 include_dirs = [ "public" ] 27} 28 29config("enable_heap_poison") { 30 if (pw_allocator_POISON_HEAP) { 31 defines = [ "PW_ALLOCATOR_POISON_ENABLE=1" ] 32 } 33} 34 35group("pw_allocator") { 36 public_deps = [ 37 ":block", 38 ":freelist", 39 ":freelist_heap", 40 ] 41} 42 43pw_source_set("block") { 44 public_configs = [ ":default_config" ] 45 configs = [ ":enable_heap_poison" ] 46 public = [ "public/pw_allocator/block.h" ] 47 public_deps = [ 48 dir_pw_assert, 49 dir_pw_span, 50 dir_pw_status, 51 ] 52 sources = [ "block.cc" ] 53} 54 55pw_source_set("freelist") { 56 public_configs = [ ":default_config" ] 57 configs = [ ":enable_heap_poison" ] 58 public = [ "public/pw_allocator/freelist.h" ] 59 public_deps = [ 60 "$dir_pw_containers:vector", 61 dir_pw_span, 62 dir_pw_status, 63 ] 64 sources = [ "freelist.cc" ] 65} 66 67pw_source_set("freelist_heap") { 68 public_configs = [ ":default_config" ] 69 configs = [ ":enable_heap_poison" ] 70 public = [ "public/pw_allocator/freelist_heap.h" ] 71 public_deps = [ 72 ":block", 73 ":freelist", 74 ] 75 deps = [ 76 dir_pw_assert, 77 dir_pw_log, 78 dir_pw_span, 79 ] 80 sources = [ "freelist_heap.cc" ] 81} 82 83pw_test_group("tests") { 84 tests = [ 85 ":block_test", 86 ":freelist_test", 87 ":freelist_heap_test", 88 ] 89} 90 91pw_test("block_test") { 92 configs = [ ":enable_heap_poison" ] 93 deps = [ 94 ":block", 95 dir_pw_span, 96 ] 97 sources = [ "block_test.cc" ] 98} 99 100pw_test("freelist_test") { 101 configs = [ ":enable_heap_poison" ] 102 deps = [ 103 ":freelist", 104 dir_pw_span, 105 dir_pw_status, 106 ] 107 sources = [ "freelist_test.cc" ] 108} 109 110pw_test("freelist_heap_test") { 111 configs = [ ":enable_heap_poison" ] 112 deps = [ ":freelist_heap" ] 113 sources = [ "freelist_heap_test.cc" ] 114} 115 116pw_doc_group("docs") { 117 inputs = [ "doc_resources/pw_allocator_heap_visualizer_demo.png" ] 118 sources = [ "docs.rst" ] 119} 120