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_bloat/bloat.gni") 18import("$dir_pw_build/module_config.gni") 19import("$dir_pw_build/target_types.gni") 20import("$dir_pw_docgen/docs.gni") 21import("$dir_pw_perf_test/perf_test.gni") 22import("$dir_pw_unit_test/test.gni") 23 24declare_args() { 25 # The build target that overrides the default configuration options for this 26 # module. This should point to a source set that provides defines through a 27 # public config (which may -include a file or add defines directly). 28 pw_checksum_CONFIG = pw_build_DEFAULT_MODULE_CONFIG 29} 30 31config("public_include_path") { 32 include_dirs = [ "public" ] 33} 34 35pw_source_set("config") { 36 sources = [ "public/pw_checksum/internal/config.h" ] 37 public_configs = [ ":public_include_path" ] 38 public_deps = [ pw_checksum_CONFIG ] 39 visibility = [ ":*" ] # Only allow this module to depend on ":config" 40 friend = [ ":*" ] # Allow this module to access the config.h header. 41} 42 43pw_source_set("pw_checksum") { 44 public_configs = [ ":public_include_path" ] 45 public = [ 46 "public/pw_checksum/crc16_ccitt.h", 47 "public/pw_checksum/crc32.h", 48 ] 49 sources = [ 50 "crc16_ccitt.cc", 51 "crc32.cc", 52 ] 53 public_deps = [ 54 ":config", 55 dir_pw_bytes, 56 dir_pw_span, 57 ] 58 59 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 60 configs = [ "$dir_pw_build:conversion_warnings" ] 61} 62 63pw_test_group("tests") { 64 tests = [ 65 ":crc16_ccitt_test", 66 ":crc32_test", 67 ] 68} 69 70pw_test("crc16_ccitt_test") { 71 deps = [ 72 ":pw_checksum", 73 dir_pw_bytes, 74 ] 75 sources = [ 76 "crc16_ccitt_test.cc", 77 "crc16_ccitt_test_c.c", 78 ] 79 80 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 81 configs = [ "$dir_pw_build:conversion_warnings" ] 82} 83 84pw_test("crc32_test") { 85 deps = [ 86 ":pw_checksum", 87 dir_pw_bytes, 88 ] 89 sources = [ 90 "crc32_test.cc", 91 "crc32_test_c.c", 92 ] 93 94 # TODO: b/259746255 - Remove this when everything compiles with -Wconversion. 95 configs = [ "$dir_pw_build:conversion_warnings" ] 96} 97 98pw_perf_test("crc32_perf_tests") { 99 enable_if = pw_perf_test_TIMER_INTERFACE_BACKEND != "" 100 deps = [ 101 ":pw_checksum", 102 dir_pw_bytes, 103 ] 104 sources = [ "crc32_perf_test.cc" ] 105} 106 107pw_perf_test("crc16_perf_tests") { 108 enable_if = pw_perf_test_TIMER_INTERFACE_BACKEND != "" 109 deps = [ 110 ":pw_checksum", 111 dir_pw_bytes, 112 ] 113 sources = [ "crc16_ccitt_perf_test.cc" ] 114} 115 116group("perf_tests") { 117 deps = [ 118 ":crc16_perf_tests", 119 ":crc32_perf_tests", 120 ] 121} 122 123pw_size_diff("size_report") { 124 title = "Checksum sizes" 125 126 binaries = [ 127 { 128 target = "size_report:crc16_checksum" 129 base = "size_report:noop_checksum" 130 label = "CRC16 with 256-entry table" 131 }, 132 { 133 target = "size_report:crc32_8bit_checksum" 134 base = "size_report:noop_checksum" 135 label = "CRC32: 8 bits per iteration, 256-entry table" 136 }, 137 { 138 target = "size_report:crc32_4bit_checksum" 139 base = "size_report:noop_checksum" 140 label = "CRC32: 4 bits per iteration, 16-entry table" 141 }, 142 { 143 target = "size_report:crc32_1bit_checksum" 144 base = "size_report:noop_checksum" 145 label = "CRC32: 1 bit per iteration, no table" 146 }, 147 { 148 target = "size_report:fletcher16_checksum" 149 base = "size_report:noop_checksum" 150 label = "Fletcher16 (illustrative only)" 151 }, 152 ] 153} 154 155pw_doc_group("docs") { 156 inputs = [ "Kconfig" ] 157 sources = [ "docs.rst" ] 158 report_deps = [ ":size_report" ] 159} 160