blob: afeebe397bfeb2cd7b4ce34c178c96139ca0590a [file] [log] [blame]
Ewout van Bekkum5bcd8c42020-11-23 10:46:16 -08001# Copyright 2020 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/target_types.gni")
Ewout van Bekkumf7e38b32020-11-16 11:56:41 -080018import("$dir_pw_chrono/backend.gni")
Ewout van Bekkum5bcd8c42020-11-23 10:46:16 -080019import("$dir_pw_docgen/docs.gni")
Ewout van Bekkumf680eb12020-12-30 15:29:18 -080020import("$dir_pw_sync/backend.gni")
Ewout van Bekkum5bcd8c42020-11-23 10:46:16 -080021
22config("public_include_path") {
23 include_dirs = [ "public" ]
24 visibility = [ ":*" ]
25}
26
27config("backend_config") {
28 include_dirs = [ "public_overrides" ]
29 visibility = [ ":*" ]
30}
31
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -070032# This target provides the backend for pw::sync::Mutex.
33pw_source_set("mutex") {
34 public_configs = [
35 ":public_include_path",
36 ":backend_config",
37 ]
38 public = [
39 "public/pw_sync_threadx/mutex_inline.h",
40 "public/pw_sync_threadx/mutex_native.h",
41 "public_overrides/pw_sync_backend/mutex_inline.h",
42 "public_overrides/pw_sync_backend/mutex_native.h",
43 ]
44 public_deps = [
45 "$dir_pw_assert",
46 "$dir_pw_interrupt:context",
47 "$dir_pw_sync:mutex.facade",
48 "$dir_pw_third_party/threadx",
49 ]
50}
51
Ewout van Bekkumf680eb12020-12-30 15:29:18 -080052if (pw_chrono_SYSTEM_CLOCK_BACKEND != "") {
53 # This target provides the backend for pw::sync::BinarySemaphore.
54 pw_source_set("binary_semaphore") {
55 public_configs = [
56 ":public_include_path",
57 ":backend_config",
58 ]
59 public = [
60 "public/pw_sync_threadx/binary_semaphore_inline.h",
61 "public/pw_sync_threadx/binary_semaphore_native.h",
62 "public_overrides/pw_sync_backend/binary_semaphore_inline.h",
63 "public_overrides/pw_sync_backend/binary_semaphore_native.h",
64 ]
65 public_deps = [
66 "$dir_pw_assert",
67 "$dir_pw_chrono:system_clock",
68 "$dir_pw_interrupt:context",
69 "$dir_pw_third_party/threadx",
70 ]
71 sources = [ "binary_semaphore.cc" ]
72 deps = [
73 "$dir_pw_sync:binary_semaphore.facade",
74 pw_chrono_SYSTEM_CLOCK_BACKEND,
75 ]
76 assert(
77 pw_sync_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
78 pw_chrono_SYSTEM_CLOCK_BACKEND ==
79 "$dir_pw_chrono_threadx:system_clock",
80 "The ThreadX pw::sync::BinarySemaphore backend only works with the " +
81 "ThreadX pw::chrono::SystemClock backend.")
82 }
Ewout van Bekkumf7e38b32020-11-16 11:56:41 -080083
Ewout van Bekkumf680eb12020-12-30 15:29:18 -080084 # This target provides the backend for pw::sync::CountingSemaphore.
85 pw_source_set("counting_semaphore") {
86 public_configs = [
87 ":public_include_path",
88 ":backend_config",
89 ]
90 public = [
91 "public/pw_sync_threadx/counting_semaphore_inline.h",
92 "public/pw_sync_threadx/counting_semaphore_native.h",
93 "public_overrides/pw_sync_backend/counting_semaphore_inline.h",
94 "public_overrides/pw_sync_backend/counting_semaphore_native.h",
95 ]
96 public_deps = [
97 "$dir_pw_assert",
98 "$dir_pw_chrono:system_clock",
99 "$dir_pw_interrupt:context",
100 "$dir_pw_third_party/threadx",
101 ]
102 sources = [ "counting_semaphore.cc" ]
103 deps = [
104 "$dir_pw_sync:counting_semaphore.facade",
105 pw_chrono_SYSTEM_CLOCK_BACKEND,
106 ]
107 assert(pw_sync_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
108 pw_chrono_SYSTEM_CLOCK_BACKEND ==
109 "$dir_pw_chrono_threadx:system_clock",
110 "The ThreadX pw::sync::CountingSemaphore backend only works with " +
111 "the ThreadX pw::chrono::SystemClock backend.")
112 }
Ewout van Bekkumf7e38b32020-11-16 11:56:41 -0800113
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700114 # This target provides the backend for pw::sync::TimedMutex.
115 pw_source_set("timed_mutex") {
Ewout van Bekkumf680eb12020-12-30 15:29:18 -0800116 public_configs = [
117 ":public_include_path",
118 ":backend_config",
119 ]
120 public = [
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700121 "public/pw_sync_threadx/timed_mutex_inline.h",
122 "public_overrides/pw_sync_backend/timed_mutex_inline.h",
Ewout van Bekkumf680eb12020-12-30 15:29:18 -0800123 ]
124 public_deps = [
Ewout van Bekkumf680eb12020-12-30 15:29:18 -0800125 "$dir_pw_chrono:system_clock",
Ewout van Bekkum6f5b8fb2021-04-06 16:15:22 -0700126 "$dir_pw_sync:timed_mutex.facade",
127 ]
128 sources = [ "timed_mutex.cc" ]
129 deps = [
130 "$dir_pw_assert",
Ewout van Bekkumf680eb12020-12-30 15:29:18 -0800131 "$dir_pw_interrupt:context",
132 "$dir_pw_third_party/threadx",
Ewout van Bekkumf680eb12020-12-30 15:29:18 -0800133 pw_chrono_SYSTEM_CLOCK_BACKEND,
134 ]
135 assert(pw_sync_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
136 pw_chrono_SYSTEM_CLOCK_BACKEND ==
137 "$dir_pw_chrono_threadx:system_clock",
138 "The ThreadX pw::sync::Mutex backend only works with the ThreadX " +
139 "pw::chrono::SystemClock backend.")
140 }
Ewout van Bekkumf7e38b32020-11-16 11:56:41 -0800141}
142
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800143# This target provides the backend for pw::sync::InterruptSpinLock, note that
144# this implementation does NOT support ThreadX w/ SMP.
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800145pw_source_set("interrupt_spin_lock") {
Ewout van Bekkum5bcd8c42020-11-23 10:46:16 -0800146 public_configs = [
147 ":public_include_path",
148 ":backend_config",
149 ]
150 public = [
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800151 "public/pw_sync_threadx/interrupt_spin_lock_inline.h",
152 "public/pw_sync_threadx/interrupt_spin_lock_native.h",
153 "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
154 "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
Ewout van Bekkum5bcd8c42020-11-23 10:46:16 -0800155 ]
156 public_deps = [ "$dir_pw_third_party/threadx" ]
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800157 sources = [ "interrupt_spin_lock.cc" ]
Ewout van Bekkum5bcd8c42020-11-23 10:46:16 -0800158 deps = [
159 "$dir_pw_assert",
Ewout van Bekkumeded1032021-06-22 14:19:42 -0700160 "$dir_pw_interrupt:context",
Ewout van Bekkum126e0112021-03-12 10:59:49 -0800161 "$dir_pw_sync:interrupt_spin_lock.facade",
Ewout van Bekkum5bcd8c42020-11-23 10:46:16 -0800162 ]
163}
164
165pw_doc_group("docs") {
166 sources = [ "docs.rst" ]
167}