xref: /aosp_15_r20/external/webrtc/rtc_base/synchronization/BUILD.gn (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS.  All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
8
9import("//third_party/google_benchmark/buildconfig.gni")
10import("../../webrtc.gni")
11if (is_android) {
12  import("//build/config/android/config.gni")
13  import("//build/config/android/rules.gni")
14}
15
16rtc_library("yield") {
17  sources = [
18    "yield.cc",
19    "yield.h",
20  ]
21  deps = []
22}
23
24rtc_source_set("mutex") {
25  sources = [
26    "mutex.h",
27    "mutex_critical_section.h",
28    "mutex_pthread.h",
29  ]
30  if (rtc_use_absl_mutex) {
31    sources += [ "mutex_abseil.h" ]
32  }
33
34  deps = [
35    ":yield",
36    "..:checks",
37    "..:macromagic",
38    "..:platform_thread_types",
39    "../system:no_unique_address",
40  ]
41  absl_deps = [ "//third_party/abseil-cpp/absl/base:core_headers" ]
42  if (rtc_use_absl_mutex) {
43    absl_deps += [ "//third_party/abseil-cpp/absl/synchronization" ]
44  }
45}
46
47rtc_library("sequence_checker_internal") {
48  visibility = [ "../../api:sequence_checker" ]
49  sources = [
50    "sequence_checker_internal.cc",
51    "sequence_checker_internal.h",
52  ]
53  deps = [
54    ":mutex",
55    "..:checks",
56    "..:macromagic",
57    "..:platform_thread_types",
58    "..:stringutils",
59    "../../api/task_queue",
60    "../system:rtc_export",
61  ]
62}
63
64rtc_library("yield_policy") {
65  sources = [
66    "yield_policy.cc",
67    "yield_policy.h",
68  ]
69  deps = [ "..:checks" ]
70  absl_deps = [
71    "//third_party/abseil-cpp/absl/base:config",
72    "//third_party/abseil-cpp/absl/base:core_headers",
73  ]
74}
75
76if (rtc_include_tests) {
77  if (enable_google_benchmarks) {
78    rtc_library("synchronization_unittests") {
79      testonly = true
80      sources = [
81        "mutex_unittest.cc",
82        "yield_policy_unittest.cc",
83      ]
84      deps = [
85        ":mutex",
86        ":yield",
87        ":yield_policy",
88        "..:checks",
89        "..:macromagic",
90        "..:platform_thread",
91        "..:rtc_base",
92        "..:rtc_event",
93        "..:threading",
94        "../../test:test_support",
95        "//third_party/google_benchmark",
96      ]
97    }
98
99    rtc_library("mutex_benchmark") {
100      testonly = true
101      sources = [ "mutex_benchmark.cc" ]
102      deps = [
103        ":mutex",
104        "../system:unused",
105        "//third_party/google_benchmark",
106      ]
107    }
108  }
109}
110