Bazel and CMake build updates

- Build pw_log and pw_log_basic in Bazel and CMake.
- Use pw_log_basic as the hard-coded backend in Bazel.
- Give CMake auto added tests access to all of the module's
  dependencies.

Change-Id: I15ebb2958506f120c79ee6057fbef0fdcf090354
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a9b5e63..b7b5d46 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,7 @@
 add_subdirectory(pw_dumb_io)
 add_subdirectory(pw_dumb_io_stdio)
 add_subdirectory(pw_log)
+add_subdirectory(pw_log_basic)
 add_subdirectory(pw_polyfill)
 add_subdirectory(pw_preprocessor)
 add_subdirectory(pw_span)
diff --git a/pw_build/pigweed.cmake b/pw_build/pigweed.cmake
index e7c8315..920a52f 100644
--- a/pw_build/pigweed.cmake
+++ b/pw_build/pigweed.cmake
@@ -44,10 +44,12 @@
 #
 # Args:
 #   IMPLEMENTS_FACADE: this module implements the specified facade
+#   PUBLIC_DEPS: public target_link_libraries arguments
+#   PRIVATE_DEPS: private target_link_libraries arguments
 #
-# All other arguments are forwarded to pw_add_module_library.
 function(pw_auto_add_simple_module MODULE)
-  cmake_parse_arguments(PARSE_ARGV 1 arg "" "IMPLEMENTS_FACADE" "")
+  set(multi PUBLIC_DEPS PRIVATE_DEPS)
+  cmake_parse_arguments(PARSE_ARGV 1 arg "" "IMPLEMENTS_FACADE" "${multi}")
 
   file(GLOB all_sources *.cc *.c)
 
@@ -65,7 +67,10 @@
   endif()
 
   pw_add_module_library("${MODULE}"
-    ${arg_UNPARSED_ARGUMENTS}
+    PUBLIC_DEPS
+      ${arg_PUBLIC_DEPS}
+    PRIVATE_DEPS
+      ${arg_PRIVATE_DEPS}
     SOURCES
       ${sources}
     HEADERS
@@ -90,6 +95,8 @@
         ${c_test}
       DEPS
         "${MODULE}"
+        ${arg_PUBLIC_DEPS}
+        ${arg_PRIVATE_DEPS}
       GROUPS
         "${groups}"
     )
@@ -152,7 +159,6 @@
   target_link_libraries("${MODULE}"
     PUBLIC
       "${MODULE}.facade"
-    PRIVATE
       "${MODULE}.backend"
   )
 endfunction(pw_add_facade)
diff --git a/pw_log/BUILD b/pw_log/BUILD
index 6d89404..ee32845 100644
--- a/pw_log/BUILD
+++ b/pw_log/BUILD
@@ -12,23 +12,44 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
+load(
+    "//pw_build:pigweed.bzl",
+    "pw_cc_library",
+    "pw_cc_test",
+)
+
 package(default_visibility = ["//visibility:public"])
 
 licenses(["notice"])  # Apache License 2.0
 
-filegroup(
-    name = "pw_log",
-    srcs = [
-        "public/pw_log/log.h",
+# TODO(pwbug/101): Need to add support for facades/backends to Bazel.
+PW_LOG_BACKEND = "//pw_log_basic"
+
+pw_cc_library(
+    name = "facade",
+    hdrs = [
         "public/pw_log/levels.h",
+        "public/pw_log/log.h",
+    ],
+    includes = ["public"],
+    deps = [
+        "//pw_preprocessor",
     ],
 )
 
-# TODO: This isn't a real Bazel build yet.
-filegroup(
+pw_cc_library(
+    name = "pw_log",
+    deps = [
+        ":facade",
+        PW_LOG_BACKEND,
+    ],
+)
+
+pw_cc_test(
     name = "test",
     srcs = [
         "basic_log_test.cc",
         "basic_log_test_plain_c.c",
     ],
+    deps = [":pw_log"],
 )
diff --git a/pw_log_basic/BUILD b/pw_log_basic/BUILD
index 9430dd5..fd9105d 100644
--- a/pw_log_basic/BUILD
+++ b/pw_log_basic/BUILD
@@ -12,15 +12,31 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
+load(
+    "//pw_build:pigweed.bzl",
+    "pw_cc_library",
+)
+
 package(default_visibility = ["//visibility:public"])
 
 licenses(["notice"])  # Apache License 2.0
 
-filegroup(
+pw_cc_library(
     name = "pw_log_basic",
     srcs = [
+        "log_basic.cc",
+    ],
+    hdrs = [
         "public/pw_log_basic/log_basic.h",
         "public_overrides/pw_log_backend/log_backend.h",
-        "log_basic.cc",
+    ],
+    includes = [
+        "public",
+        "public_overrides",
+    ],
+    deps = [
+        "//pw_dumb_io",
+        "//pw_log:facade",
+        "//pw_string",
     ],
 )
diff --git a/pw_log_basic/CMakeLists.txt b/pw_log_basic/CMakeLists.txt
new file mode 100644
index 0000000..c85276d
--- /dev/null
+++ b/pw_log_basic/CMakeLists.txt
@@ -0,0 +1,27 @@
+# Copyright 2020 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+pw_auto_add_simple_module(pw_log_basic
+  IMPLEMENTS_FACADE
+    pw_log
+  PRIVATE_DEPS
+    pw_dumb_io
+    pw_string
+)
+
+target_include_directories(pw_log_basic PUBLIC public_overrides)
+
+# TODO(hepler): Declare pw_log_basic as the pw_log backend for now.
+add_library(pw_log.backend INTERFACE)
+target_link_libraries(pw_log.backend INTERFACE pw_log_basic)