• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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/error.gni")
18import("$dir_pw_build/target_types.gni")
19import("$dir_pw_chrono/backend.gni")
20import("$dir_pw_docgen/docs.gni")
21import("$dir_pw_sync/backend.gni")
22
23config("public_include_path") {
24  include_dirs = [ "public" ]
25  visibility = [ ":*" ]
26}
27
28config("backend_config") {
29  include_dirs = [ "public_overrides" ]
30  visibility = [ ":*" ]
31}
32
33pw_build_assert("check_system_clock_backend") {
34  condition =
35      pw_sync_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
36      pw_chrono_SYSTEM_CLOCK_BACKEND == "$dir_pw_chrono_threadx:system_clock"
37  message = "The ThreadX pw::sync::BinarySemaphore backend only works with " +
38            "the ThreadX pw::chrono::SystemClock backend."
39  visibility = [ ":*" ]
40}
41
42# This target provides the backend for pw::sync::Mutex.
43pw_source_set("mutex") {
44  public_configs = [
45    ":public_include_path",
46    ":backend_config",
47  ]
48  public = [
49    "public/pw_sync_threadx/mutex_inline.h",
50    "public/pw_sync_threadx/mutex_native.h",
51    "public_overrides/pw_sync_backend/mutex_inline.h",
52    "public_overrides/pw_sync_backend/mutex_native.h",
53  ]
54  public_deps = [
55    "$dir_pw_assert",
56    "$dir_pw_interrupt:context",
57    "$dir_pw_sync:mutex.facade",
58    "$dir_pw_third_party/threadx",
59  ]
60}
61
62if (pw_chrono_SYSTEM_CLOCK_BACKEND != "") {
63  # This target provides the backend for pw::sync::BinarySemaphore.
64  pw_source_set("binary_semaphore") {
65    public_configs = [
66      ":public_include_path",
67      ":backend_config",
68    ]
69    public = [
70      "public/pw_sync_threadx/binary_semaphore_inline.h",
71      "public/pw_sync_threadx/binary_semaphore_native.h",
72      "public_overrides/pw_sync_backend/binary_semaphore_inline.h",
73      "public_overrides/pw_sync_backend/binary_semaphore_native.h",
74    ]
75    public_deps = [
76      "$dir_pw_assert",
77      "$dir_pw_chrono:system_clock",
78      "$dir_pw_interrupt:context",
79      "$dir_pw_third_party/threadx",
80    ]
81    sources = [ "binary_semaphore.cc" ]
82    deps = [
83      ":check_system_clock_backend",
84      "$dir_pw_sync:binary_semaphore.facade",
85      pw_chrono_SYSTEM_CLOCK_BACKEND,
86    ]
87  }
88
89  # This target provides the backend for pw::sync::CountingSemaphore.
90  pw_source_set("counting_semaphore") {
91    public_configs = [
92      ":public_include_path",
93      ":backend_config",
94    ]
95    public = [
96      "public/pw_sync_threadx/counting_semaphore_inline.h",
97      "public/pw_sync_threadx/counting_semaphore_native.h",
98      "public_overrides/pw_sync_backend/counting_semaphore_inline.h",
99      "public_overrides/pw_sync_backend/counting_semaphore_native.h",
100    ]
101    public_deps = [
102      "$dir_pw_assert",
103      "$dir_pw_chrono:system_clock",
104      "$dir_pw_interrupt:context",
105      "$dir_pw_third_party/threadx",
106    ]
107    sources = [ "counting_semaphore.cc" ]
108    deps = [
109      ":check_system_clock_backend",
110      "$dir_pw_sync:counting_semaphore.facade",
111      pw_chrono_SYSTEM_CLOCK_BACKEND,
112    ]
113  }
114
115  # This target provides the backend for pw::sync::TimedMutex.
116  pw_source_set("timed_mutex") {
117    public_configs = [
118      ":public_include_path",
119      ":backend_config",
120    ]
121    public = [
122      "public/pw_sync_threadx/timed_mutex_inline.h",
123      "public_overrides/pw_sync_backend/timed_mutex_inline.h",
124    ]
125    public_deps = [
126      "$dir_pw_chrono:system_clock",
127      "$dir_pw_sync:timed_mutex.facade",
128    ]
129    sources = [ "timed_mutex.cc" ]
130    deps = [
131      ":check_system_clock_backend",
132      "$dir_pw_assert",
133      "$dir_pw_interrupt:context",
134      "$dir_pw_third_party/threadx",
135      pw_chrono_SYSTEM_CLOCK_BACKEND,
136    ]
137  }
138}
139
140# This target provides the backend for pw::sync::InterruptSpinLock, note that
141# this implementation does NOT support ThreadX w/ SMP.
142pw_source_set("interrupt_spin_lock") {
143  public_configs = [
144    ":public_include_path",
145    ":backend_config",
146  ]
147  public = [
148    "public/pw_sync_threadx/interrupt_spin_lock_inline.h",
149    "public/pw_sync_threadx/interrupt_spin_lock_native.h",
150    "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
151    "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
152  ]
153  public_deps = [ "$dir_pw_third_party/threadx" ]
154  sources = [ "interrupt_spin_lock.cc" ]
155  deps = [
156    "$dir_pw_assert",
157    "$dir_pw_interrupt:context",
158    "$dir_pw_sync:interrupt_spin_lock.facade",
159  ]
160}
161
162pw_doc_group("docs") {
163  sources = [ "docs.rst" ]
164}
165