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