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 15include($ENV{PW_ROOT}/pw_build/pigweed.cmake) 16include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake) 17 18pw_add_module_config(pw_tokenizer_CONFIG) 19 20pw_add_module_library(pw_tokenizer.config 21 HEADERS 22 public/pw_tokenizer/config.h 23 PUBLIC_INCLUDES 24 public 25 PUBLIC_DEPS 26 ${pw_tokenizer_CONFIG} 27) 28 29pw_add_module_library(pw_tokenizer 30 HEADERS 31 public/pw_tokenizer/encode_args.h 32 public/pw_tokenizer/hash.h 33 public/pw_tokenizer/tokenize.h 34 PUBLIC_INCLUDES 35 public 36 PUBLIC_DEPS 37 pw_containers 38 pw_polyfill.span 39 pw_preprocessor 40 pw_tokenizer.config 41 SOURCES 42 encode_args.cc 43 hash.cc 44 public/pw_tokenizer/internal/argument_types.h 45 public/pw_tokenizer/internal/argument_types_macro_4_byte.h 46 public/pw_tokenizer/internal/argument_types_macro_8_byte.h 47 public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h 48 public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_256_hash_macro.h 49 public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h 50 public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h 51 public/pw_tokenizer/internal/tokenize_string.h 52 tokenize.cc 53 PRIVATE_DEPS 54 pw_varint 55) 56 57if("${CMAKE_SYSTEM_NAME}" STREQUAL "") 58 target_link_options(pw_tokenizer 59 PUBLIC 60 "-T${CMAKE_CURRENT_SOURCE_DIR}/pw_tokenizer_linker_sections.ld" 61 ) 62elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") 63 target_link_options(pw_tokenizer 64 PUBLIC 65 "-T${CMAKE_CURRENT_SOURCE_DIR}/add_tokenizer_sections_to_default_script.ld" 66 "-L${CMAKE_CURRENT_SOURCE_DIR}" 67 ) 68endif() 69 70pw_add_module_library(pw_tokenizer.base64 71 HEADERS 72 public/pw_tokenizer/base64.h 73 PUBLIC_INCLUDES 74 public 75 PUBLIC_DEPS 76 pw_base64 77 pw_polyfill.cstddef 78 pw_polyfill.span 79 pw_tokenizer 80 pw_tokenizer.config 81 SOURCES 82 base64.cc 83) 84 85pw_add_module_library(pw_tokenizer.decoder 86 HEADERS 87 public/pw_tokenizer/detokenize.h 88 public/pw_tokenizer/token_database.h 89 PUBLIC_INCLUDES 90 public 91 PUBLIC_DEPS 92 pw_polyfill.span 93 pw_tokenizer 94 SOURCES 95 decode.cc 96 detokenize.cc 97 public/pw_tokenizer/internal/decode.h 98 token_database.cc 99 PRIVATE_DEPS 100 pw_varint 101) 102 103pw_add_facade(pw_tokenizer.global_handler 104 DEFAULT_BACKEND 105 pw_build.empty # Default to an empty backend so the tests can run. 106 HEADERS 107 public/pw_tokenizer/tokenize_to_global_handler.h 108 PUBLIC_INCLUDES 109 public 110 PUBLIC_DEPS 111 pw_preprocessor 112 pw_tokenizer 113 SOURCES 114 tokenize_to_global_handler.cc 115) 116 117pw_add_facade(pw_tokenizer.global_handler_with_payload 118 DEFAULT_BACKEND 119 pw_build.empty # Default to an empty backend so the tests can run. 120 HEADERS 121 public/pw_tokenizer/tokenize_to_global_handler_with_payload.h 122 PUBLIC_INCLUDES 123 public 124 PUBLIC_DEPS 125 pw_preprocessor 126 pw_tokenizer 127 SOURCES 128 tokenize_to_global_handler_with_payload.cc 129) 130 131pw_proto_library(pw_tokenizer.proto 132 SOURCES 133 options.proto 134 PREFIX 135 pw_tokenizer/proto 136) 137 138# Executable for generating test data for the C++ and Python detokenizers. This 139# target should only be built for the host. 140add_executable(pw_tokenizer.generate_decoding_test_data EXCLUDE_FROM_ALL 141 generate_decoding_test_data.cc) 142target_link_libraries(pw_tokenizer.generate_decoding_test_data PRIVATE 143 pw_varint pw_tokenizer) 144target_compile_options(pw_tokenizer.generate_decoding_test_data PRIVATE 145 -Wall -Werror) 146 147# Executable for generating a test ELF file for elf_reader_test.py. A host 148# version of this binary is checked in for use in elf_reader_test.py. 149add_executable(pw_tokenizer.elf_reader_test_binary EXCLUDE_FROM_ALL 150 py/elf_reader_test_binary.c) 151target_link_libraries(pw_tokenizer.elf_reader_test_binary PRIVATE 152 -Wl,--unresolved-symbols=ignore-all) # main is not defined 153set_target_properties(pw_tokenizer.elf_reader_test_binary PROPERTIES 154 OUTPUT_NAME elf_reader_test_binary.elf) 155 156pw_add_test(pw_tokenizer.argument_types_test 157 SOURCES 158 argument_types_test_c.c 159 argument_types_test.cc 160 DEPS 161 pw_tokenizer 162 GROUPS 163 modules 164 pw_tokenizer 165) 166 167pw_add_test(pw_tokenizer.base64_test 168 SOURCES 169 base64_test.cc 170 DEPS 171 pw_tokenizer.base64 172 GROUPS 173 modules 174 pw_tokenizer 175) 176 177pw_add_test(pw_tokenizer.decode_test 178 SOURCES 179 decode_test.cc 180 DEPS 181 pw_varint 182 pw_tokenizer.decoder 183 GROUPS 184 modules 185 pw_tokenizer 186) 187 188pw_add_test(pw_tokenizer.detokenize_test 189 SOURCES 190 detokenize_test.cc 191 DEPS 192 pw_tokenizer.decoder 193 GROUPS 194 modules 195 pw_tokenizer 196) 197 198pw_add_test(pw_tokenizer.global_handlers_test 199 SOURCES 200 global_handlers_test_c.c 201 global_handlers_test.cc 202 DEPS 203 pw_tokenizer.global_handler 204 pw_tokenizer.global_handler_with_payload 205 GROUPS 206 modules 207 pw_tokenizer 208) 209 210pw_add_test(pw_tokenizer.hash_test 211 SOURCES 212 hash_test.cc 213 DEPS 214 pw_tokenizer 215 GROUPS 216 modules 217 pw_tokenizer 218) 219 220pw_add_test(pw_tokenizer.token_database_test 221 SOURCES 222 token_database_test.cc 223 DEPS 224 pw_tokenizer.decoder 225 GROUPS 226 modules 227 pw_tokenizer 228) 229 230pw_add_test(pw_tokenizer.tokenize_test 231 SOURCES 232 tokenize_test_c.c 233 tokenize_test.cc 234 DEPS 235 pw_varint 236 pw_tokenizer 237 GROUPS 238 modules 239 pw_tokenizer 240) 241