aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmando Montanez <amontanez@google.com>2022-12-01 21:41:53 +0000
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-12-01 21:41:53 +0000
commitdb776ce778ada38bc16dd670f100a46501ae7402 (patch)
treea54f7b06a70ff7aca89b20cc8e54fb9c11d923c1
parente78828a82847c94148757d0a4b1814049903a23c (diff)
downloadpigweed-db776ce778ada38bc16dd670f100a46501ae7402.tar.gz
pw_system: Get building with Bazel
Gets pw_system building for host under Bazel. Bug: b/257539200 Change-Id: I5432b143478ea1721a3341b480919e9a0cc45e20 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/121399 Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com> Reviewed-by: Ted Pudlik <tpudlik@google.com> Pigweed-Auto-Submit: Armando Montanez <amontanez@google.com>
-rwxr-xr-xpw_presubmit/py/pw_presubmit/pigweed_presubmit.py1
-rw-r--r--pw_system/BUILD.bazel56
-rw-r--r--pw_thread/BUILD.bazel13
-rw-r--r--targets/default_config.BUILD10
4 files changed, 66 insertions, 14 deletions
diff --git a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
index 7703228b4..3e9572330 100755
--- a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
+++ b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
@@ -476,7 +476,6 @@ _TARGETS_THAT_DO_NOT_BUILD_WITH_BAZEL = (
'-//pw_boot/...:all',
'-//pw_chrono/py/...:all',
'-//pw_chrono:chrono_proto_pb2',
- '-//pw_system/...:all',
'-//pw_thread/py/...:all',
'-//pw_work_queue/...:all',
'-//targets/stm32f429i_disc1_stm32cube/...:all',
diff --git a/pw_system/BUILD.bazel b/pw_system/BUILD.bazel
index f51d1ee13..6d753a3a2 100644
--- a/pw_system/BUILD.bazel
+++ b/pw_system/BUILD.bazel
@@ -22,10 +22,6 @@ package(default_visibility = ["//visibility:public"])
licenses(["notice"])
-# WARNING: Many of the dependencies in this file are missing and need to be
-# added/updated. This is provided as a starting point, but currently does not
-# work.
-
pw_cc_library(
name = "config",
hdrs = [
@@ -66,7 +62,8 @@ pw_cc_library(
"//pw_log:facade",
"//pw_log:proto_utils",
"//pw_log_string:handler_facade",
- "//pw_log_tokenized:metadata",
+ "//pw_log_tokenized:headers",
+ "//pw_metric:global",
"//pw_multisink",
"//pw_result",
"//pw_string",
@@ -77,14 +74,22 @@ pw_cc_library(
)
pw_cc_library(
- name = "rpc_server",
+ name = "rpc_server_headers",
hdrs = [
"public/pw_system/rpc_server.h",
],
includes = ["public"],
deps = [
":config",
+ ],
+)
+
+pw_cc_library(
+ name = "rpc_server",
+ deps = [
+ ":config",
":hdlc_rpc_server",
+ ":rpc_server_headers",
],
)
@@ -96,7 +101,7 @@ pw_cc_library(
includes = ["public"],
deps = [
":io",
- ":rpc_server",
+ ":rpc_server_headers",
":target_io",
"//pw_assert",
"//pw_hdlc:pw_rpc",
@@ -116,7 +121,7 @@ pw_cc_library(
],
includes = ["public"],
deps = [
- "//pw_rpc:server",
+ "//pw_rpc",
"//pw_thread:thread_snapshot_service",
],
)
@@ -143,7 +148,7 @@ pw_cc_library(
deps = [
":log",
":rpc_server",
- ":target_hooks.facade",
+ ":target_hooks_headers",
":thread_snapshot_service",
":work_queue",
"//pw_metric:global",
@@ -163,6 +168,7 @@ pw_cc_library(
],
includes = ["public"],
deps = [
+ ":config",
"//pw_work_queue",
],
)
@@ -196,6 +202,17 @@ pw_cc_library(
)
pw_cc_library(
+ name = "target_hooks_headers",
+ hdrs = [
+ "public/pw_system/target_hooks.h",
+ ],
+ includes = ["public"],
+ deps = [
+ "//pw_thread:thread",
+ ],
+)
+
+pw_cc_library(
name = "target_hooks",
hdrs = [
"public/pw_system/target_hooks.h",
@@ -203,15 +220,29 @@ pw_cc_library(
includes = ["public"],
deps = [
"//pw_thread:thread",
+ "@pigweed_config//:pw_system_target_hooks_backend",
],
)
+# This isn't the best solution, but it's close enough for now. Target hooks are
+# not generically related to an OS, and should be inject-able by downstream
+# projects. For now, assume the pre-baked OS-specific hooks are good enough.
+pw_cc_library(
+ name = "target_hooks_multiplexer",
+ visibility = ["@pigweed_config//:__pkg__"],
+ deps = select({
+ "//pw_build/constraints/rtos:freertos": [":freertos_target_hooks"],
+ "//conditions:default": [":stl_target_hooks"],
+ }),
+)
+
pw_cc_library(
name = "stl_target_hooks",
srcs = [
"stl_target_hooks.cc",
],
deps = [
+ ":init",
"//pw_thread:sleep",
"//pw_thread:thread",
"//pw_thread_stl:thread",
@@ -223,9 +254,9 @@ pw_cc_library(
srcs = [
"freertos_target_hooks.cc",
],
-
- # TODO(b/234876414): This should depend on FreeRTOS but our third parties
- # currently do not have Bazel support.
+ target_compatible_with = [
+ "//pw_build/constraints/rtos:freertos",
+ ],
deps = [
"//pw_thread:thread",
"//pw_thread_freertos:thread",
@@ -241,5 +272,6 @@ pw_cc_binary(
":target_hooks",
"//pw_stream",
"//pw_stream:sys_io_stream",
+ "//pw_unit_test:rpc_service",
],
)
diff --git a/pw_thread/BUILD.bazel b/pw_thread/BUILD.bazel
index 283d62cb7..2e20f1d44 100644
--- a/pw_thread/BUILD.bazel
+++ b/pw_thread/BUILD.bazel
@@ -82,10 +82,21 @@ pw_cc_library(
name = "thread_iteration",
deps = [
":thread_iteration_facade",
- "@pigweed_config//:pw_thread_thread_backend",
+ "@pigweed_config//:pw_thread_iteration_backend",
],
)
+pw_cc_library(
+ name = "iteration_backend_multiplexer",
+ visibility = ["@pigweed_config//:__pkg__"],
+ deps = select({
+ "//pw_build/constraints/rtos:embos": ["//pw_thread_embos:thread_iteration"],
+ "//pw_build/constraints/rtos:freertos": ["//pw_thread_freertos:thread_iteration"],
+ "//pw_build/constraints/rtos:threadx": ["//pw_thread_threadx:thread_iteration"],
+ "//conditions:default": ["//pw_thread_stl:thread_iteration"],
+ }),
+)
+
pw_cc_facade(
name = "sleep_facade",
hdrs = [
diff --git a/targets/default_config.BUILD b/targets/default_config.BUILD
index 68d599295..dd1022ef9 100644
--- a/targets/default_config.BUILD
+++ b/targets/default_config.BUILD
@@ -117,6 +117,11 @@ label_flag(
)
label_flag(
+ name = "pw_thread_iteration_backend",
+ build_setting_default = "@pigweed//pw_thread:iteration_backend_multiplexer",
+)
+
+label_flag(
name = "pw_thread_sleep_backend",
build_setting_default = "@pigweed//pw_thread:sleep_backend_multiplexer",
)
@@ -147,6 +152,11 @@ label_flag(
)
label_flag(
+ name = "pw_system_target_hooks_backend",
+ build_setting_default = "@pigweed//pw_system:target_hooks_multiplexer",
+)
+
+label_flag(
name = "pw_unit_test_googletest_backend",
build_setting_default = "@pigweed//pw_unit_test:light",
)