1# Copyright (c) 2014 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("//build/config/android/config.gni")
10import("../build/webrtc.gni")
11
12static_library("system_wrappers") {
13  sources = [
14    "include/aligned_array.h",
15    "include/aligned_malloc.h",
16    "include/atomic32.h",
17    "include/clock.h",
18    "include/condition_variable_wrapper.h",
19    "include/cpu_features_wrapper.h",
20    "include/cpu_info.h",
21    "include/critical_section_wrapper.h",
22    "include/data_log.h",
23    "include/data_log_c.h",
24    "include/data_log_impl.h",
25    "include/event_wrapper.h",
26    "include/field_trial.h",
27    "include/file_wrapper.h",
28    "include/fix_interlocked_exchange_pointer_win.h",
29    "include/logging.h",
30    "include/metrics.h",
31    "include/ref_count.h",
32    "include/rtp_to_ntp.h",
33    "include/rw_lock_wrapper.h",
34    "include/scoped_vector.h",
35    "include/sleep.h",
36    "include/sort.h",
37    "include/static_instance.h",
38    "include/stl_util.h",
39    "include/stringize_macros.h",
40    "include/tick_util.h",
41    "include/timestamp_extrapolator.h",
42    "include/trace.h",
43    "include/utf_util_win.h",
44    "source/aligned_malloc.cc",
45    "source/atomic32_mac.cc",
46    "source/atomic32_win.cc",
47    "source/clock.cc",
48    "source/condition_variable.cc",
49    "source/condition_variable_event_win.cc",
50    "source/condition_variable_event_win.h",
51    "source/condition_variable_native_win.cc",
52    "source/condition_variable_native_win.h",
53    "source/condition_variable_posix.cc",
54    "source/condition_variable_posix.h",
55    "source/cpu_features.cc",
56    "source/cpu_info.cc",
57    "source/critical_section.cc",
58    "source/critical_section_posix.cc",
59    "source/critical_section_posix.h",
60    "source/critical_section_win.cc",
61    "source/critical_section_win.h",
62    "source/data_log_c.cc",
63    "source/event.cc",
64    "source/event_timer_posix.cc",
65    "source/event_timer_posix.h",
66    "source/event_timer_win.cc",
67    "source/event_timer_win.h",
68    "source/file_impl.cc",
69    "source/file_impl.h",
70    "source/logging.cc",
71    "source/rtp_to_ntp.cc",
72    "source/rw_lock.cc",
73    "source/rw_lock_generic.cc",
74    "source/rw_lock_generic.h",
75    "source/rw_lock_posix.cc",
76    "source/rw_lock_posix.h",
77    "source/rw_lock_win.cc",
78    "source/rw_lock_win.h",
79    "source/sleep.cc",
80    "source/sort.cc",
81    "source/tick_util.cc",
82    "source/timestamp_extrapolator.cc",
83    "source/trace_impl.cc",
84    "source/trace_impl.h",
85    "source/trace_posix.cc",
86    "source/trace_posix.h",
87    "source/trace_win.cc",
88    "source/trace_win.h",
89  ]
90
91  configs += [ "..:common_config" ]
92
93  public_configs = [ "..:common_inherited_config" ]
94
95  if (rtc_enable_data_logging) {
96    sources += [ "source/data_log.cc" ]
97  } else {
98    sources += [ "source/data_log_no_op.cc" ]
99  }
100
101  defines = []
102  libs = []
103  deps = [
104    "..:webrtc_common",
105  ]
106
107  if (is_android) {
108    sources += [
109      "include/logcat_trace_context.h",
110      "source/logcat_trace_context.cc",
111    ]
112
113    defines += [
114      "WEBRTC_THREAD_RR",
115
116      # TODO(leozwang): Investigate CLOCK_REALTIME and CLOCK_MONOTONIC
117      # support on Android. Keep WEBRTC_CLOCK_TYPE_REALTIME for now,
118      # remove it after I verify that CLOCK_MONOTONIC is fully functional
119      # with condition and event functions in system_wrappers.
120      "WEBRTC_CLOCK_TYPE_REALTIME",
121    ]
122
123    deps += [ ":cpu_features_android" ]
124
125    libs += [ "log" ]
126  }
127
128  if (is_linux) {
129    defines += [
130      "WEBRTC_THREAD_RR",
131      # TODO(andrew): can we select this automatically?
132      # Define this if the Linux system does not support CLOCK_MONOTONIC.
133      #"WEBRTC_CLOCK_TYPE_REALTIME",
134    ]
135
136    libs += [ "rt" ]
137  }
138
139  if (!is_mac && !is_ios) {
140    sources += [ "source/atomic32_posix.cc" ]
141  }
142
143  if (is_ios || is_mac) {
144    defines += [
145      "WEBRTC_THREAD_RR",
146      "WEBRTC_CLOCK_TYPE_REALTIME",
147    ]
148  }
149
150  if (is_ios) {
151    sources += [ "source/atomic32_mac.cc" ]
152  }
153
154  if (is_win) {
155    libs += [ "winmm.lib" ]
156
157    cflags = [
158      "/wd4267",  # size_t to int truncation.
159      "/wd4334",  # Ignore warning on shift operator promotion.
160    ]
161  }
162
163  deps += [ "../base:rtc_base_approved" ]
164}
165
166source_set("field_trial_default") {
167  sources = [
168    "include/field_trial_default.h",
169    "source/field_trial_default.cc",
170  ]
171
172  configs += [ "..:common_config" ]
173  public_configs = [ "..:common_inherited_config" ]
174}
175
176source_set("metrics_default") {
177  sources = [
178    "source/metrics_default.cc",
179  ]
180
181  configs += [ "..:common_config" ]
182  public_configs = [ "..:common_inherited_config" ]
183}
184
185source_set("system_wrappers_default") {
186  configs += [ "..:common_config" ]
187  public_configs = [ "..:common_inherited_config" ]
188
189  deps = [
190    ":field_trial_default",
191    ":metrics_default",
192    ":system_wrappers",
193  ]
194}
195
196if (is_android) {
197  source_set("cpu_features_android") {
198    sources = [
199      "source/cpu_features_android.c",
200    ]
201
202    configs += [ "..:common_config" ]
203    public_configs = [ "..:common_inherited_config" ]
204    deps = [
205      "//third_party/android_tools:cpu_features",
206    ]
207  }
208}
209