diff options
Diffstat (limited to 'pw_tokenizer/BUILD.gn')
-rw-r--r-- | pw_tokenizer/BUILD.gn | 166 |
1 files changed, 65 insertions, 101 deletions
diff --git a/pw_tokenizer/BUILD.gn b/pw_tokenizer/BUILD.gn index 269419edf..fc276f456 100644 --- a/pw_tokenizer/BUILD.gn +++ b/pw_tokenizer/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/pigweed.gni") import("$dir_pw_arduino_build/arduino.gni") -import("$dir_pw_build/facade.gni") +import("$dir_pw_bloat/bloat.gni") import("$dir_pw_build/module_config.gni") import("$dir_pw_build/target_types.gni") import("$dir_pw_docgen/docs.gni") @@ -37,7 +37,11 @@ config("public_include_path") { } config("linker_script") { - inputs = [ "pw_tokenizer_linker_sections.ld" ] + inputs = [ + "pw_tokenizer_linker_sections.ld", + "pw_tokenizer_linker_rules.ld", + ] + lib_dirs = [ "." ] # Automatically add the tokenizer linker sections when cross-compiling or # building for Linux. macOS and Windows executables are not supported. @@ -56,7 +60,6 @@ config("linker_script") { rebase_path("add_tokenizer_sections_to_default_script.ld", root_build_dir), ] - lib_dirs = [ "." ] inputs += [ "add_tokenizer_sections_to_default_script.ld" ] } @@ -75,7 +78,9 @@ pw_source_set("pw_tokenizer") { public_deps = [ ":config", "$dir_pw_containers:to_array", + dir_pw_polyfill, dir_pw_preprocessor, + dir_pw_span, ] deps = [ dir_pw_varint ] public = [ @@ -99,57 +104,34 @@ pw_source_set("pw_tokenizer") { friend = [ ":*" ] } -# As a temporary workaround, if no backend is set, use an empty test backend so -# that the test can define the handler function. -# TODO(hepler): Switch this to a facade test when available. -if (pw_tokenizer_GLOBAL_HANDLER_BACKEND == "" && - pw_tokenizer_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND == "") { - # This is an empty library to use as the backend for global_handler and - # global_handler_with_payload tests. - pw_source_set("test_backend") { - visibility = [ ":*" ] - } - - pw_tokenizer_GLOBAL_HANDLER_BACKEND = ":test_backend" - pw_tokenizer_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND = ":test_backend" - - enable_global_handler_test = true -} else { - enable_global_handler_test = false -} - -pw_facade("global_handler") { - backend = pw_tokenizer_GLOBAL_HANDLER_BACKEND - - public_configs = [ ":public_include_path" ] - public = [ "public/pw_tokenizer/tokenize_to_global_handler.h" ] - sources = [ "tokenize_to_global_handler.cc" ] - public_deps = [ ":pw_tokenizer" ] -} - -pw_facade("global_handler_with_payload") { - backend = pw_tokenizer_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND - - public_configs = [ ":public_include_path" ] - public = [ "public/pw_tokenizer/tokenize_to_global_handler_with_payload.h" ] - sources = [ "tokenize_to_global_handler_with_payload.cc" ] - public_deps = [ ":pw_tokenizer" ] -} - pw_source_set("base64") { public_configs = [ ":public_include_path" ] public = [ "public/pw_tokenizer/base64.h" ] sources = [ "base64.cc" ] public_deps = [ ":pw_tokenizer", + "$dir_pw_string:string", dir_pw_base64, dir_pw_preprocessor, ] } +# TODO(hepler): Remove this backwards compatibility header after projects have +# migrated. +pw_source_set("global_handler_with_payload") { + public_configs = [ ":public_include_path" ] + public = [ "public/pw_tokenizer/tokenize_to_global_handler_with_payload.h" ] + public_deps = [ dir_pw_preprocessor ] +} + pw_source_set("decoder") { public_configs = [ ":public_include_path" ] - deps = [ dir_pw_varint ] + public_deps = [ dir_pw_span ] + deps = [ + "$dir_pw_bytes:bit", + dir_pw_bytes, + dir_pw_varint, + ] public = [ "public/pw_tokenizer/detokenize.h", "public/pw_tokenizer/token_database.h", @@ -190,19 +172,25 @@ pw_test_group("tests") { ":argument_types_test", ":base64_test", ":decode_test", - ":detokenize_fuzzer", + ":detokenize_fuzzer_test", ":detokenize_test", - ":global_handlers_test", + ":encode_args_test", ":hash_test", - ":simple_tokenize_test_cpp14", - ":simple_tokenize_test_cpp17", - ":token_database_fuzzer", + ":simple_tokenize_test", + ":token_database_fuzzer_test", ":token_database_test", ":tokenize_test", ] group_deps = [ "$dir_pw_preprocessor:tests" ] } +group("fuzzers") { + deps = [ + ":detokenize_fuzzer", + ":token_database_fuzzer", + ] +} + pw_test("argument_types_test") { sources = [ "argument_types_test.cc", @@ -218,7 +206,10 @@ pw_test("argument_types_test") { pw_test("base64_test") { sources = [ "base64_test.cc" ] - deps = [ ":base64" ] + deps = [ + ":base64", + dir_pw_span, + ] } pw_test("decode_test") { @@ -246,19 +237,9 @@ pw_test("detokenize_test") { enable_if = pw_build_EXECUTABLE_TARGET_TYPE != "arduino_executable" } -pw_test("global_handlers_test") { - sources = [ - "global_handlers_test.cc", - "global_handlers_test_c.c", - "pw_tokenizer_private/tokenize_test.h", - ] - deps = [ - ":global_handler", - ":global_handler_with_payload", - ] - - # TODO(hepler): Switch this to a facade test when available. - enable_if = enable_global_handler_test +pw_test("encode_args_test") { + sources = [ "encode_args_test.cc" ] + deps = [ ":pw_tokenizer" ] } pw_test("hash_test") { @@ -269,47 +250,9 @@ pw_test("hash_test") { deps = [ ":pw_tokenizer" ] } -# Fully test C++14 compatibility by compiling all sources as C++14. -_simple_tokenize_test_sources = [ - "$dir_pw_containers/public/pw_containers/to_array.h", - "$dir_pw_varint/public/pw_varint/varint.h", - "$dir_pw_varint/varint.cc", - "encode_args.cc", - "public/pw_tokenizer/config.h", - "public/pw_tokenizer/encode_args.h", - "public/pw_tokenizer/hash.h", - "public/pw_tokenizer/internal/argument_types.h", - "public/pw_tokenizer/internal/argument_types_macro_4_byte.h", - "public/pw_tokenizer/internal/argument_types_macro_8_byte.h", - "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h", - "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h", - "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h", - "public/pw_tokenizer/internal/tokenize_string.h", - "public/pw_tokenizer/tokenize.h", - "public/pw_tokenizer/tokenize_to_global_handler.h", - "public/pw_tokenizer/tokenize_to_global_handler_with_payload.h", - "simple_tokenize_test.cc", - "tokenize.cc", - "tokenize_to_global_handler.cc", - "tokenize_to_global_handler_with_payload.cc", -] -_simple_tokenize_test_configs = [ - ":public_include_path", - "$dir_pw_varint:default_config", - "$dir_pw_containers:public_include_path", -] - -pw_test("simple_tokenize_test_cpp14") { - remove_configs = [ "$dir_pw_build:cpp17" ] - configs = [ "$dir_pw_build:cpp14" ] + _simple_tokenize_test_configs - sources = _simple_tokenize_test_sources - deps = [ dir_pw_preprocessor ] -} - -pw_test("simple_tokenize_test_cpp17") { - configs = _simple_tokenize_test_configs - sources = _simple_tokenize_test_sources - deps = [ dir_pw_preprocessor ] +pw_test("simple_tokenize_test") { + sources = [ "simple_tokenize_test.cc" ] + deps = [ ":pw_tokenizer" ] } pw_test("token_database_test") { @@ -335,7 +278,9 @@ pw_fuzzer("token_database_fuzzer") { ":decoder", "$dir_pw_fuzzer", "$dir_pw_preprocessor", + dir_pw_span, ] + enable_test_if = false } pw_fuzzer("detokenize_fuzzer") { @@ -379,6 +324,7 @@ pw_shared_library("detokenizer_jni") { ":decoder", "$dir_pw_preprocessor", ] + deps = [ dir_pw_span ] } pw_doc_group("docs") { @@ -387,4 +333,22 @@ pw_doc_group("docs") { "proto.rst", ] inputs = [ "py/pw_tokenizer/encode.py" ] + report_deps = [ ":tokenizer_size_report" ] +} + +# Pigweed tokenizer size report. +pw_size_diff("tokenizer_size_report") { + title = "Pigweed tokenizer size report" + binaries = [ + { + target = "size_report:tokenize_string" + base = "size_report:tokenize_string_base" + label = "tokenize a string" + }, + { + target = "size_report:tokenize_string_expr" + base = "size_report:tokenize_string_expr_base" + label = "tokenize a string expression" + }, + ] } |