blob: c25bb4c123c0547b6e9a7e952215f7d995e535fc [file] [log] [blame]
Jamie Garside558e1442020-03-27 17:05:55 +00001# 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 Montanezfb3d3fb2020-06-09 18:12:12 -070015import("//build_overrides/pigweed.gni")
16
Alexei Frolovedd2f142020-06-09 19:11:27 -070017import("$dir_pw_build/target_types.gni")
Jamie Garside558e1442020-03-27 17:05:55 +000018import("$dir_pw_docgen/docs.gni")
19import("$dir_pw_unit_test/test.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070020
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -040021declare_args() {
22 pw_allocator_POISON_HEAP = false
23}
24
Jamie Garside558e1442020-03-27 17:05:55 +000025config("default_config") {
26 include_dirs = [ "public" ]
27}
28
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -040029config("enable_heap_poison") {
30 if (pw_allocator_POISON_HEAP) {
31 defines = [ "PW_ALLOCATOR_POISON_ENABLE=1" ]
32 }
33}
34
Jamie Garside558e1442020-03-27 17:05:55 +000035group("pw_allocator") {
Chenghan Zhoud4f44d22020-06-18 15:42:06 -040036 public_deps = [
Jamie Garside558e1442020-03-27 17:05:55 +000037 ":block",
38 ":freelist",
Jamie Garsidef65bb9c2020-04-02 11:17:20 +010039 ":freelist_heap",
Jamie Garside558e1442020-03-27 17:05:55 +000040 ]
41}
42
Alexei Frolovedd2f142020-06-09 19:11:27 -070043pw_source_set("block") {
Jamie Garside558e1442020-03-27 17:05:55 +000044 public_configs = [ ":default_config" ]
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -040045 configs = [ ":enable_heap_poison" ]
Jamie Garside558e1442020-03-27 17:05:55 +000046 public = [ "public/pw_allocator/block.h" ]
47 public_deps = [
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -040048 "$dir_pw_assert",
Jamie Garside558e1442020-03-27 17:05:55 +000049 "$dir_pw_status",
50 ]
51 sources = [ "block.cc" ]
Jamie Garside558e1442020-03-27 17:05:55 +000052}
53
Alexei Frolovedd2f142020-06-09 19:11:27 -070054pw_source_set("freelist") {
Jamie Garside558e1442020-03-27 17:05:55 +000055 public_configs = [ ":default_config" ]
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -040056 configs = [ ":enable_heap_poison" ]
Jamie Garside558e1442020-03-27 17:05:55 +000057 public = [ "public/pw_allocator/freelist.h" ]
58 public_deps = [
Chenghan Zhoud4f44d22020-06-18 15:42:06 -040059 "$dir_pw_containers:vector",
Jamie Garside558e1442020-03-27 17:05:55 +000060 "$dir_pw_status",
61 ]
62 sources = [ "freelist.cc" ]
Jamie Garside558e1442020-03-27 17:05:55 +000063}
64
Alexei Frolovedd2f142020-06-09 19:11:27 -070065pw_source_set("freelist_heap") {
Jamie Garsidef65bb9c2020-04-02 11:17:20 +010066 public_configs = [ ":default_config" ]
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -040067 configs = [ ":enable_heap_poison" ]
Jamie Garsidef65bb9c2020-04-02 11:17:20 +010068 public = [ "public/pw_allocator/freelist_heap.h" ]
69 public_deps = [
70 ":block",
71 ":freelist",
Jamie Garsidef65bb9c2020-04-02 11:17:20 +010072 ]
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -040073 deps = [
74 "$dir_pw_assert",
75 "$dir_pw_log",
76 ]
Jamie Garsidef65bb9c2020-04-02 11:17:20 +010077 sources = [ "freelist_heap.cc" ]
Jamie Garsidef65bb9c2020-04-02 11:17:20 +010078}
79
Jamie Garside558e1442020-03-27 17:05:55 +000080pw_test_group("tests") {
81 tests = [
82 ":block_test",
83 ":freelist_test",
Jamie Garsidef65bb9c2020-04-02 11:17:20 +010084 ":freelist_heap_test",
Jamie Garside558e1442020-03-27 17:05:55 +000085 ]
86}
87
88pw_test("block_test") {
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -040089 configs = [ ":enable_heap_poison" ]
Jamie Garside558e1442020-03-27 17:05:55 +000090 deps = [ ":block" ]
91 sources = [ "block_test.cc" ]
92}
93
94pw_test("freelist_test") {
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -040095 configs = [ ":enable_heap_poison" ]
Jamie Garside558e1442020-03-27 17:05:55 +000096 deps = [ ":freelist" ]
97 sources = [ "freelist_test.cc" ]
98}
99
Jamie Garsidef65bb9c2020-04-02 11:17:20 +0100100pw_test("freelist_heap_test") {
Chenghan Zhouea0f7ad2020-07-29 18:20:37 -0400101 configs = [ ":enable_heap_poison" ]
Jamie Garsidef65bb9c2020-04-02 11:17:20 +0100102 deps = [ ":freelist_heap" ]
103 sources = [ "freelist_heap_test.cc" ]
104}
105
Jamie Garside558e1442020-03-27 17:05:55 +0000106pw_doc_group("docs") {
Chenghan Zhou091e3122020-08-03 17:52:34 -0400107 inputs = [ "doc_resources/pw_allocator_heap_visualizer_demo.png" ]
Jamie Garside558e1442020-03-27 17:05:55 +0000108 sources = [ "docs.rst" ]
109}