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 15load( 16 "//pw_build:pigweed.bzl", 17 "pw_cc_test", 18) 19load( 20 "//pw_build:selects.bzl", 21 "TARGET_COMPATIBLE_WITH_HOST_SELECT", 22) 23 24package(default_visibility = ["//visibility:public"]) 25 26licenses(["notice"]) 27 28cc_library( 29 name = "id", 30 hdrs = [ 31 "id_public_overrides/pw_thread_backend/id_inline.h", 32 "id_public_overrides/pw_thread_backend/id_native.h", 33 "public/pw_thread_stl/id_inline.h", 34 "public/pw_thread_stl/id_native.h", 35 ], 36 includes = [ 37 "id_public_overrides", 38 "public", 39 ], 40 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 41 deps = [ 42 "//pw_thread:id_facade", 43 ], 44) 45 46cc_library( 47 name = "sleep", 48 hdrs = [ 49 "public/pw_thread_stl/sleep_inline.h", 50 "sleep_public_overrides/pw_thread_backend/sleep_inline.h", 51 ], 52 includes = [ 53 "public", 54 "sleep_public_overrides", 55 ], 56 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 57 deps = [ 58 "//pw_chrono:system_clock", 59 "//pw_thread:sleep_facade", 60 ], 61) 62 63cc_library( 64 name = "thread", 65 hdrs = [ 66 "public/pw_thread_stl/options.h", 67 "public/pw_thread_stl/thread_inline.h", 68 "public/pw_thread_stl/thread_native.h", 69 "thread_public_overrides/pw_thread_backend/thread_inline.h", 70 "thread_public_overrides/pw_thread_backend/thread_native.h", 71 ], 72 includes = [ 73 "public", 74 "thread_public_overrides", 75 ], 76 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 77 deps = [ 78 "//pw_thread:thread_facade", 79 ], 80) 81 82# This target provides a stub backend for pw::this_thread::thread_iteration. 83# Iterating over child threads isn't supported by STL, so this only exists 84# for portability reasons. 85cc_library( 86 name = "thread_iteration", 87 srcs = ["thread_iteration.cc"], 88 deps = [ 89 "//pw_status", 90 "//pw_thread:thread_iteration.facade", 91 ], 92) 93 94cc_library( 95 name = "non_portable_test_thread_options", 96 srcs = [ 97 "test_threads.cc", 98 ], 99 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 100 deps = [ 101 "//pw_thread:non_portable_test_thread_options", 102 "//pw_thread:thread_facade", 103 ], 104) 105 106pw_cc_test( 107 name = "thread_backend_test", 108 # TODO: b/317922402 - On Windows, this test can easily hang indefinitely. 109 # Disable on Windows until we can test with the native Windows SDK libraries 110 # for threading. 111 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT | { 112 "@platforms//os:windows": ["@platforms//:incompatible"], 113 }), 114 deps = [ 115 ":non_portable_test_thread_options", 116 "//pw_thread:thread_facade_test", 117 ], 118) 119 120cc_library( 121 name = "yield", 122 hdrs = [ 123 "public/pw_thread_stl/yield_inline.h", 124 "yield_public_overrides/pw_thread_backend/yield_inline.h", 125 ], 126 includes = [ 127 "public", 128 "yield_public_overrides", 129 ], 130 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 131 deps = [ 132 "//pw_thread:yield_facade", 133 ], 134) 135 136cc_library( 137 name = "test_thread_context", 138 hdrs = [ 139 "public/pw_thread_stl/test_thread_context_native.h", 140 "test_thread_context_public_overrides/pw_thread_backend/test_thread_context_native.h", 141 ], 142 includes = [ 143 "public", 144 "test_thread_context_public_overrides", 145 ], 146 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 147 deps = [ 148 ":thread", 149 "//pw_thread:test_thread_context_facade", 150 ], 151) 152