pw_tokenizer: Use facades for global handlers

Previously, pw_tokenizer conditionally enabled the global handlers with
macros. The default was that they were enabled, which meant handlers had
to be defined, even if they weren't used.

This change moves the two global handlers from the core pw_tokenizer
library to separate facades. This allows projects to define only the
global handlers they need.

Change-Id: Ic8598d9e62921b706fa0b76032b2a14265669360
diff --git a/pw_tokenizer/BUILD b/pw_tokenizer/BUILD
index fc944f6..3de81eb 100644
--- a/pw_tokenizer/BUILD
+++ b/pw_tokenizer/BUILD
@@ -26,6 +26,7 @@
 pw_cc_library(
     name = "pw_tokenizer",
     srcs = [
+        "encode_args.cc",
         "public/pw_tokenizer/config.h",
         "public/pw_tokenizer/internal/argument_types.h",
         "public/pw_tokenizer/internal/argument_types_macro_4_byte.h",
@@ -34,6 +35,7 @@
         "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",
+        "pw_tokenizer_private/encode_args.h",
         "tokenize.cc",
     ],
     hdrs = [
@@ -49,6 +51,36 @@
     ],
 )
 
+# TODO(pwbug/101): Need to add support for facades/backends to Bazel.
+PW_TOKENIZER_GLOBAL_HANDLER_BACKEND = "//pw_tokenizer:test_backend"
+
+PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND = "//pw_tokenizer:test_backend"
+
+pw_cc_library(
+    name = "test_backend",
+    visibility = ["//visibility:private"],
+)
+
+pw_cc_library(
+    name = "global_handler",
+    srcs = ["tokenize_to_global_handler.cc"],
+    hdrs = ["public/pw_tokenizer/tokenize_to_global_handler.h"],
+    deps = [
+        ":pw_tokenizer",
+        PW_TOKENIZER_GLOBAL_HANDLER_BACKEND,
+    ],
+)
+
+pw_cc_library(
+    name = "global_handler_with_payload",
+    srcs = ["tokenize_to_global_handler_with_payload.cc"],
+    hdrs = ["public/pw_tokenizer/tokenize_to_global_handler_with_payload.h"],
+    deps = [
+        ":pw_tokenizer",
+        PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND,
+    ],
+)
+
 pw_cc_library(
     name = "base64",
     srcs = [
@@ -168,6 +200,19 @@
 )
 
 pw_cc_test(
+    name = "global_handlers_test",
+    srcs = [
+        "global_handlers_test.c",
+        "global_handlers_test.cc",
+        "pw_tokenizer_private/tokenize_test.h",
+    ],
+    deps = [
+        ":global_handler",
+        ":global_handler_with_payload",
+    ],
+)
+
+pw_cc_test(
     name = "hash_test",
     srcs = [
         "hash_test.cc",