Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_sync_threadx / BUILD.gn
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
15 import("//build_overrides/pigweed.gni")
16
17 import("$dir_pw_build/target_types.gni")
18 import("$dir_pw_chrono/backend.gni")
19 import("$dir_pw_docgen/docs.gni")
20 import("$dir_pw_sync/backend.gni")
21
22 config("public_include_path") {
23   include_dirs = [ "public" ]
24   visibility = [ ":*" ]
25 }
26
27 config("backend_config") {
28   include_dirs = [ "public_overrides" ]
29   visibility = [ ":*" ]
30 }
31
32 if (pw_chrono_SYSTEM_CLOCK_BACKEND != "") {
33   # This target provides the backend for pw::sync::BinarySemaphore.
34   pw_source_set("binary_semaphore") {
35     public_configs = [
36       ":public_include_path",
37       ":backend_config",
38     ]
39     public = [
40       "public/pw_sync_threadx/binary_semaphore_inline.h",
41       "public/pw_sync_threadx/binary_semaphore_native.h",
42       "public_overrides/pw_sync_backend/binary_semaphore_inline.h",
43       "public_overrides/pw_sync_backend/binary_semaphore_native.h",
44     ]
45     public_deps = [
46       "$dir_pw_assert",
47       "$dir_pw_chrono:system_clock",
48       "$dir_pw_interrupt:context",
49       "$dir_pw_third_party/threadx",
50     ]
51     sources = [ "binary_semaphore.cc" ]
52     deps = [
53       "$dir_pw_sync:binary_semaphore.facade",
54       pw_chrono_SYSTEM_CLOCK_BACKEND,
55     ]
56     assert(
57         pw_sync_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
58             pw_chrono_SYSTEM_CLOCK_BACKEND ==
59                 "$dir_pw_chrono_threadx:system_clock",
60         "The ThreadX pw::sync::BinarySemaphore backend only works with the " +
61             "ThreadX pw::chrono::SystemClock backend.")
62   }
63
64   # This target provides the backend for pw::sync::CountingSemaphore.
65   pw_source_set("counting_semaphore") {
66     public_configs = [
67       ":public_include_path",
68       ":backend_config",
69     ]
70     public = [
71       "public/pw_sync_threadx/counting_semaphore_inline.h",
72       "public/pw_sync_threadx/counting_semaphore_native.h",
73       "public_overrides/pw_sync_backend/counting_semaphore_inline.h",
74       "public_overrides/pw_sync_backend/counting_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 = [ "counting_semaphore.cc" ]
83     deps = [
84       "$dir_pw_sync:counting_semaphore.facade",
85       pw_chrono_SYSTEM_CLOCK_BACKEND,
86     ]
87     assert(pw_sync_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
88                pw_chrono_SYSTEM_CLOCK_BACKEND ==
89                    "$dir_pw_chrono_threadx:system_clock",
90            "The ThreadX pw::sync::CountingSemaphore backend only works with " +
91                "the ThreadX pw::chrono::SystemClock backend.")
92   }
93
94   # This target provides the backend for pw::sync::Mutex.
95   pw_source_set("mutex") {
96     public_configs = [
97       ":public_include_path",
98       ":backend_config",
99     ]
100     public = [
101       "public/pw_sync_threadx/mutex_inline.h",
102       "public/pw_sync_threadx/mutex_native.h",
103       "public_overrides/pw_sync_backend/mutex_inline.h",
104       "public_overrides/pw_sync_backend/mutex_native.h",
105     ]
106     public_deps = [
107       "$dir_pw_assert",
108       "$dir_pw_chrono:system_clock",
109       "$dir_pw_interrupt:context",
110       "$dir_pw_third_party/threadx",
111     ]
112     sources = [ "mutex.cc" ]
113     deps = [
114       "$dir_pw_sync:mutex.facade",
115       pw_chrono_SYSTEM_CLOCK_BACKEND,
116     ]
117     assert(pw_sync_OVERRIDE_SYSTEM_CLOCK_BACKEND_CHECK ||
118                pw_chrono_SYSTEM_CLOCK_BACKEND ==
119                    "$dir_pw_chrono_threadx:system_clock",
120            "The ThreadX pw::sync::Mutex backend only works with the ThreadX " +
121                "pw::chrono::SystemClock backend.")
122   }
123 }
124
125 # This target provides the backend for pw::sync::SpinLock, note that this
126 # implementation does NOT support ThreadX w/ SMP.
127 pw_source_set("spin_lock") {
128   public_configs = [
129     ":public_include_path",
130     ":backend_config",
131   ]
132   public = [
133     "public/pw_sync_threadx/spin_lock_inline.h",
134     "public/pw_sync_threadx/spin_lock_native.h",
135     "public_overrides/pw_sync_backend/spin_lock_inline.h",
136     "public_overrides/pw_sync_backend/spin_lock_native.h",
137   ]
138   public_deps = [ "$dir_pw_third_party/threadx" ]
139   sources = [ "spin_lock.cc" ]
140   deps = [
141     "$dir_pw_assert",
142     "$dir_pw_sync:spin_lock.facade",
143   ]
144 }
145
146 pw_doc_group("docs") {
147   sources = [ "docs.rst" ]
148 }