Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 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 | |
Armando Montanez | fb3d3fb | 2020-06-09 18:12:12 -0700 | [diff] [blame] | 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 17 | import("$dir_pw_build/target_types.gni") |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 18 | import("$dir_pw_docgen/docs.gni") |
| 19 | import("$dir_pw_unit_test/test.gni") |
Wyatt Hepler | d49f8fe | 2020-10-15 10:13:47 -0700 | [diff] [blame] | 20 | |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 21 | declare_args() { |
| 22 | pw_allocator_POISON_HEAP = false |
| 23 | } |
| 24 | |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 25 | config("default_config") { |
| 26 | include_dirs = [ "public" ] |
| 27 | } |
| 28 | |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 29 | config("enable_heap_poison") { |
| 30 | if (pw_allocator_POISON_HEAP) { |
| 31 | defines = [ "PW_ALLOCATOR_POISON_ENABLE=1" ] |
| 32 | } |
| 33 | } |
| 34 | |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 35 | group("pw_allocator") { |
Chenghan Zhou | d4f44d2 | 2020-06-18 15:42:06 -0400 | [diff] [blame] | 36 | public_deps = [ |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 37 | ":block", |
| 38 | ":freelist", |
Jamie Garside | f65bb9c | 2020-04-02 11:17:20 +0100 | [diff] [blame] | 39 | ":freelist_heap", |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 40 | ] |
| 41 | } |
| 42 | |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 43 | pw_source_set("block") { |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 44 | public_configs = [ ":default_config" ] |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 45 | configs = [ ":enable_heap_poison" ] |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 46 | public = [ "public/pw_allocator/block.h" ] |
| 47 | public_deps = [ |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 48 | "$dir_pw_assert", |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 49 | "$dir_pw_status", |
| 50 | ] |
| 51 | sources = [ "block.cc" ] |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 54 | pw_source_set("freelist") { |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 55 | public_configs = [ ":default_config" ] |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 56 | configs = [ ":enable_heap_poison" ] |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 57 | public = [ "public/pw_allocator/freelist.h" ] |
| 58 | public_deps = [ |
Chenghan Zhou | d4f44d2 | 2020-06-18 15:42:06 -0400 | [diff] [blame] | 59 | "$dir_pw_containers:vector", |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 60 | "$dir_pw_status", |
| 61 | ] |
| 62 | sources = [ "freelist.cc" ] |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 65 | pw_source_set("freelist_heap") { |
Jamie Garside | f65bb9c | 2020-04-02 11:17:20 +0100 | [diff] [blame] | 66 | public_configs = [ ":default_config" ] |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 67 | configs = [ ":enable_heap_poison" ] |
Jamie Garside | f65bb9c | 2020-04-02 11:17:20 +0100 | [diff] [blame] | 68 | public = [ "public/pw_allocator/freelist_heap.h" ] |
| 69 | public_deps = [ |
| 70 | ":block", |
| 71 | ":freelist", |
Jamie Garside | f65bb9c | 2020-04-02 11:17:20 +0100 | [diff] [blame] | 72 | ] |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 73 | deps = [ |
| 74 | "$dir_pw_assert", |
| 75 | "$dir_pw_log", |
| 76 | ] |
Jamie Garside | f65bb9c | 2020-04-02 11:17:20 +0100 | [diff] [blame] | 77 | sources = [ "freelist_heap.cc" ] |
Jamie Garside | f65bb9c | 2020-04-02 11:17:20 +0100 | [diff] [blame] | 78 | } |
| 79 | |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 80 | pw_test_group("tests") { |
| 81 | tests = [ |
| 82 | ":block_test", |
| 83 | ":freelist_test", |
Jamie Garside | f65bb9c | 2020-04-02 11:17:20 +0100 | [diff] [blame] | 84 | ":freelist_heap_test", |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 85 | ] |
| 86 | } |
| 87 | |
| 88 | pw_test("block_test") { |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 89 | configs = [ ":enable_heap_poison" ] |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 90 | deps = [ ":block" ] |
| 91 | sources = [ "block_test.cc" ] |
| 92 | } |
| 93 | |
| 94 | pw_test("freelist_test") { |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 95 | configs = [ ":enable_heap_poison" ] |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 96 | deps = [ ":freelist" ] |
| 97 | sources = [ "freelist_test.cc" ] |
| 98 | } |
| 99 | |
Jamie Garside | f65bb9c | 2020-04-02 11:17:20 +0100 | [diff] [blame] | 100 | pw_test("freelist_heap_test") { |
Chenghan Zhou | ea0f7ad | 2020-07-29 18:20:37 -0400 | [diff] [blame] | 101 | configs = [ ":enable_heap_poison" ] |
Jamie Garside | f65bb9c | 2020-04-02 11:17:20 +0100 | [diff] [blame] | 102 | deps = [ ":freelist_heap" ] |
| 103 | sources = [ "freelist_heap_test.cc" ] |
| 104 | } |
| 105 | |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 106 | pw_doc_group("docs") { |
Chenghan Zhou | 091e312 | 2020-08-03 17:52:34 -0400 | [diff] [blame] | 107 | inputs = [ "doc_resources/pw_allocator_heap_visualizer_demo.png" ] |
Jamie Garside | 558e144 | 2020-03-27 17:05:55 +0000 | [diff] [blame] | 108 | sources = [ "docs.rst" ] |
| 109 | } |