pw_tokenizer: Make the module configurable

Expose the configuration header with a facade (pw_tokenizer_CONFIG).

Change-Id: I7577ae0a76e2a56bdfb15e978a7151992f2c8776
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21360
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
diff --git a/pw_tokenizer/BUILD.gn b/pw_tokenizer/BUILD.gn
index 4090546..1f7e442 100644
--- a/pw_tokenizer/BUILD.gn
+++ b/pw_tokenizer/BUILD.gn
@@ -16,19 +16,35 @@
 
 import("$dir_pw_arduino_build/arduino.gni")
 import("$dir_pw_build/facade.gni")
+import("$dir_pw_build/module_config.gni")
 import("$dir_pw_build/target_types.gni")
 import("$dir_pw_docgen/docs.gni")
 import("$dir_pw_fuzzer/fuzzer.gni")
 import("$dir_pw_unit_test/test.gni")
 import("backend.gni")
 
-config("default_config") {
+declare_args() {
+  # The build target that overrides the default configuration options for this
+  # module. This should point to a source set that provides defines through a
+  # public config (which may -include a file or add defines directly).
+  pw_tokenizer_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
+}
+
+config("public_include_path") {
   include_dirs = [ "public" ]
+  visibility = [ ":*" ]
+}
+
+pw_source_set("config") {
+  public = [ "public/pw_tokenizer/config.h" ]
+  public_configs = [ ":public_include_path" ]
+  public_deps = [ pw_tokenizer_CONFIG ]
 }
 
 pw_source_set("pw_tokenizer") {
-  public_configs = [ ":default_config" ]
+  public_configs = [ ":public_include_path" ]
   public_deps = [
+    ":config",
     dir_pw_preprocessor,
     dir_pw_span,
   ]
@@ -39,7 +55,6 @@
   ]
   sources = [
     "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",
     "public/pw_tokenizer/internal/argument_types_macro_8_byte.h",
@@ -76,7 +91,7 @@
   facade_name = "global_handler_facade"
   backend = pw_tokenizer_GLOBAL_HANDLER_BACKEND
 
-  public_configs = [ ":default_config" ]
+  public_configs = [ ":public_include_path" ]
   public = [ "public/pw_tokenizer/tokenize_to_global_handler.h" ]
   sources = [ "tokenize_to_global_handler.cc" ]
   public_deps = [ ":pw_tokenizer" ]
@@ -86,14 +101,14 @@
   facade_name = "global_handler_with_payload_facade"
   backend = pw_tokenizer_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND
 
-  public_configs = [ ":default_config" ]
+  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 = [ ":default_config" ]
+  public_configs = [ ":public_include_path" ]
   public = [ "public/pw_tokenizer/base64.h" ]
   sources = [ "base64.cc" ]
   public_deps = [
@@ -106,7 +121,7 @@
 }
 
 pw_source_set("decoder") {
-  public_configs = [ ":default_config" ]
+  public_configs = [ ":public_include_path" ]
   public_deps = [ dir_pw_span ]
   deps = [ dir_pw_varint ]
   public = [
@@ -249,7 +264,7 @@
   "tokenize_to_global_handler_with_payload.cc",
 ]
 _simple_tokenize_test_configs = [
-  ":default_config",
+  ":public_include_path",
   "$dir_pw_varint:default_config",
 ]
 
@@ -328,7 +343,7 @@
 # the JNI headers must be available in the system or provided with the
 # pw_JAVA_NATIVE_INTERFACE_INCLUDE_DIRS variable.
 pw_shared_library("detokenizer_jni") {
-  public_configs = [ ":default_config" ]
+  public_configs = [ ":public_include_path" ]
   include_dirs = pw_JAVA_NATIVE_INTERFACE_INCLUDE_DIRS
   sources = [ "java/dev/pigweed/tokenizer/detokenizer.cc" ]
   public_deps = [
diff --git a/pw_tokenizer/public/pw_tokenizer/config.h b/pw_tokenizer/public/pw_tokenizer/config.h
index c4f34c8..3d4fe62 100644
--- a/pw_tokenizer/public/pw_tokenizer/config.h
+++ b/pw_tokenizer/public/pw_tokenizer/config.h
@@ -16,9 +16,6 @@
 #pragma once
 
 #include <assert.h>
-#include <stdint.h>
-
-// TODO(pwbug/17): Configure these options in the config system.
 
 // For a tokenized string that has arguments, the types of the arguments are
 // encoded in either a 4-byte (uint32_t) or a 8-byte (uint64_t) value. The 4 or