pw_sys_io_stdio: Expand allowed uses beyond host

Select compatible targets via the constraint for the backend instead of
limiting to only hosts. There are embedded use cases where stdio output
makes sense (semi-hosting/simulators/etc).

Change-Id: I1d99dc054c808c8cfa1202422a596b210a745a18
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/208511
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Commit-Queue: Austin Foxley <afoxley@google.com>
diff --git a/pw_sys_io/BUILD.bazel b/pw_sys_io/BUILD.bazel
index 9bee6e0..ea6ce2d 100644
--- a/pw_sys_io/BUILD.bazel
+++ b/pw_sys_io/BUILD.bazel
@@ -24,6 +24,12 @@
 
 constraint_setting(
     name = "backend_constraint_setting",
+    default_constraint_value = "unspecified",
+)
+
+constraint_value(
+    name = "unspecified",
+    constraint_setting = ":backend_constraint_setting",
 )
 
 # TODO: pwbug.dev/328679085 - Remove this alias once no-one uses it.
@@ -69,6 +75,7 @@
         "//pw_sys_io_rp2040:backend": "@pigweed//pw_sys_io_rp2040",
         "//pw_sys_io_stm32cube:backend": "@pigweed//pw_sys_io_stm32cube",
         "//pw_sys_io_stdio:backend": "@pigweed//pw_sys_io_stdio",
+        ":unspecified": ":unspecified_backend",
         "//conditions:default": ":unspecified_backend",
     }),
     visibility = ["@pigweed//targets:__pkg__"],
diff --git a/pw_sys_io_stdio/BUILD.bazel b/pw_sys_io_stdio/BUILD.bazel
index 1121003..8bf1e54 100644
--- a/pw_sys_io_stdio/BUILD.bazel
+++ b/pw_sys_io_stdio/BUILD.bazel
@@ -12,11 +12,6 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
-load(
-    "//pw_build:selects.bzl",
-    "TARGET_COMPATIBLE_WITH_HOST_SELECT",
-)
-
 package(default_visibility = ["//visibility:public"])
 
 licenses(["notice"])
@@ -29,7 +24,11 @@
 cc_library(
     name = "pw_sys_io_stdio",
     srcs = ["sys_io.cc"],
-    target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
+    target_compatible_with = select({
+        ":backend": [],
+        "//pw_sys_io:unspecified": [],
+        "//conditions:default": ["@platforms//:incompatible"],
+    }),
     deps = [
         "//pw_sys_io:default_putget_bytes",
         "//pw_sys_io:pw_sys_io.facade",
diff --git a/pw_sys_io_stdio/docs.rst b/pw_sys_io_stdio/docs.rst
index eaa45af..b566b29 100644
--- a/pw_sys_io_stdio/docs.rst
+++ b/pw_sys_io_stdio/docs.rst
@@ -21,7 +21,12 @@
 This module requires relatively minimal setup:
 
 1. Write code against the ``pw_sys_io`` facade.
-2. Direct the ``pw_sys_io_BACKEND`` GN build arg to point to this backend.
+2. Setup build system to point to this backend.
+
+ - For GN, direct the ``pw_sys_io_BACKEND`` GN build arg to point here.
+ - For Bazel, the default backend multiplexer will automatically pick this stdio
+   backend for host builds. To use this backend on non-host platforms, add the
+   ``@pigweed//pw_sys_io_stdio:backend`` constraint_value to your platform.
 
 Module usage
 ============