blob: 0ad8e33ebde8d729915845e4d45f2d253a723b59 [file] [log] [blame]
Ewout van Bekkume858b812022-01-19 17:07:54 -08001# Copyright 2022 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
15include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
16
17pw_add_module_config(pw_thread_CONFIG)
18
19pw_add_module_library(pw_thread.config
20 HEADERS
21 public/pw_thread/config.h
22 PUBLIC_INCLUDES
23 public
24 PUBLIC_DEPS
25 ${pw_thread_CONFIG}
26)
27
28pw_add_facade(pw_thread.id
29 HEADERS
30 public/pw_thread/id.h
31 PUBLIC_INCLUDES
32 public
33)
34
35pw_add_facade(pw_thread.sleep
36 HEADERS
37 public/pw_thread/sleep.h
38 PUBLIC_INCLUDES
39 public
40 PUBLIC_DEPS
41 pw_chrono.system_clock
42 pw_preprocessor
43 SOURCES
44 sleep.cc
45)
46
47pw_add_facade(pw_thread.thread
48 HEADERS
49 public/pw_thread/detached_thread.h
50 public/pw_thread/thread.h
51 PUBLIC_INCLUDES
52 public
53 PUBLIC_DEPS
54 pw_thread.thread_core
55 pw_thread.id
56 SOURCES
57 thread.cc
58)
59
60pw_add_module_library(pw_thread.thread_core
61 HEADERS
62 public/pw_thread/thread_core.h
63 PUBLIC_INCLUDES
64 public
65)
66
67pw_add_facade(pw_thread.yield
68 HEADERS
69 public/pw_thread/yield.h
70 PUBLIC_INCLUDES
71 public
72 PUBLIC_DEPS
73 pw_preprocessor
74 SOURCES
75 yield.cc
76)
77
78pw_add_module_library(pw_thread.snapshot
79 HEADERS
80 public/pw_thread/snapshot.h
81 PUBLIC_INCLUDES
82 public
83 PUBLIC_DEPS
84 pw_bytes
Ewout van Bekkume36b4cf2022-02-11 15:02:06 -080085 pw_function
Ewout van Bekkume858b812022-01-19 17:07:54 -080086 pw_protobuf
87 pw_status
88 pw_thread.protos.pwpb
89 SOURCES
90 snapshot.cc
91 PRIVATE_DEPS
92 pw_thread.config
93 pw_log
94)
95
96pw_proto_library(pw_thread.protos
97 SOURCES
98 pw_thread_protos/thread.proto
Ewout van Bekkumc5c8b272022-01-26 16:23:08 -080099 DEPS
Ewout van Bekkume858b812022-01-19 17:07:54 -0800100 pw_tokenizer.proto
101)
102
103if(NOT "${pw_thread.id_BACKEND}" STREQUAL "pw_thread.id.NO_BACKEND_SET")
104 pw_add_test(pw_thread.id_facade_test
105 SOURCES
106 id_facade_test.cc
107 DEPS
108 pw_thread.id
109 GROUPS
110 modules
111 pw_thread
112 )
113endif()
114
115if((NOT "${pw_thread.id_BACKEND}" STREQUAL "pw_thread.id.NO_BACKEND_SET") AND
116 (NOT "${pw_thread.sleep_BACKEND}" STREQUAL "pw_thread.sleep.NO_BACKEND_SET"))
117 pw_add_test(pw_thread.sleep_facade_test
118 SOURCES
119 sleep_facade_test.cc
120 sleep_facade_test_c.c
121 DEPS
122 pw_chrono.system_clock
123 pw_thread.id
124 pw_thread.sleep
125 GROUPS
126 modules
127 pw_thread
128 )
129endif()
130
131pw_add_module_library(pw_thread.test_threads
132 HEADERS
133 public/pw_thread/test_threads.h
134 PUBLIC_INCLUDES
135 public
136 PUBLIC_DEPS
137 pw_thread.thread
138)
139
140# To instantiate this facade test based on a selected backend to provide
141# test_threads you can create a pw_add_test target which depends on this
142# target and a target which provides the implementation of
143# test_threads. See pw_thread_stl.thread_backend_test as an example.
144pw_add_module_library(pw_thread.thread_facade_test
145 SOURCES
146 thread_facade_test.cc
147 PRIVATE_DEPS
148 pw_thread.id
149 pw_thread.sleep
150 pw_thread.test_threads
151 pw_thread.thread
152 pw_sync.binary_semaphore
153 pw_unit_test
154)
155
156if((NOT "${pw_thread.id_BACKEND}" STREQUAL "pw_thread.id.NO_BACKEND_SET") AND
157 (NOT "${pw_thread.yield_BACKEND}" STREQUAL "pw_thread.yield.NO_BACKEND_SET"))
158 pw_add_test(pw_thread.yield_facade_test
159 SOURCES
160 yield_facade_test.cc
161 yield_facade_test_c.c
162 DEPS
163 pw_thread.id
164 pw_thread.yield
165 GROUPS
166 modules
167 pw_thread
168 )
169endif()