1# 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 17# This target provides the backend for pw::Thread::id & pw::this_thread::get_id. 18pw_add_library(pw_thread_stl.id INTERFACE 19 HEADERS 20 public/pw_thread_stl/id_inline.h 21 public/pw_thread_stl/id_native.h 22 id_public_overrides/pw_thread_backend/id_inline.h 23 id_public_overrides/pw_thread_backend/id_native.h 24 PUBLIC_INCLUDES 25 public 26 id_public_overrides 27 PUBLIC_DEPS 28 pw_thread.thread.facade 29) 30 31# This target provides the backend for pw::Thread with joining capability. 32pw_add_library(pw_thread_stl.thread INTERFACE 33 HEADERS 34 public/pw_thread_stl/options.h 35 public/pw_thread_stl/thread_inline.h 36 public/pw_thread_stl/thread_native.h 37 thread_public_overrides/pw_thread_backend/thread_inline.h 38 thread_public_overrides/pw_thread_backend/thread_native.h 39 PUBLIC_INCLUDES 40 public 41 thread_public_overrides 42 PUBLIC_DEPS 43 pw_thread.thread.facade 44) 45 46pw_add_library(pw_thread_stl.thread_creation INTERFACE 47 HEADERS 48 thread_creation_public_overrides/pw_thread_backend/context.h 49 thread_creation_public_overrides/pw_thread_backend/options.h 50 thread_creation_public_overrides/pw_thread_backend/priority.h 51 thread_creation_public_overrides/pw_thread_backend/stack.h 52 PUBLIC_INCLUDES 53 thread_creation_public_overrides 54 PUBLIC_DEPS 55 pw_thread_stl.thread 56) 57 58# This target provides the backend for pw::this_thread::sleep_{for,until}. 59pw_add_library(pw_thread_stl.sleep INTERFACE 60 HEADERS 61 public/pw_thread_stl/sleep_inline.h 62 sleep_public_overrides/pw_thread_backend/sleep_inline.h 63 PUBLIC_INCLUDES 64 public 65 sleep_public_overrides 66 PUBLIC_DEPS 67 pw_chrono.system_clock 68 pw_thread.sleep.facade 69) 70 71# This target provides the backend for pw::this_thread::yield. 72pw_add_library(pw_thread_stl.yield INTERFACE 73 HEADERS 74 public/pw_thread_stl/yield_inline.h 75 yield_public_overrides/pw_thread_backend/yield_inline.h 76 PUBLIC_INCLUDES 77 public 78 yield_public_overrides 79 PUBLIC_DEPS 80 pw_thread.yield.facade 81) 82 83# This target provides the backend for pw::thread::test::TestThreadContext. 84pw_add_library(pw_thread_stl.test_thread_context INTERFACE 85 HEADERS 86 public/pw_thread_stl/test_thread_context_native.h 87 test_thread_context_public_overrides/pw_thread_backend/test_thread_context_native.h 88 PUBLIC_INCLUDES 89 public 90 test_thread_context_public_overrides 91 PUBLIC_DEPS 92 pw_thread_stl.thread 93 pw_thread.test_thread_context.facade 94) 95 96pw_add_library(pw_thread_stl.test_threads STATIC 97 PUBLIC_DEPS 98 pw_thread.non_portable_test_thread_options 99 SOURCES 100 test_threads.cc 101 PRIVATE_DEPS 102 pw_thread.thread 103) 104 105pw_add_library(pw_thread_stl.thread_iteration STATIC 106 PRIVATE_DEPS 107 pw_status 108 SOURCES 109 thread_iteration.cc 110 PUBLIC_DEPS 111 pw_thread.thread_iteration.facade 112) 113 114if(("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") AND 115 (NOT "${pw_thread.sleep_BACKEND}" STREQUAL "")) 116 pw_add_test(pw_thread_stl.thread_backend_test 117 PRIVATE_DEPS 118 pw_thread_stl.test_threads 119 pw_thread.thread_facade_test 120 GROUPS 121 modules 122 pw_thread_stl 123 ) 124endif() 125