1*61c4878aSAndroid Build Coastguard Worker# Copyright 2022 The Pigweed Authors 2*61c4878aSAndroid Build Coastguard Worker# 3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of 5*61c4878aSAndroid Build Coastguard Worker# the License at 6*61c4878aSAndroid Build Coastguard Worker# 7*61c4878aSAndroid Build Coastguard Worker# https://www.apache.org/licenses/LICENSE-2.0 8*61c4878aSAndroid Build Coastguard Worker# 9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under 13*61c4878aSAndroid Build Coastguard Worker# the License. 14*61c4878aSAndroid Build Coastguard Worker 15*61c4878aSAndroid Build Coastguard Workerinclude($ENV{PW_ROOT}/pw_build/pigweed.cmake) 16*61c4878aSAndroid Build Coastguard Workerinclude($ENV{PW_ROOT}/pw_thread/backend.cmake) 17*61c4878aSAndroid Build Coastguard Worker 18*61c4878aSAndroid Build Coastguard Workerpw_add_module_config(pw_thread_CONFIG) 19*61c4878aSAndroid Build Coastguard Worker 20*61c4878aSAndroid Build Coastguard Workerpw_add_library(pw_thread.config INTERFACE 21*61c4878aSAndroid Build Coastguard Worker HEADERS 22*61c4878aSAndroid Build Coastguard Worker public/pw_thread/config.h 23*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 24*61c4878aSAndroid Build Coastguard Worker public 25*61c4878aSAndroid Build Coastguard Worker PUBLIC_DEPS 26*61c4878aSAndroid Build Coastguard Worker ${pw_thread_CONFIG} 27*61c4878aSAndroid Build Coastguard Worker) 28*61c4878aSAndroid Build Coastguard Worker 29*61c4878aSAndroid Build Coastguard Worker# pw_thread.id is deprecated; depend on pw_thread.thread instead. 30*61c4878aSAndroid Build Coastguard Workerpw_add_facade(pw_thread.id INTERFACE 31*61c4878aSAndroid Build Coastguard Worker BACKEND 32*61c4878aSAndroid Build Coastguard Worker pw_thread.id_BACKEND 33*61c4878aSAndroid Build Coastguard Worker HEADERS 34*61c4878aSAndroid Build Coastguard Worker public/pw_thread/id.h 35*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 36*61c4878aSAndroid Build Coastguard Worker public 37*61c4878aSAndroid Build Coastguard Worker) 38*61c4878aSAndroid Build Coastguard Worker 39*61c4878aSAndroid Build Coastguard Workerpw_add_facade(pw_thread.sleep STATIC 40*61c4878aSAndroid Build Coastguard Worker BACKEND 41*61c4878aSAndroid Build Coastguard Worker pw_thread.sleep_BACKEND 42*61c4878aSAndroid Build Coastguard Worker HEADERS 43*61c4878aSAndroid Build Coastguard Worker public/pw_thread/sleep.h 44*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 45*61c4878aSAndroid Build Coastguard Worker public 46*61c4878aSAndroid Build Coastguard Worker PUBLIC_DEPS 47*61c4878aSAndroid Build Coastguard Worker pw_chrono.system_clock 48*61c4878aSAndroid Build Coastguard Worker pw_preprocessor 49*61c4878aSAndroid Build Coastguard Worker SOURCES 50*61c4878aSAndroid Build Coastguard Worker sleep.cc 51*61c4878aSAndroid Build Coastguard Worker) 52*61c4878aSAndroid Build Coastguard Worker 53*61c4878aSAndroid Build Coastguard Workerpw_add_facade(pw_thread.thread STATIC 54*61c4878aSAndroid Build Coastguard Worker BACKEND 55*61c4878aSAndroid Build Coastguard Worker pw_thread.thread_BACKEND 56*61c4878aSAndroid Build Coastguard Worker HEADERS 57*61c4878aSAndroid Build Coastguard Worker public/pw_thread/detached_thread.h 58*61c4878aSAndroid Build Coastguard Worker public/pw_thread/thread.h 59*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 60*61c4878aSAndroid Build Coastguard Worker public 61*61c4878aSAndroid Build Coastguard Worker PUBLIC_DEPS 62*61c4878aSAndroid Build Coastguard Worker pw_function 63*61c4878aSAndroid Build Coastguard Worker pw_thread.thread_core 64*61c4878aSAndroid Build Coastguard Worker pw_thread.id 65*61c4878aSAndroid Build Coastguard Worker pw_thread.options 66*61c4878aSAndroid Build Coastguard Worker SOURCES 67*61c4878aSAndroid Build Coastguard Worker thread.cc 68*61c4878aSAndroid Build Coastguard Worker) 69*61c4878aSAndroid Build Coastguard Worker 70*61c4878aSAndroid Build Coastguard Workerpw_add_library(pw_thread.options INTERFACE 71*61c4878aSAndroid Build Coastguard Worker HEADERS 72*61c4878aSAndroid Build Coastguard Worker public/pw_thread/options.h 73*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 74*61c4878aSAndroid Build Coastguard Worker public 75*61c4878aSAndroid Build Coastguard Worker) 76*61c4878aSAndroid Build Coastguard Worker 77*61c4878aSAndroid Build Coastguard Workerpw_add_library(pw_thread.thread_core INTERFACE 78*61c4878aSAndroid Build Coastguard Worker HEADERS 79*61c4878aSAndroid Build Coastguard Worker public/pw_thread/thread_core.h 80*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 81*61c4878aSAndroid Build Coastguard Worker public 82*61c4878aSAndroid Build Coastguard Worker) 83*61c4878aSAndroid Build Coastguard Worker 84*61c4878aSAndroid Build Coastguard Workerpw_add_library(pw_thread.thread_info INTERFACE 85*61c4878aSAndroid Build Coastguard Worker HEADERS 86*61c4878aSAndroid Build Coastguard Worker public/pw_thread/thread_info.h 87*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 88*61c4878aSAndroid Build Coastguard Worker public 89*61c4878aSAndroid Build Coastguard Worker PUBLIC_DEPS 90*61c4878aSAndroid Build Coastguard Worker pw_span 91*61c4878aSAndroid Build Coastguard Worker) 92*61c4878aSAndroid Build Coastguard Worker 93*61c4878aSAndroid Build Coastguard Workerpw_add_facade(pw_thread.thread_iteration INTERFACE 94*61c4878aSAndroid Build Coastguard Worker BACKEND 95*61c4878aSAndroid Build Coastguard Worker pw_thread.thread_iteration_BACKEND 96*61c4878aSAndroid Build Coastguard Worker HEADERS 97*61c4878aSAndroid Build Coastguard Worker public/pw_thread/thread_iteration.h 98*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 99*61c4878aSAndroid Build Coastguard Worker public 100*61c4878aSAndroid Build Coastguard Worker PUBLIC_DEPS 101*61c4878aSAndroid Build Coastguard Worker pw_thread.thread_info 102*61c4878aSAndroid Build Coastguard Worker pw_function 103*61c4878aSAndroid Build Coastguard Worker pw_status 104*61c4878aSAndroid Build Coastguard Worker) 105*61c4878aSAndroid Build Coastguard Worker 106*61c4878aSAndroid Build Coastguard Workerpw_proto_library(pw_thread.thread_snapshot_service_cc 107*61c4878aSAndroid Build Coastguard Worker SOURCES 108*61c4878aSAndroid Build Coastguard Worker pw_thread_protos/thread_snapshot_service.proto 109*61c4878aSAndroid Build Coastguard Worker DEPS 110*61c4878aSAndroid Build Coastguard Worker pw_thread.protos 111*61c4878aSAndroid Build Coastguard Worker) 112*61c4878aSAndroid Build Coastguard Worker 113*61c4878aSAndroid Build Coastguard Workerpw_add_library(pw_thread.thread_snapshot_service STATIC 114*61c4878aSAndroid Build Coastguard Worker HEADERS 115*61c4878aSAndroid Build Coastguard Worker public/pw_thread/thread_snapshot_service.h 116*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 117*61c4878aSAndroid Build Coastguard Worker public 118*61c4878aSAndroid Build Coastguard Worker PUBLIC_DEPS 119*61c4878aSAndroid Build Coastguard Worker pw_log 120*61c4878aSAndroid Build Coastguard Worker pw_protobuf 121*61c4878aSAndroid Build Coastguard Worker pw_rpc.raw.server_api 122*61c4878aSAndroid Build Coastguard Worker pw_span 123*61c4878aSAndroid Build Coastguard Worker pw_status 124*61c4878aSAndroid Build Coastguard Worker pw_thread.config 125*61c4878aSAndroid Build Coastguard Worker pw_thread.protos.pwpb 126*61c4878aSAndroid Build Coastguard Worker pw_thread.thread_info 127*61c4878aSAndroid Build Coastguard Worker pw_thread.thread_iteration 128*61c4878aSAndroid Build Coastguard Worker pw_thread.thread_snapshot_service_cc.pwpb 129*61c4878aSAndroid Build Coastguard Worker pw_thread.thread_snapshot_service_cc.raw_rpc 130*61c4878aSAndroid Build Coastguard Worker SOURCES 131*61c4878aSAndroid Build Coastguard Worker pw_thread_private/thread_snapshot_service.h 132*61c4878aSAndroid Build Coastguard Worker thread_snapshot_service.cc 133*61c4878aSAndroid Build Coastguard Worker) 134*61c4878aSAndroid Build Coastguard Worker 135*61c4878aSAndroid Build Coastguard Workerpw_add_facade(pw_thread.test_thread_context INTERFACE 136*61c4878aSAndroid Build Coastguard Worker BACKEND 137*61c4878aSAndroid Build Coastguard Worker pw_thread.test_thread_context_BACKEND 138*61c4878aSAndroid Build Coastguard Worker HEADERS 139*61c4878aSAndroid Build Coastguard Worker public/pw_thread/test_thread_context.h 140*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 141*61c4878aSAndroid Build Coastguard Worker public 142*61c4878aSAndroid Build Coastguard Worker) 143*61c4878aSAndroid Build Coastguard Worker 144*61c4878aSAndroid Build Coastguard Workerpw_add_facade(pw_thread.yield STATIC 145*61c4878aSAndroid Build Coastguard Worker BACKEND 146*61c4878aSAndroid Build Coastguard Worker pw_thread.yield_BACKEND 147*61c4878aSAndroid Build Coastguard Worker HEADERS 148*61c4878aSAndroid Build Coastguard Worker public/pw_thread/yield.h 149*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 150*61c4878aSAndroid Build Coastguard Worker public 151*61c4878aSAndroid Build Coastguard Worker PUBLIC_DEPS 152*61c4878aSAndroid Build Coastguard Worker pw_preprocessor 153*61c4878aSAndroid Build Coastguard Worker SOURCES 154*61c4878aSAndroid Build Coastguard Worker yield.cc 155*61c4878aSAndroid Build Coastguard Worker) 156*61c4878aSAndroid Build Coastguard Worker 157*61c4878aSAndroid Build Coastguard Workerpw_add_library(pw_thread.snapshot STATIC 158*61c4878aSAndroid Build Coastguard Worker HEADERS 159*61c4878aSAndroid Build Coastguard Worker public/pw_thread/snapshot.h 160*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 161*61c4878aSAndroid Build Coastguard Worker public 162*61c4878aSAndroid Build Coastguard Worker PUBLIC_DEPS 163*61c4878aSAndroid Build Coastguard Worker pw_bytes 164*61c4878aSAndroid Build Coastguard Worker pw_function 165*61c4878aSAndroid Build Coastguard Worker pw_protobuf 166*61c4878aSAndroid Build Coastguard Worker pw_status 167*61c4878aSAndroid Build Coastguard Worker pw_thread.protos.pwpb 168*61c4878aSAndroid Build Coastguard Worker SOURCES 169*61c4878aSAndroid Build Coastguard Worker snapshot.cc 170*61c4878aSAndroid Build Coastguard Worker PRIVATE_DEPS 171*61c4878aSAndroid Build Coastguard Worker pw_thread.config 172*61c4878aSAndroid Build Coastguard Worker pw_log 173*61c4878aSAndroid Build Coastguard Worker) 174*61c4878aSAndroid Build Coastguard Worker 175*61c4878aSAndroid Build Coastguard Workerpw_proto_library(pw_thread.protos 176*61c4878aSAndroid Build Coastguard Worker SOURCES 177*61c4878aSAndroid Build Coastguard Worker pw_thread_protos/thread.proto 178*61c4878aSAndroid Build Coastguard Worker DEPS 179*61c4878aSAndroid Build Coastguard Worker pw_tokenizer.proto 180*61c4878aSAndroid Build Coastguard Worker) 181*61c4878aSAndroid Build Coastguard Worker 182*61c4878aSAndroid Build Coastguard Workerif(NOT "${pw_thread.id_BACKEND}" STREQUAL "") 183*61c4878aSAndroid Build Coastguard Worker pw_add_test(pw_thread.id_facade_test 184*61c4878aSAndroid Build Coastguard Worker SOURCES 185*61c4878aSAndroid Build Coastguard Worker id_facade_test.cc 186*61c4878aSAndroid Build Coastguard Worker PRIVATE_DEPS 187*61c4878aSAndroid Build Coastguard Worker pw_thread.thread 188*61c4878aSAndroid Build Coastguard Worker GROUPS 189*61c4878aSAndroid Build Coastguard Worker modules 190*61c4878aSAndroid Build Coastguard Worker pw_thread 191*61c4878aSAndroid Build Coastguard Worker ) 192*61c4878aSAndroid Build Coastguard Workerendif() 193*61c4878aSAndroid Build Coastguard Worker 194*61c4878aSAndroid Build Coastguard Workerif((NOT "${pw_thread.id_BACKEND}" STREQUAL "") AND 195*61c4878aSAndroid Build Coastguard Worker (NOT "${pw_thread.sleep_BACKEND}" STREQUAL "")) 196*61c4878aSAndroid Build Coastguard Worker pw_add_test(pw_thread.sleep_facade_test 197*61c4878aSAndroid Build Coastguard Worker SOURCES 198*61c4878aSAndroid Build Coastguard Worker sleep_facade_test.cc 199*61c4878aSAndroid Build Coastguard Worker sleep_facade_test_c.c 200*61c4878aSAndroid Build Coastguard Worker PRIVATE_DEPS 201*61c4878aSAndroid Build Coastguard Worker pw_chrono.system_clock 202*61c4878aSAndroid Build Coastguard Worker pw_thread.sleep 203*61c4878aSAndroid Build Coastguard Worker pw_thread.thread 204*61c4878aSAndroid Build Coastguard Worker GROUPS 205*61c4878aSAndroid Build Coastguard Worker modules 206*61c4878aSAndroid Build Coastguard Worker pw_thread 207*61c4878aSAndroid Build Coastguard Worker ) 208*61c4878aSAndroid Build Coastguard Workerendif() 209*61c4878aSAndroid Build Coastguard Worker 210*61c4878aSAndroid Build Coastguard Workerpw_add_library(pw_thread.non_portable_test_thread_options INTERFACE 211*61c4878aSAndroid Build Coastguard Worker HEADERS 212*61c4878aSAndroid Build Coastguard Worker public/pw_thread/non_portable_test_thread_options.h 213*61c4878aSAndroid Build Coastguard Worker PUBLIC_INCLUDES 214*61c4878aSAndroid Build Coastguard Worker public 215*61c4878aSAndroid Build Coastguard Worker PUBLIC_DEPS 216*61c4878aSAndroid Build Coastguard Worker pw_thread.thread 217*61c4878aSAndroid Build Coastguard Worker) 218*61c4878aSAndroid Build Coastguard Worker 219*61c4878aSAndroid Build Coastguard Worker# To instantiate this facade test based on a selected backend to provide 220*61c4878aSAndroid Build Coastguard Worker# test_threads you can create a pw_add_test target which depends on this 221*61c4878aSAndroid Build Coastguard Worker# target and a target which provides the implementation of 222*61c4878aSAndroid Build Coastguard Worker# test_threads. See pw_thread_stl.thread_backend_test as an example. 223*61c4878aSAndroid Build Coastguard Workerpw_add_library(pw_thread.thread_facade_test STATIC 224*61c4878aSAndroid Build Coastguard Worker SOURCES 225*61c4878aSAndroid Build Coastguard Worker thread_facade_test.cc 226*61c4878aSAndroid Build Coastguard Worker PRIVATE_DEPS 227*61c4878aSAndroid Build Coastguard Worker pw_thread.sleep 228*61c4878aSAndroid Build Coastguard Worker pw_thread.non_portable_test_thread_options 229*61c4878aSAndroid Build Coastguard Worker pw_thread.thread 230*61c4878aSAndroid Build Coastguard Worker pw_sync.binary_semaphore 231*61c4878aSAndroid Build Coastguard Worker pw_unit_test 232*61c4878aSAndroid Build Coastguard Worker) 233*61c4878aSAndroid Build Coastguard Worker 234*61c4878aSAndroid Build Coastguard Workerif((NOT "${pw_thread.id_BACKEND}" STREQUAL "") AND 235*61c4878aSAndroid Build Coastguard Worker (NOT "${pw_thread.yield_BACKEND}" STREQUAL "")) 236*61c4878aSAndroid Build Coastguard Worker pw_add_test(pw_thread.yield_facade_test 237*61c4878aSAndroid Build Coastguard Worker SOURCES 238*61c4878aSAndroid Build Coastguard Worker yield_facade_test.cc 239*61c4878aSAndroid Build Coastguard Worker yield_facade_test_c.c 240*61c4878aSAndroid Build Coastguard Worker PRIVATE_DEPS 241*61c4878aSAndroid Build Coastguard Worker pw_thread.thread 242*61c4878aSAndroid Build Coastguard Worker pw_thread.yield 243*61c4878aSAndroid Build Coastguard Worker GROUPS 244*61c4878aSAndroid Build Coastguard Worker modules 245*61c4878aSAndroid Build Coastguard Worker pw_thread 246*61c4878aSAndroid Build Coastguard Worker ) 247*61c4878aSAndroid Build Coastguard Workerendif() 248*61c4878aSAndroid Build Coastguard Worker 249*61c4878aSAndroid Build Coastguard Workerif(NOT "${pw_thread.test_thread_context_BACKEND}" STREQUAL "") 250*61c4878aSAndroid Build Coastguard Worker pw_add_test(pw_thread.test_thread_context_facade_test 251*61c4878aSAndroid Build Coastguard Worker SOURCES 252*61c4878aSAndroid Build Coastguard Worker test_thread_context_facade_test.cc 253*61c4878aSAndroid Build Coastguard Worker PRIVATE_DEPS 254*61c4878aSAndroid Build Coastguard Worker pw_thread.test_thread_context 255*61c4878aSAndroid Build Coastguard Worker pw_thread.thread 256*61c4878aSAndroid Build Coastguard Worker pw_sync.binary_semaphore 257*61c4878aSAndroid Build Coastguard Worker ) 258*61c4878aSAndroid Build Coastguard Workerendif() 259