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