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_status", 50 ] 51 sources = [ "block.cc" ] 52} 53 54pw_source_set("freelist") { 55 public_configs = [ ":default_config" ] 56 configs = [ ":enable_heap_poison" ] 57 public = [ "public/pw_allocator/freelist.h" ] 58 public_deps = [ 59 "$dir_pw_containers:vector", 60 "$dir_pw_status", 61 ] 62 sources = [ "freelist.cc" ] 63} 64 65pw_source_set("freelist_heap") { 66 public_configs = [ ":default_config" ] 67 configs = [ ":enable_heap_poison" ] 68 public = [ "public/pw_allocator/freelist_heap.h" ] 69 public_deps = [ 70 ":block", 71 ":freelist", 72 ] 73 deps = [ 74 "$dir_pw_assert", 75 "$dir_pw_log", 76 ] 77 sources = [ "freelist_heap.cc" ] 78} 79 80pw_test_group("tests") { 81 tests = [ 82 ":block_test", 83 ":freelist_test", 84 ":freelist_heap_test", 85 ] 86} 87 88pw_test("block_test") { 89 configs = [ ":enable_heap_poison" ] 90 deps = [ ":block" ] 91 sources = [ "block_test.cc" ] 92} 93 94pw_test("freelist_test") { 95 configs = [ ":enable_heap_poison" ] 96 deps = [ ":freelist" ] 97 sources = [ "freelist_test.cc" ] 98} 99 100pw_test("freelist_heap_test") { 101 configs = [ ":enable_heap_poison" ] 102 deps = [ ":freelist_heap" ] 103 sources = [ "freelist_heap_test.cc" ] 104} 105 106pw_doc_group("docs") { 107 inputs = [ "doc_resources/pw_allocator_heap_visualizer_demo.png" ] 108 sources = [ "docs.rst" ] 109} 110