blob: 079d8ca8eca7ec6e4b2009c74910a10ec66dc66d [file] [log] [blame]
# Copyright 2021 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.
load(
"//pw_build:pigweed.bzl",
"pw_cc_facade",
"pw_cc_library",
"pw_cc_test",
)
load(
"//pw_build:selects.bzl",
"TARGET_COMPATIBLE_WITH_HOST_SELECT",
)
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
pw_cc_facade(
name = "binary_semaphore_facade",
hdrs = [
"public/pw_sync/binary_semaphore.h",
],
includes = ["public"],
deps = [
"//pw_chrono:system_clock",
"//pw_preprocessor",
],
)
pw_cc_library(
name = "binary_semaphore",
srcs = [
"binary_semaphore.cc",
],
deps = [
":binary_semaphore_facade",
"@pigweed_config//:pw_sync_binary_semaphore_backend",
],
)
pw_cc_library(
name = "binary_semaphore_backend_multiplexer",
visibility = ["@pigweed_config//:__pkg__"],
deps = select({
"@platforms//os:none": ["//pw_sync_baremetal:binary_semaphore"],
"//pw_build/constraints/rtos:embos": ["//pw_sync_embos:binary_semaphore"],
"//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:binary_semaphore"],
"//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:binary_semaphore"],
"//conditions:default": ["//pw_sync_stl:binary_semaphore"],
}),
)
pw_cc_facade(
name = "counting_semaphore_facade",
hdrs = [
"public/pw_sync/counting_semaphore.h",
],
includes = ["public"],
deps = [
"//pw_chrono:system_clock",
"//pw_preprocessor",
],
)
pw_cc_library(
name = "counting_semaphore",
srcs = [
"counting_semaphore.cc",
],
deps = [
":counting_semaphore_facade",
"@pigweed_config//:pw_sync_counting_semaphore_backend",
],
)
pw_cc_library(
name = "counting_semaphore_backend_multiplexer",
visibility = ["@pigweed_config//:__pkg__"],
deps = select({
"@platforms//os:none": ["//pw_sync_baremetal:counting_semaphore"],
"//pw_build/constraints/rtos:embos": ["//pw_sync_embos:counting_semaphore"],
"//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:counting_semaphore"],
"//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:counting_semaphore"],
"//conditions:default": ["//pw_sync_stl:counting_semaphore"],
}),
)
pw_cc_library(
name = "lock_annotations",
hdrs = [
"public/pw_sync/lock_annotations.h",
],
includes = ["public"],
deps = [
"//pw_preprocessor",
],
)
pw_cc_library(
name = "borrow",
hdrs = [
"public/pw_sync/borrow.h",
],
includes = ["public"],
deps = [
":lock_annotations",
":virtual_basic_lockable",
"//pw_assert",
],
)
pw_cc_library(
name = "virtual_basic_lockable",
hdrs = [
"public/pw_sync/virtual_basic_lockable.h",
],
includes = ["public"],
deps = [
":lock_annotations",
"//pw_polyfill",
],
)
pw_cc_facade(
name = "mutex_facade",
hdrs = [
"public/pw_sync/mutex.h",
],
includes = ["public"],
deps = [
":lock_annotations",
":virtual_basic_lockable",
"//pw_preprocessor",
],
)
pw_cc_library(
name = "mutex",
srcs = [
"mutex.cc",
],
deps = [
":mutex_facade",
"@pigweed_config//:pw_sync_mutex_backend",
],
)
pw_cc_library(
name = "mutex_backend_multiplexer",
visibility = ["@pigweed_config//:__pkg__"],
deps = select({
"@platforms//os:none": ["//pw_sync_baremetal:mutex"],
"//pw_build/constraints/rtos:embos": ["//pw_sync_embos:mutex"],
"//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:mutex"],
"//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:mutex"],
"//conditions:default": ["//pw_sync_stl:mutex"],
}),
)
pw_cc_facade(
name = "timed_mutex_facade",
hdrs = [
"public/pw_sync/timed_mutex.h",
],
includes = ["public"],
deps = [
":lock_annotations",
":mutex_facade",
":virtual_basic_lockable",
"//pw_chrono:system_clock",
"//pw_preprocessor",
],
)
pw_cc_library(
name = "timed_mutex",
srcs = [
"timed_mutex.cc",
],
deps = [
":mutex",
":timed_mutex_facade",
":virtual_basic_lockable",
"@pigweed_config//:pw_sync_timed_mutex_backend",
],
)
pw_cc_library(
name = "timed_mutex_backend_multiplexer",
visibility = ["@pigweed_config//:__pkg__"],
deps = select({
"@platforms//os:none": ["//pw_sync_baremetal:timed_mutex"],
"//pw_build/constraints/rtos:embos": ["//pw_sync_embos:timed_mutex"],
"//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:timed_mutex"],
"//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:timed_mutex"],
"//conditions:default": ["//pw_sync_stl:timed_mutex"],
}),
)
pw_cc_library(
name = "recursive_mutex_facade",
hdrs = ["public/pw_sync/recursive_mutex.h"],
includes = ["public"],
deps = [
":lock_annotations",
"//pw_preprocessor",
],
)
pw_cc_library(
name = "recursive_mutex",
srcs = ["recursive_mutex.cc"],
visibility = ["//pw_sync_baremetal:__pkg__"],
deps = [
":recursive_mutex_facade",
"@pigweed_config//:pw_sync_recursive_mutex_backend",
],
)
pw_cc_library(
name = "recursive_mutex_backend_multiplexer",
visibility = ["@pigweed_config//:__pkg__"],
deps = select({
"@platforms//os:none": ["//pw_sync_baremetal:recursive_mutex"],
"//conditions:default": ["//pw_sync_stl:recursive_mutex"],
}),
)
pw_cc_facade(
name = "interrupt_spin_lock_facade",
hdrs = [
"public/pw_sync/interrupt_spin_lock.h",
],
includes = ["public"],
deps = [
":lock_annotations",
":virtual_basic_lockable",
"//pw_preprocessor",
],
)
pw_cc_library(
name = "interrupt_spin_lock",
srcs = [
"interrupt_spin_lock.cc",
],
deps = [
":interrupt_spin_lock_facade",
"@pigweed_config//:pw_sync_interrupt_spin_lock_backend",
],
)
pw_cc_library(
name = "interrupt_spin_lock_backend_multiplexer",
visibility = ["@pigweed_config//:__pkg__"],
deps = select({
"@platforms//os:none": ["//pw_sync_baremetal:interrupt_spin_lock"],
"//pw_build/constraints/rtos:embos": ["//pw_sync_embos:interrupt_spin_lock"],
"//pw_build/constraints/rtos:freertos": ["//pw_sync_freertos:interrupt_spin_lock"],
"//pw_build/constraints/rtos:threadx": ["//pw_sync_threadx:interrupt_spin_lock"],
"//conditions:default": ["//pw_sync_stl:interrupt_spin_lock"],
}),
)
pw_cc_facade(
name = "thread_notification_facade",
hdrs = [
"public/pw_sync/thread_notification.h",
],
includes = ["public"],
)
pw_cc_library(
name = "thread_notification",
deps = [
":thread_notification_facade",
"@pigweed_config//:pw_sync_thread_notification_backend",
],
)
pw_cc_library(
name = "thread_notification_backend_multiplexer",
visibility = ["@pigweed_config//:__pkg__"],
deps = select({
"//conditions:default": ["//pw_sync:binary_semaphore_thread_notification_backend"],
}),
)
pw_cc_facade(
name = "timed_thread_notification_facade",
hdrs = [
"public/pw_sync/timed_thread_notification.h",
],
includes = ["public"],
deps = [
":thread_notification_facade",
"//pw_chrono:system_clock",
],
)
pw_cc_library(
name = "timed_thread_notification",
deps = [
":thread_notification",
":timed_thread_notification_facade",
"@pigweed_config//:pw_sync_timed_thread_notification_backend",
],
)
pw_cc_library(
name = "timed_thread_notification_backend_multiplexer",
visibility = ["@pigweed_config//:__pkg__"],
deps = select({
"//conditions:default": ["//pw_sync:binary_semaphore_timed_thread_notification_backend"],
}),
)
pw_cc_library(
name = "binary_semaphore_thread_notification_backend_headers",
hdrs = [
"public/pw_sync/backends/binary_semaphore_thread_notification_inline.h",
"public/pw_sync/backends/binary_semaphore_thread_notification_native.h",
"public_overrides/pw_sync_backend/thread_notification_inline.h",
"public_overrides/pw_sync_backend/thread_notification_native.h",
],
includes = [
"public",
"public_overrides",
],
target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
deps = [":binary_semaphore"],
)
pw_cc_library(
name = "binary_semaphore_thread_notification_backend",
target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
deps = [
":binary_semaphore_facade",
":binary_semaphore_thread_notification_backend_headers",
":thread_notification_facade",
],
)
pw_cc_library(
name = "binary_semaphore_timed_thread_notification_backend_headers",
hdrs = [
"public/pw_sync/backends/binary_semaphore_timed_thread_notification_inline.h",
"public_overrides/pw_sync_backend/timed_thread_notification_inline.h",
],
includes = [
"public",
"public_overrides",
],
target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
deps = [
":binary_semaphore_thread_notification_backend_headers",
"//pw_chrono:system_clock",
],
)
pw_cc_library(
name = "binary_semaphore_timed_thread_notification_backend",
target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
deps = [
":binary_semaphore_thread_notification_backend",
":binary_semaphore_timed_thread_notification_backend_headers",
"//pw_sync:timed_thread_notification_facade",
],
)
pw_cc_library(
name = "yield_core",
hdrs = [
"public/pw_sync/yield_core.h",
],
includes = ["public"],
)
pw_cc_facade(
name = "condition_variable_facade",
hdrs = [
"public/pw_sync/condition_variable.h",
],
includes = ["public"],
deps = [
"//pw_chrono:system_clock",
"//pw_sync:mutex",
],
)
# TODO(b/228998350): This needs to be instantiated for each platform that
# provides an implementation of $dir_pw_thread:test_threads and
# $dir_pw_sync:condition_variable.
# pw_cc_library(
# name = "condition_variable_test",
# srcs = ["condition_variable_test.cc"],
# deps = [
# ":condition_variable_facade",
# "//pw_containers:vector",
# "//pw_sync:mutex",
# "//pw_sync:timed_thread_notification",
# "//pw_thread:sleep",
# "//pw_thread:test_threads_header",
# "//pw_thread:thread",
# "//pw_unit_test",
# ],
# )
#
# Filegroup to mark `condition_variable_test.cc` as used for the linter:
filegroup(
name = "condition_variable_test_filegroup",
srcs = ["condition_variable_test.cc"],
)
pw_cc_test(
name = "borrow_test",
srcs = [
"borrow_test.cc",
],
deps = [
":borrow",
":virtual_basic_lockable",
"//pw_assert",
"//pw_unit_test",
],
)
pw_cc_test(
name = "binary_semaphore_facade_test",
srcs = [
"binary_semaphore_facade_test.cc",
"binary_semaphore_facade_test_c.c",
],
deps = [
":binary_semaphore",
"//pw_preprocessor",
"//pw_unit_test",
],
)
pw_cc_test(
name = "counting_semaphore_facade_test",
srcs = [
"counting_semaphore_facade_test.cc",
"counting_semaphore_facade_test_c.c",
],
deps = [
":counting_semaphore",
"//pw_preprocessor",
"//pw_unit_test",
],
)
pw_cc_test(
name = "mutex_facade_test",
srcs = [
"mutex_facade_test.cc",
"mutex_facade_test_c.c",
],
deps = [
":mutex",
"//pw_preprocessor",
"//pw_unit_test",
],
)
pw_cc_test(
name = "timed_mutex_facade_test",
srcs = [
"timed_mutex_facade_test.cc",
"timed_mutex_facade_test_c.c",
],
deps = [
":timed_mutex",
"//pw_chrono:system_clock",
"//pw_preprocessor",
"//pw_unit_test",
],
)
pw_cc_test(
name = "recursive_mutex_facade_test",
srcs = [
"recursive_mutex_facade_test.cc",
"recursive_mutex_facade_test_c.c",
],
deps = [
":recursive_mutex",
"//pw_preprocessor",
"//pw_unit_test",
],
)
pw_cc_test(
name = "interrupt_spin_lock_facade_test",
srcs = [
"interrupt_spin_lock_facade_test.cc",
"interrupt_spin_lock_facade_test_c.c",
],
deps = [
":interrupt_spin_lock",
"//pw_preprocessor",
"//pw_unit_test",
],
)
pw_cc_test(
name = "thread_notification_facade_test",
srcs = [
"thread_notification_facade_test.cc",
],
deps = [
":thread_notification",
"//pw_unit_test",
],
)
pw_cc_test(
name = "timed_thread_notification_facade_test",
srcs = [
"timed_thread_notification_facade_test.cc",
],
deps = [
":timed_thread_notification",
"//pw_chrono:system_clock",
"//pw_unit_test",
],
)