aboutsummaryrefslogtreecommitdiff
path: root/pw_build
diff options
context:
space:
mode:
authorTed Pudlik <tpudlik@google.com>2023-11-30 20:43:12 +0000
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-11-30 20:43:12 +0000
commita40f262a595caff2093df22304d42dbb1a8cfe48 (patch)
treeab2f344c798c2a6286707b3b25e483e76898b17c /pw_build
parent5e64e119af0a5d7c8d0fe0466594772604597b21 (diff)
downloadpigweed-a40f262a595caff2093df22304d42dbb1a8cfe48.tar.gz
bazel: Add simple module configuration mechanism
Add a module configuration mechanism for Bazel that only supports setting the configuration options through `defines`. Bug: b/234872811 Change-Id: I97ddbb661789cf0881e043e3db68b22f21b741b0 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/181032 Commit-Queue: Ted Pudlik <tpudlik@google.com> Reviewed-by: Wyatt Hepler <hepler@google.com>
Diffstat (limited to 'pw_build')
-rw-r--r--pw_build/BUILD.bazel27
-rw-r--r--pw_build/BUILD.gn11
-rw-r--r--pw_build/module_config_test.cc21
3 files changed, 59 insertions, 0 deletions
diff --git a/pw_build/BUILD.bazel b/pw_build/BUILD.bazel
index 6ee0e3890..49fe41bce 100644
--- a/pw_build/BUILD.bazel
+++ b/pw_build/BUILD.bazel
@@ -72,6 +72,33 @@ pw_cc_test(
],
)
+label_flag(
+ name = "default_module_config",
+ # The default module config is empty.
+ build_setting_default = ":empty_cc_library",
+)
+
+cc_library(
+ name = "test_module_config",
+ defines = [
+ "PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED=1",
+ ],
+)
+
+pw_cc_test(
+ name = "module_config_test",
+ srcs = ["module_config_test.cc"],
+ # This test requires a special configuration. It's run in CI, and can be
+ # run manually via,
+ #
+ # bazel build \
+ # --//pw_thread_freertos:config_override=//pw_build:test_module_config \
+ # --platforms=//pw_build/platforms:testonly_freertos \
+ # //pw_build:module_config_test
+ tags = ["manual"],
+ deps = ["//pw_thread:thread"],
+)
+
# This empty library is used as a placeholder for label flags that need to
# point to a library of some kind, but don't actually need the dependency to
# amount to anything.
diff --git a/pw_build/BUILD.gn b/pw_build/BUILD.gn
index 0a373022e..4e56015f6 100644
--- a/pw_build/BUILD.gn
+++ b/pw_build/BUILD.gn
@@ -356,6 +356,11 @@ pw_doc_group("docs") {
]
}
+config("module_config_test_config") {
+ visibility = [ ":*" ]
+ defines = [ "PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED=1" ]
+}
+
# Pigweed upstream does not use the default toolchain, but other projects may
# use it. To support using pw_build from the default toolchain without fully
# configuring the Pigweed build, only instantiate the pw_build tests for a
@@ -366,6 +371,12 @@ if (current_toolchain != default_toolchain) {
deps = [ ":test_blob" ]
}
+ pw_test("module_config_test") {
+ public_configs = [ ":module_config_test_config" ]
+ sources = [ "module_config_test.cc" ]
+ deps = [ "$dir_pw_thread_freertos:config" ]
+ }
+
pw_cc_blob_library("test_blob") {
out_header = "pw_build/test_blob.h"
namespace = "test::ns"
diff --git a/pw_build/module_config_test.cc b/pw_build/module_config_test.cc
new file mode 100644
index 000000000..1d8b25042
--- /dev/null
+++ b/pw_build/module_config_test.cc
@@ -0,0 +1,21 @@
+// Copyright 2023 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.
+
+#include "pw_thread_freertos/config.h"
+
+namespace pw::build::test {
+
+static_assert(PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED == 1);
+
+} // namespace pw::build::test