1 # Copyright 2020 The Pigweed Authors
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
7 # https://www.apache.org/licenses/LICENSE-2.0
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
15 include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
17 pw_add_module_library(pw_tokenizer
30 if("${CMAKE_SYSTEM_NAME}" STREQUAL "")
31 target_link_options(pw_tokenizer
33 "-T${CMAKE_CURRENT_SOURCE_DIR}/pw_tokenizer_linker_sections.ld"
35 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
36 target_link_options(pw_tokenizer
38 "-T${CMAKE_CURRENT_SOURCE_DIR}/add_tokenizer_sections_to_default_script.ld"
39 "-L${CMAKE_CURRENT_SOURCE_DIR}"
43 pw_add_module_library(pw_tokenizer.base64
54 pw_add_module_library(pw_tokenizer.decoder
66 pw_add_facade(pw_tokenizer.global_handler
68 tokenize_to_global_handler.cc
72 pw_build.empty # Default to an empty backend so the tests can run.
75 pw_add_facade(pw_tokenizer.global_handler_with_payload
77 tokenize_to_global_handler_with_payload.cc
81 pw_build.empty # Default to an empty backend so the tests can run.
84 # Executable for generating test data for the C++ and Python detokenizers. This
85 # target should only be built for the host.
86 add_executable(pw_tokenizer.generate_decoding_test_data EXCLUDE_FROM_ALL
87 generate_decoding_test_data.cc)
88 target_link_libraries(pw_tokenizer.generate_decoding_test_data PRIVATE
89 pw_varint pw_tokenizer)
90 target_compile_options(pw_tokenizer.generate_decoding_test_data PRIVATE
93 # Executable for generating a test ELF file for elf_reader_test.py. A host
94 # version of this binary is checked in for use in elf_reader_test.py.
95 add_executable(pw_tokenizer.elf_reader_test_binary EXCLUDE_FROM_ALL
96 py/elf_reader_test_binary.c)
97 target_link_libraries(pw_tokenizer.elf_reader_test_binary PRIVATE
98 -Wl,--unresolved-symbols=ignore-all) # main is not defined
99 set_target_properties(pw_tokenizer.elf_reader_test_binary PROPERTIES
100 OUTPUT_NAME elf_reader_test_binary.elf)
102 pw_add_test(pw_tokenizer.argument_types_test
104 argument_types_test_c.c
105 argument_types_test.cc
113 pw_add_test(pw_tokenizer.base64_test
123 pw_add_test(pw_tokenizer.decode_test
134 pw_add_test(pw_tokenizer.detokenize_test
144 pw_add_test(pw_tokenizer.global_handlers_test
146 global_handlers_test_c.c
147 global_handlers_test.cc
149 pw_tokenizer.global_handler
150 pw_tokenizer.global_handler_with_payload
156 pw_add_test(pw_tokenizer.hash_test
166 pw_add_test(pw_tokenizer.token_database_test
168 token_database_test.cc
176 pw_add_test(pw_tokenizer.tokenize_test