mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 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. |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 8 | import("//build/config/arm.gni") |
| 9 | import("//build/config/features.gni") |
| 10 | import("//build/config/mips.gni") |
Maksim Sisov | ef4d0b6 | 2021-09-20 06:02:01 | [diff] [blame] | 11 | import("//build/config/ozone.gni") |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 12 | import("//build/config/sanitizers/sanitizers.gni") |
Tomas Popela | 318da51 | 2018-11-13 05:32:23 | [diff] [blame] | 13 | import("//build/config/sysroot.gni") |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 14 | import("//build_overrides/build.gni") |
mbonadei | 9660627 | 2017-03-04 03:41:59 | [diff] [blame] | 15 | |
| 16 | if (!build_with_chromium && is_component_build) { |
| 17 | print("The Gn argument `is_component_build` is currently " + |
| 18 | "ignored for WebRTC builds.") |
| 19 | print("Component builds are supported by Chromium and the argument " + |
| 20 | "`is_component_build` makes it possible to create shared libraries " + |
| 21 | "instead of static libraries.") |
| 22 | print("If an app depends on WebRTC it makes sense to just depend on the " + |
| 23 | "WebRTC static library, so there is no difference between " + |
| 24 | "`is_component_build=true` and `is_component_build=false`.") |
| 25 | print( |
Fanny Linderborg | 0d2dc1f | 2021-07-14 14:02:11 | [diff] [blame] | 26 | "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/main/docs/component_build.md") |
mbonadei | 9660627 | 2017-03-04 03:41:59 | [diff] [blame] | 27 | assert(!is_component_build, "Component builds are not supported in WebRTC.") |
| 28 | } |
| 29 | |
kthelgason | 4065a576 | 2017-02-14 12:58:56 | [diff] [blame] | 30 | if (is_ios) { |
| 31 | import("//build/config/ios/rules.gni") |
| 32 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 33 | |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 34 | if (is_mac) { |
| 35 | import("//build/config/mac/rules.gni") |
| 36 | } |
| 37 | |
Christoffer Jansson | 25e4156 | 2022-09-23 06:38:54 | [diff] [blame] | 38 | if (is_fuchsia) { |
| 39 | import("//build/config/fuchsia/config.gni") |
| 40 | } |
| 41 | |
Mirko Bonadei | e3b4263 | 2024-03-27 12:13:52 | [diff] [blame] | 42 | if (build_with_chromium) { |
| 43 | import("//media/media_options.gni") |
| 44 | } |
| 45 | |
Mirko Bonadei | 5f07845 | 2021-07-30 20:32:55 | [diff] [blame] | 46 | # This declare_args is separated from the next one because args declared |
| 47 | # in this one, can be read from the next one (args defined in the same |
| 48 | # declare_args cannot be referenced in that scope). |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 49 | declare_args() { |
Mirko Bonadei | 028248c | 2018-10-10 10:19:02 | [diff] [blame] | 50 | # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h) |
| 51 | # expand to code that will manage symbols visibility. |
| 52 | rtc_enable_symbol_export = false |
Mirko Bonadei | 5f07845 | 2021-07-30 20:32:55 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | declare_args() { |
Mirko Bonadei | 2bfa071 | 2023-08-07 09:54:35 | [diff] [blame] | 56 | # If set to true, C++ code will refer to the new JNI Generator symbols. |
| 57 | # If set to false the old ones will be used (to provide a nice update path). |
| 58 | rtc_jni_generator_legacy_symbols = false |
| 59 | |
Mirko Bonadei | 339965f | 2021-10-12 11:23:44 | [diff] [blame] | 60 | # Setting this to true, will make RTC_DLOG() expand to log statements instead |
Mirko Bonadei | 56ed468 | 2021-10-12 06:55:42 | [diff] [blame] | 61 | # of being removed by the preprocessor. |
| 62 | # This is useful for example to be able to get RTC_DLOGs on a release build. |
| 63 | rtc_dlog_always_on = false |
| 64 | |
Peter Kasting | 1e6d77c | 2023-03-13 23:01:00 | [diff] [blame] | 65 | # Enables additional build targets that rely on |
| 66 | # //third_party/google_benchmarks. |
| 67 | rtc_enable_google_benchmarks = true |
| 68 | |
Mirko Bonadei | 5f07845 | 2021-07-30 20:32:55 | [diff] [blame] | 69 | # Setting this to true will make RTC_OBJC_EXPORT expand to code that will |
| 70 | # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported |
| 71 | # if C++ symbols are but setting this arg to true while keeping |
| 72 | # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT |
| 73 | # annotated symbols. |
| 74 | rtc_enable_objc_symbol_export = rtc_enable_symbol_export |
Mirko Bonadei | 028248c | 2018-10-10 10:19:02 | [diff] [blame] | 75 | |
Mirko Bonadei | 31b0b45 | 2018-08-22 08:37:11 | [diff] [blame] | 76 | # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which |
Mirko Bonadei | 7040090 | 2018-08-21 13:44:28 | [diff] [blame] | 77 | # will tell the pre-processor to remove the default definition of symbols |
| 78 | # needed to use field_trial. In that case a new implementation needs to be |
| 79 | # provided. |
Mirko Bonadei | 31b0b45 | 2018-08-22 08:37:11 | [diff] [blame] | 80 | if (build_with_chromium) { |
| 81 | # When WebRTC is built as part of Chromium it should exclude the default |
| 82 | # implementation of field_trial unless it is building for NACL or |
| 83 | # Chromecast. |
Ryan Keane | cf7802d | 2022-06-10 21:33:18 | [diff] [blame] | 84 | rtc_exclude_field_trial_default = !is_nacl && !is_castos && !is_cast_android |
Mirko Bonadei | 31b0b45 | 2018-08-22 08:37:11 | [diff] [blame] | 85 | } else { |
| 86 | rtc_exclude_field_trial_default = false |
| 87 | } |
Mirko Bonadei | 7040090 | 2018-08-21 13:44:28 | [diff] [blame] | 88 | |
Mirko Bonadei | 906add4 | 2018-09-05 14:03:16 | [diff] [blame] | 89 | # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which |
| 90 | # will tell the pre-processor to remove the default definition of symbols |
| 91 | # needed to use metrics. In that case a new implementation needs to be |
| 92 | # provided. |
| 93 | rtc_exclude_metrics_default = build_with_chromium |
| 94 | |
Johannes Kron | da20c73 | 2021-02-19 15:39:41 | [diff] [blame] | 95 | # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which |
| 96 | # will tell the pre-processor to remove the default definition of the |
| 97 | # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In |
| 98 | # that case a new implementation needs to be provided. |
Johannes Kron | bb52bdf | 2021-02-25 09:10:08 | [diff] [blame] | 99 | rtc_exclude_system_time = build_with_chromium |
Johannes Kron | da20c73 | 2021-02-19 15:39:41 | [diff] [blame] | 100 | |
Benjamin Wright | d6f86e8 | 2018-05-08 20:12:25 | [diff] [blame] | 101 | # Setting this to false will require the API user to pass in their own |
| 102 | # SSLCertificateVerifier to verify the certificates presented from a |
| 103 | # TLS-TURN server. In return disabling this saves around 100kb in the binary. |
| 104 | rtc_builtin_ssl_root_certificates = true |
| 105 | |
Karl Wiberg | eb254b4 | 2017-11-01 14:08:12 | [diff] [blame] | 106 | # Include the iLBC audio codec? |
Olga Sharonova | 5fbd758 | 2020-07-09 09:50:42 | [diff] [blame] | 107 | rtc_include_ilbc = true |
Karl Wiberg | eb254b4 | 2017-11-01 14:08:12 | [diff] [blame] | 108 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 109 | # Disable this to avoid building the Opus audio codec. |
| 110 | rtc_include_opus = true |
| 111 | |
minyue | 2e03c66 | 2017-02-02 01:31:11 | [diff] [blame] | 112 | # Enable this if the Opus version upon which WebRTC is built supports direct |
| 113 | # encoding of 120 ms packets. |
minyue-webrtc | 516711c | 2017-07-27 15:45:49 | [diff] [blame] | 114 | rtc_opus_support_120ms_ptime = true |
minyue | 2e03c66 | 2017-02-02 01:31:11 | [diff] [blame] | 115 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 116 | # Enable this to let the Opus audio codec change complexity on the fly. |
| 117 | rtc_opus_variable_complexity = false |
| 118 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 119 | # Used to specify an external Jsoncpp include path when not compiling the |
| 120 | # library that comes with WebRTC (i.e. rtc_build_json == 0). |
| 121 | rtc_jsoncpp_root = "//third_party/jsoncpp/source/include" |
| 122 | |
| 123 | # Used to specify an external OpenSSL include path when not compiling the |
| 124 | # library that comes with WebRTC (i.e. rtc_build_ssl == 0). |
| 125 | rtc_ssl_root = "" |
| 126 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 127 | # Enable when an external authentication mechanism is used for performing |
| 128 | # packet authentication for RTP packets instead of libsrtp. |
| 129 | rtc_enable_external_auth = build_with_chromium |
| 130 | |
| 131 | # Selects whether debug dumps for the audio processing module |
| 132 | # should be generated. |
| 133 | apm_debug_dump = false |
| 134 | |
Per Åhgren | cc73ed3 | 2020-04-26 21:56:17 | [diff] [blame] | 135 | # Selects whether the audio processing module should be excluded. |
| 136 | rtc_exclude_audio_processing_module = false |
| 137 | |
Joachim Bauch | 93e9134 | 2017-12-07 00:25:53 | [diff] [blame] | 138 | # Set this to false to skip building examples. |
| 139 | rtc_build_examples = true |
| 140 | |
| 141 | # Set this to false to skip building tools. |
| 142 | rtc_build_tools = true |
| 143 | |
Joachim Bauch | 75f18fc | 2017-12-20 20:25:47 | [diff] [blame] | 144 | # Set this to false to skip building code that requires X11. |
Maksim Sisov | ef4d0b6 | 2021-09-20 06:02:01 | [diff] [blame] | 145 | rtc_use_x11 = ozone_platform_x11 |
Joachim Bauch | 75f18fc | 2017-12-20 20:25:47 | [diff] [blame] | 146 | |
Tomas Popela | 318da51 | 2018-11-13 05:32:23 | [diff] [blame] | 147 | # Set this to use PipeWire on the Wayland display server. |
Tomas Popela | 762543f | 2018-12-12 13:37:51 | [diff] [blame] | 148 | # By default it's only enabled on desktop Linux (excludes ChromeOS) and |
| 149 | # only when using the sysroot as PipeWire is not available in older and |
| 150 | # supported Ubuntu and Debian distributions. |
Artem Titov | 4d6a76d | 2021-09-03 10:07:20 | [diff] [blame] | 151 | rtc_use_pipewire = is_linux && use_sysroot |
Tomas Popela | 762543f | 2018-12-12 13:37:51 | [diff] [blame] | 152 | |
Jan Grulich | e1e05af | 2021-09-21 18:36:16 | [diff] [blame] | 153 | # Set this to link PipeWire and required libraries directly instead of using the dlopen. |
Tomas Popela | 762543f | 2018-12-12 13:37:51 | [diff] [blame] | 154 | rtc_link_pipewire = false |
Tomas Popela | 318da51 | 2018-11-13 05:32:23 | [diff] [blame] | 155 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 156 | # Enable to use the Mozilla internal settings. |
| 157 | build_with_mozilla = false |
| 158 | |
Philipp Hancke | e95ebda | 2020-09-17 14:13:20 | [diff] [blame] | 159 | # Experimental: enable use of Android AAudio which requires Android SDK 26 or above |
| 160 | # and NDK r16 or above. |
henrika | 883d00f | 2018-03-16 09:09:49 | [diff] [blame] | 161 | rtc_enable_android_aaudio = false |
| 162 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 163 | # Set to "func", "block", "edge" for coverage generation. |
| 164 | # At unit test runtime set UBSAN_OPTIONS="coverage=1". |
| 165 | # It is recommend to set include_examples=0. |
| 166 | # Use llvm's sancov -html-report for human readable reports. |
| 167 | # See http://clang.llvm.org/docs/SanitizerCoverage.html . |
| 168 | rtc_sanitize_coverage = "" |
| 169 | |
Philipp Hancke | aeac9f8 | 2020-09-11 09:58:18 | [diff] [blame] | 170 | # Selects fixed-point code where possible. |
| 171 | rtc_prefer_fixed_point = false |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 172 | if (current_cpu == "arm" || current_cpu == "arm64") { |
| 173 | rtc_prefer_fixed_point = true |
| 174 | } |
| 175 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 176 | # Determines whether NEON code will be built. |
| 177 | rtc_build_with_neon = |
| 178 | (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64" |
| 179 | |
| 180 | # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on |
| 181 | # all platforms except Android and iOS. Because FFmpeg can be built |
Artem Titov | 22a6b2d | 2021-07-27 14:25:56 | [diff] [blame] | 182 | # with/without H.264 support, `ffmpeg_branding` has to separately be set to a |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 183 | # value that includes H.264, for example "Chrome". If FFmpeg is built without |
Artem Titov | 22a6b2d | 2021-07-27 14:25:56 | [diff] [blame] | 184 | # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize. |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 185 | # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING. |
| 186 | # http://www.openh264.org, https://www.ffmpeg.org/ |
Mirko Bonadei | ee0a85c | 2019-01-15 09:47:18 | [diff] [blame] | 187 | # |
| 188 | # Enabling H264 when building with MSVC is currently not supported, see |
| 189 | # bugs.webrtc.org/9213#c13 for more info. |
| 190 | rtc_use_h264 = |
| 191 | proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang) |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 192 | |
Jan Grulich | 0f86252 | 2024-04-29 14:16:28 | [diff] [blame] | 193 | # Use system OpenH264 |
| 194 | rtc_system_openh264 = false |
| 195 | |
qwu16 | 972f283 | 2023-08-15 09:16:54 | [diff] [blame] | 196 | # Enable to use H265 |
Mirko Bonadei | e3b4263 | 2024-03-27 12:13:52 | [diff] [blame] | 197 | if (build_with_chromium) { |
| 198 | rtc_use_h265 = enable_hevc_parser_and_hw_decoder |
| 199 | } else { |
| 200 | rtc_use_h265 = proprietary_codecs |
| 201 | } |
qwu16 | 972f283 | 2023-08-15 09:16:54 | [diff] [blame] | 202 | |
Markus Handell | 8e75bd4 | 2020-06-05 09:47:40 | [diff] [blame] | 203 | # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex. |
| 204 | rtc_use_absl_mutex = false |
| 205 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 206 | # By default, use normal platform audio support or dummy audio, but don't |
| 207 | # use file-based audio playout and record. |
| 208 | rtc_use_dummy_audio_file_devices = false |
| 209 | |
henrika | 7be7883 | 2017-06-13 15:34:16 | [diff] [blame] | 210 | # When set to true, replace the audio output with a sinus tone at 440Hz. |
| 211 | # The ADM will ask for audio data from WebRTC but instead of reading real |
| 212 | # audio samples from NetEQ, a sinus tone will be generated and replace the |
| 213 | # real audio samples. |
| 214 | rtc_audio_device_plays_sinus_tone = false |
| 215 | |
Anders Carlsson | 358f2e0 | 2018-06-04 08:24:37 | [diff] [blame] | 216 | if (is_ios) { |
| 217 | # Build broadcast extension in AppRTCMobile for iOS. This results in the |
| 218 | # binary only running on iOS 11+, which is why it is disabled by default. |
| 219 | rtc_apprtcmobile_broadcast_extension = false |
| 220 | } |
Anders Carlsson | 7bca8ca | 2018-08-30 07:30:29 | [diff] [blame] | 221 | |
Kári Tristan Helgason | ba50cb3 | 2023-06-28 12:32:04 | [diff] [blame] | 222 | # Determines whether OpenGL is available on iOS. |
| 223 | rtc_ios_use_opengl_rendering = is_ios && target_environment != "catalyst" |
Jordan Rose | 53d3fc9 | 2021-07-06 19:16:41 | [diff] [blame] | 224 | |
Jiawei Ou | 0874530 | 2019-02-12 19:36:13 | [diff] [blame] | 225 | # When set to false, builtin audio encoder/decoder factories and all the |
| 226 | # audio codecs they depend on will not be included in libwebrtc.{a|lib} |
| 227 | # (they will still be included in libjingle_peerconnection_so.so and |
| 228 | # WebRTC.framework) |
| 229 | rtc_include_builtin_audio_codecs = true |
| 230 | |
Mirko Bonadei | 20574f4 | 2019-03-28 06:50:07 | [diff] [blame] | 231 | # When set to true and in a standalone build, it will undefine UNICODE and |
| 232 | # _UNICODE (which are always defined globally by the Chromium Windows |
| 233 | # toolchain). |
| 234 | # This is only needed for testing purposes, WebRTC wants to be sure it |
| 235 | # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses |
| 236 | # wide character functions. |
| 237 | rtc_win_undef_unicode = false |
Austin Orion | 25b0dee | 2020-10-01 20:47:54 | [diff] [blame] | 238 | |
| 239 | # When set to true, a capturer implementation that uses the |
Austin Orion | 66241e4 | 2021-04-22 20:22:25 | [diff] [blame] | 240 | # Windows.Graphics.Capture APIs will be available for use. This introduces a |
| 241 | # dependency on the Win 10 SDK v10.0.17763.0. |
Austin Orion | 78f04d8 | 2021-04-23 19:37:26 | [diff] [blame] | 242 | rtc_enable_win_wgc = is_win |
philipel | b09d872 | 2021-11-23 10:00:24 | [diff] [blame] | 243 | |
| 244 | # Includes the dav1d decoder in the internal decoder factory when set to true. |
| 245 | rtc_include_dav1d_in_internal_decoder_factory = true |
Emil Lundmark | 6bf20cc | 2022-09-21 13:20:22 | [diff] [blame] | 246 | |
Emil Lundmark | 9109e85 | 2023-02-28 12:57:01 | [diff] [blame] | 247 | # When enabled, a run-time check will make sure that all field trial keys have |
| 248 | # been registered in accordance with the field trial policy, see |
| 249 | # g3doc/field-trials.md. The value can be set to the following: |
| 250 | # |
| 251 | # "dcheck": RTC_DCHECKs that the field trial has been registered. RTC_DCHECK |
| 252 | # must be enabled separately. |
| 253 | # |
| 254 | # "warn": RTC_LOGs a message with LS_WARNING severity if the field trial |
| 255 | # hasn't been registered. |
| 256 | rtc_strict_field_trials = "" |
Mirko Bonadei | 9130431 | 2023-07-26 11:01:43 | [diff] [blame] | 257 | |
| 258 | # If different from "", symbols exported with RTC_OBJC_EXPORT will be prefixed |
| 259 | # with this string. |
| 260 | # See the definition of RTC_OBJC_TYPE_PREFIX in the code. |
| 261 | rtc_objc_prefix = "" |
Arthur Sonzogni | 47faf32 | 2023-08-22 09:55:36 | [diff] [blame] | 262 | |
| 263 | # Embedders can define dependencies needed by WebRTC. Dependencies can be |
| 264 | # configs or targets. This can be defined in their `.gn` file. |
| 265 | # |
| 266 | # In practise, this is use by Chromium: Targets from |
| 267 | # `//third_party/webrtc_overrides` are depending on Chrome's `//base`, but |
| 268 | # WebRTC does not declare its public dependencies. See webrtc:8603. Instead |
| 269 | # WebRTC is using a global common dependencies. |
| 270 | rtc_common_public_deps = [] # no-presubmit-check TODO(webrtc:8603) |
Evan Shrubsole | db50b03 | 2024-04-24 13:27:00 | [diff] [blame] | 271 | |
| 272 | # When true, include the Perfetto library. |
| 273 | rtc_use_perfetto = false |
Dan Minor | 9c68613 | 2018-01-15 15:20:00 | [diff] [blame] | 274 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 275 | |
Dan Minor | 9c68613 | 2018-01-15 15:20:00 | [diff] [blame] | 276 | if (!build_with_mozilla) { |
| 277 | import("//testing/test.gni") |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | # A second declare_args block, so that declarations within it can |
| 281 | # depend on the possibly overridden variables in the first |
| 282 | # declare_args block. |
| 283 | declare_args() { |
Dan Minor | 9c68613 | 2018-01-15 15:20:00 | [diff] [blame] | 284 | # Enables the use of protocol buffers for debug recordings. |
| 285 | rtc_enable_protobuf = !build_with_mozilla |
| 286 | |
| 287 | # Set this to disable building with support for SCTP data channels. |
| 288 | rtc_enable_sctp = !build_with_mozilla |
| 289 | |
| 290 | # Disable these to not build components which can be externally provided. |
| 291 | rtc_build_json = !build_with_mozilla |
| 292 | rtc_build_libsrtp = !build_with_mozilla |
| 293 | rtc_build_libvpx = !build_with_mozilla |
| 294 | rtc_libvpx_build_vp9 = !build_with_mozilla |
Dan Minor | 9c68613 | 2018-01-15 15:20:00 | [diff] [blame] | 295 | rtc_build_opus = !build_with_mozilla |
| 296 | rtc_build_ssl = !build_with_mozilla |
Dan Minor | 9c68613 | 2018-01-15 15:20:00 | [diff] [blame] | 297 | |
| 298 | # Enable libevent task queues on platforms that support it. |
Mirko Bonadei | 775c02e | 2019-06-19 17:05:00 | [diff] [blame] | 299 | if (is_win || is_mac || is_ios || is_nacl || is_fuchsia || |
| 300 | target_cpu == "wasm") { |
Dan Minor | 9c68613 | 2018-01-15 15:20:00 | [diff] [blame] | 301 | rtc_enable_libevent = false |
| 302 | rtc_build_libevent = false |
| 303 | } else { |
| 304 | rtc_enable_libevent = true |
| 305 | rtc_build_libevent = !build_with_mozilla |
| 306 | } |
| 307 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 308 | # Excluded in Chromium since its prerequisites don't require Pulse Audio. |
| 309 | rtc_include_pulse_audio = !build_with_chromium |
| 310 | |
| 311 | # Chromium uses its own IO handling, so the internal ADM is only built for |
| 312 | # standalone WebRTC. |
| 313 | rtc_include_internal_audio_device = !build_with_chromium |
| 314 | |
Zhaoliang Ma | 72e4321 | 2020-08-17 09:13:41 | [diff] [blame] | 315 | # Set this to true to enable the avx2 support in webrtc. |
Per Åhgren | a43178c | 2020-09-25 10:02:32 | [diff] [blame] | 316 | # TODO: Make sure that AVX2 works also for non-clang compilers. |
| 317 | if (is_clang == true) { |
| 318 | rtc_enable_avx2 = true |
| 319 | } else { |
| 320 | rtc_enable_avx2 = false |
| 321 | } |
Zhaoliang Ma | 72e4321 | 2020-08-17 09:13:41 | [diff] [blame] | 322 | |
Philipp Hancke | 1a89bc8 | 2021-03-02 20:23:24 | [diff] [blame] | 323 | # Set this to true to build the unit tests. |
| 324 | # Disabled when building with Chromium or Mozilla. |
Dan Minor | 9c68613 | 2018-01-15 15:20:00 | [diff] [blame] | 325 | rtc_include_tests = !build_with_chromium && !build_with_mozilla |
Oleh Prypin | 240b893 | 2019-06-07 11:27:07 | [diff] [blame] | 326 | |
| 327 | # Set this to false to skip building code that also requires X11 extensions |
| 328 | # such as Xdamage, Xfixes. |
| 329 | rtc_use_x11_extensions = rtc_use_x11 |
Artem Titov | 6a4a146 | 2019-11-26 15:24:46 | [diff] [blame] | 330 | |
| 331 | # Set this to true to fully remove logging from WebRTC. |
| 332 | rtc_disable_logging = false |
Doudou Kisabaka | 2dec496 | 2019-11-28 13:24:31 | [diff] [blame] | 333 | |
| 334 | # Set this to true to disable trace events. |
| 335 | rtc_disable_trace_events = false |
Artem Titov | 9dc209a | 2019-11-28 16:09:30 | [diff] [blame] | 336 | |
| 337 | # Set this to true to disable detailed error message and logging for |
| 338 | # RTC_CHECKs. |
| 339 | rtc_disable_check_msg = false |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 340 | |
| 341 | # Set this to true to disable webrtc metrics. |
Mirko Bonadei | 3c4fda2 | 2019-12-10 14:02:53 | [diff] [blame] | 342 | rtc_disable_metrics = false |
saza | aa42ecd | 2020-04-01 13:24:40 | [diff] [blame] | 343 | |
| 344 | # Set this to true to exclude the transient suppressor in the audio processing |
| 345 | # module from the build. |
| 346 | rtc_exclude_transient_suppressor = false |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 347 | } |
| 348 | |
Florent Castelli | a80c3e5 | 2021-04-15 13:02:56 | [diff] [blame] | 349 | declare_args() { |
Florent Castelli | a6983c6 | 2021-05-06 08:50:07 | [diff] [blame] | 350 | # Enable the dcsctp backend for DataChannels and related unittests |
| 351 | rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp |
| 352 | |
Florent Castelli | 023be3c | 2022-03-15 15:01:52 | [diff] [blame] | 353 | # Enable gRPC used for negotiation in multiprocess tests |
| 354 | rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac) |
Florent Castelli | a80c3e5 | 2021-04-15 13:02:56 | [diff] [blame] | 355 | } |
| 356 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 357 | # Make it possible to provide custom locations for some libraries (move these |
| 358 | # up into declare_args should we need to actually use them for the GN build). |
| 359 | rtc_libvpx_dir = "//third_party/libvpx" |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 360 | rtc_opus_dir = "//third_party/opus" |
| 361 | |
| 362 | # Desktop capturer is supported only on Windows, OSX and Linux. |
Oleh Prypin | 240b893 | 2019-06-07 11:27:07 | [diff] [blame] | 363 | rtc_desktop_capture_supported = |
| 364 | (is_win && current_os != "winuwp") || is_mac || |
Hidehiko Abe | f264e70 | 2020-09-10 09:10:11 | [diff] [blame] | 365 | ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire)) |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 366 | |
| 367 | ############################################################################### |
| 368 | # Templates |
| 369 | # |
| 370 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 371 | # Points to // in webrtc stand-alone or to //third_party/webrtc/ in |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 372 | # chromium. |
| 373 | # We need absolute paths for all configs in templates as they are shared in |
| 374 | # different subdirectories. |
| 375 | webrtc_root = get_path_info(".", "abspath") |
| 376 | |
| 377 | # Global configuration that should be applied to all WebRTC targets. |
| 378 | # You normally shouldn't need to include this in your target as it's |
| 379 | # automatically included when using the rtc_* templates. |
| 380 | # It sets defines, include paths and compilation warnings accordingly, |
| 381 | # both for WebRTC stand-alone builds and for the scenario when WebRTC |
| 382 | # native code is built as part of Chromium. |
Mirko Bonadei | 5f07845 | 2021-07-30 20:32:55 | [diff] [blame] | 383 | rtc_common_configs = [ webrtc_root + ":common_config" ] |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 384 | |
kthelgason | c097710 | 2017-04-24 07:57:16 | [diff] [blame] | 385 | if (is_mac || is_ios) { |
Christoffer Jansson | fe2e7ea | 2023-08-02 07:41:23 | [diff] [blame] | 386 | if (filter_include(default_compiler_configs, |
| 387 | [ "//build/config/compiler:enable_arc" ]) == []) { |
| 388 | rtc_common_configs += [ "//build/config/compiler:enable_arc" ] |
| 389 | } |
kthelgason | c097710 | 2017-04-24 07:57:16 | [diff] [blame] | 390 | } |
Evan Shrubsole | 047238e | 2024-04-29 11:36:58 | [diff] [blame] | 391 | |
Evan Shrubsole | fa87037 | 2024-05-02 11:59:39 | [diff] [blame] | 392 | if (build_with_chromium) { |
Evan Shrubsole | 047238e | 2024-04-29 11:36:58 | [diff] [blame] | 393 | rtc_use_perfetto = true |
| 394 | } |
| 395 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 396 | # Global public configuration that should be applied to all WebRTC targets. You |
| 397 | # normally shouldn't need to include this in your target as it's automatically |
| 398 | # included when using the rtc_* templates. It set the defines, include paths and |
| 399 | # compilation warnings that should be propagated to dependents of the targets |
| 400 | # depending on the target having this config. |
| 401 | rtc_common_inherited_config = webrtc_root + ":common_inherited_config" |
| 402 | |
| 403 | # Common configs to remove or add in all rtc targets. |
| 404 | rtc_remove_configs = [] |
Mirko Bonadei | fc52b91 | 2019-03-01 09:32:56 | [diff] [blame] | 405 | if (!build_with_chromium && is_clang) { |
| 406 | rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ] |
| 407 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 408 | rtc_add_configs = rtc_common_configs |
Mirko Bonadei | 96ede16a | 2018-09-06 11:45:44 | [diff] [blame] | 409 | rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ] |
Mirko Bonadei | 32ce18c | 2018-09-18 11:15:54 | [diff] [blame] | 410 | rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ] |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 411 | |
| 412 | set_defaults("rtc_test") { |
| 413 | configs = rtc_add_configs |
Arthur Sonzogni | 47faf32 | 2023-08-22 09:55:36 | [diff] [blame] | 414 | public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 415 | suppressed_configs = [] |
| 416 | } |
| 417 | |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame] | 418 | set_defaults("rtc_library") { |
| 419 | configs = rtc_add_configs |
Arthur Sonzogni | 47faf32 | 2023-08-22 09:55:36 | [diff] [blame] | 420 | public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame] | 421 | suppressed_configs = [] |
| 422 | } |
| 423 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 424 | set_defaults("rtc_source_set") { |
| 425 | configs = rtc_add_configs |
Arthur Sonzogni | 47faf32 | 2023-08-22 09:55:36 | [diff] [blame] | 426 | public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 427 | suppressed_configs = [] |
| 428 | } |
| 429 | |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame] | 430 | set_defaults("rtc_static_library") { |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 431 | configs = rtc_add_configs |
Arthur Sonzogni | 47faf32 | 2023-08-22 09:55:36 | [diff] [blame] | 432 | public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 433 | suppressed_configs = [] |
| 434 | } |
| 435 | |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame] | 436 | set_defaults("rtc_executable") { |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 437 | configs = rtc_add_configs |
Arthur Sonzogni | 47faf32 | 2023-08-22 09:55:36 | [diff] [blame] | 438 | public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 439 | suppressed_configs = [] |
| 440 | } |
| 441 | |
| 442 | set_defaults("rtc_shared_library") { |
| 443 | configs = rtc_add_configs |
Arthur Sonzogni | 47faf32 | 2023-08-22 09:55:36 | [diff] [blame] | 444 | public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 445 | suppressed_configs = [] |
| 446 | } |
| 447 | |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 | [diff] [blame] | 448 | webrtc_default_visibility = [ webrtc_root + "/*" ] |
| 449 | if (build_with_chromium) { |
| 450 | # Allow Chromium's WebRTC overrides targets to bypass the regular |
| 451 | # visibility restrictions. |
| 452 | webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ] |
| 453 | } |
| 454 | |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 455 | # ---- Poisons ---- |
| 456 | # |
| 457 | # The general idea is that some targets declare that they contain some |
| 458 | # kind of poison, which makes it impossible for other targets to |
| 459 | # depend on them (even transitively) unless they declare themselves |
| 460 | # immune to that particular type of poison. |
| 461 | # |
| 462 | # Targets that *contain* poison of type foo should contain the line |
| 463 | # |
| 464 | # poisonous = [ "foo" ] |
| 465 | # |
| 466 | # and targets that *are immune but arent't themselves poisonous* |
| 467 | # should contain |
| 468 | # |
| 469 | # allow_poison = [ "foo" ] |
| 470 | # |
| 471 | # This useful in cases where we have some large target or set of |
| 472 | # targets and want to ensure that most other targets do not |
| 473 | # transitively depend on them. For example, almost no high-level |
| 474 | # target should depend on the audio codecs, since we want WebRTC users |
| 475 | # to be able to inject any subset of them and actually end up with a |
| 476 | # binary that doesn't include the codecs they didn't inject. |
| 477 | # |
| 478 | # Test-only targets (`testonly` set to true) and non-public targets |
| 479 | # (`visibility` not containing "*") are automatically immune to all |
| 480 | # types of poison. |
| 481 | # |
| 482 | # Here's the complete list of all types of poison. It must be kept in |
| 483 | # 1:1 correspondence with the set of //:poison_* targets. |
| 484 | # |
| 485 | all_poison_types = [ |
| 486 | # Encoders and decoders for specific audio codecs such as Opus and iSAC. |
| 487 | "audio_codecs", |
Anders Carlsson | 1f433e4 | 2018-04-24 14:39:05 | [diff] [blame] | 488 | |
Sam Zackrisson | 03cb7e5 | 2021-12-06 14:40:04 | [diff] [blame] | 489 | # Default echo detector implementation. |
| 490 | "default_echo_detector", |
| 491 | |
Danil Chapovalov | 9fdceb8 | 2023-11-27 09:57:22 | [diff] [blame] | 492 | # Implementations of the utilities exposed through `Environment`. |
| 493 | # Most webrtc classes must use propagated `Environment`. Only few top-level |
| 494 | # classes are allowed to create `Environment` from individual utilities. |
| 495 | "environment_construction", |
| 496 | |
Sam Zackrisson | 492fdf4 | 2019-10-25 08:45:58 | [diff] [blame] | 497 | # Software video codecs (VP8 and VP9 through libvpx). |
| 498 | "software_video_codecs", |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 499 | ] |
| 500 | |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 501 | absl_include_config = "//third_party/abseil-cpp:absl_include_config" |
| 502 | absl_define_config = "//third_party/abseil-cpp:absl_define_config" |
| 503 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 504 | # Abseil Flags are testonly, so this config will only be applied to WebRTC targets |
| 505 | # that are testonly. |
| 506 | absl_flags_config = webrtc_root + ":absl_flags_configs" |
| 507 | |
Mirko Bonadei | e99b6cc | 2020-11-25 15:41:37 | [diff] [blame] | 508 | # WebRTC wrapper of Chromium's test() template. This template just adds some |
| 509 | # WebRTC only configuration in order to avoid to duplicate it for every WebRTC |
| 510 | # target. |
| 511 | # The parameter `is_xctest` is different from the one in the Chromium's test() |
| 512 | # template (and it is not forwarded to it). In rtc_test(), the argument |
| 513 | # `is_xctest` is used to avoid to take dependencies that are not needed |
| 514 | # in case the test is a real XCTest (using the XCTest framework). |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 515 | template("rtc_test") { |
| 516 | test(target_name) { |
| 517 | forward_variables_from(invoker, |
| 518 | "*", |
| 519 | [ |
| 520 | "configs", |
Mirko Bonadei | e99b6cc | 2020-11-25 15:41:37 | [diff] [blame] | 521 | "is_xctest", |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 522 | "public_configs", |
| 523 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 524 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 525 | ]) |
Mirko Bonadei | dd41194 | 2017-11-21 14:35:27 | [diff] [blame] | 526 | |
| 527 | # Always override to public because when target_os is Android the `test` |
| 528 | # template can override it to [ "*" ] and we want to avoid conditional |
| 529 | # visibility. |
Mirko Bonadei | 2155881 | 2017-11-21 11:47:34 | [diff] [blame] | 530 | visibility = [ "*" ] |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 531 | configs += invoker.configs |
| 532 | configs -= rtc_remove_configs |
| 533 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 534 | public_configs = [ |
| 535 | rtc_common_inherited_config, |
| 536 | absl_include_config, |
| 537 | absl_define_config, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 538 | absl_flags_config, |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 539 | ] |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 540 | if (defined(invoker.public_configs)) { |
| 541 | public_configs += invoker.public_configs |
| 542 | } |
sakal | d7fdb80 | 2017-05-26 08:51:53 | [diff] [blame] | 543 | if (!build_with_chromium && is_android) { |
Jianjun Zhu | 037f3e4 | 2017-08-15 13:48:37 | [diff] [blame] | 544 | android_manifest = webrtc_root + "test/android/AndroidManifest.xml" |
Peter Kotwicz | 3ceb16e | 2021-04-14 22:53:11 | [diff] [blame] | 545 | use_raw_android_executable = false |
Jeremy Leconte | b19cfee | 2020-06-25 20:57:49 | [diff] [blame] | 546 | min_sdk_version = 21 |
Mirko Bonadei | bd393b2 | 2020-07-10 21:00:41 | [diff] [blame] | 547 | target_sdk_version = 23 |
Mirko Bonadei | 8093935 | 2021-04-12 17:03:37 | [diff] [blame] | 548 | deps += [ |
| 549 | "//build/android/gtest_apk:native_test_instrumentation_test_runner_java", |
| 550 | webrtc_root + "test:native_test_java", |
| 551 | ] |
sakal | d7fdb80 | 2017-05-26 08:51:53 | [diff] [blame] | 552 | } |
Mirko Bonadei | e99b6cc | 2020-11-25 15:41:37 | [diff] [blame] | 553 | |
Björn Terelius | 49850c3 | 2022-05-04 08:59:56 | [diff] [blame] | 554 | # Build //test:google_test_runner_objc when the test is not a real XCTest. |
Jeremy Leconte | b8ba8c9 | 2022-03-15 08:08:29 | [diff] [blame] | 555 | if (is_ios && rtc_include_tests) { |
Mirko Bonadei | e99b6cc | 2020-11-25 15:41:37 | [diff] [blame] | 556 | if (!defined(invoker.is_xctest) || !invoker.is_xctest) { |
Björn Terelius | 49850c3 | 2022-05-04 08:59:56 | [diff] [blame] | 557 | xctest_module_target = "//test:google_test_runner_objc" |
Mirko Bonadei | e99b6cc | 2020-11-25 15:41:37 | [diff] [blame] | 558 | } |
| 559 | } |
Andrey Logvin | 7864600 | 2021-01-29 10:50:19 | [diff] [blame] | 560 | |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 561 | assert( |
| 562 | !defined(absl_deps), |
| 563 | "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.") |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 564 | |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 565 | # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 566 | if (build_with_chromium && defined(deps)) { |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 567 | absl_dependencies = |
| 568 | filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ]) |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 569 | if (absl_dependencies != []) { |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 570 | filtered_deps = |
| 571 | filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ]) |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 572 | deps = [] |
| 573 | deps = filtered_deps |
Andrey Logvin | 7864600 | 2021-01-29 10:50:19 | [diff] [blame] | 574 | deps += [ "//third_party/abseil-cpp:absl" ] |
Andrey Logvin | 7864600 | 2021-01-29 10:50:19 | [diff] [blame] | 575 | } |
| 576 | } |
| 577 | |
Jeremy Leconte | d15f3e1 | 2022-02-18 09:16:32 | [diff] [blame] | 578 | # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps |
| 579 | # shoulnd't be necessary. this code should be removed and the same solution |
| 580 | # as Chromium should be used. |
| 581 | if (is_ios) { |
| 582 | if (!defined(invoker.data)) { |
| 583 | data = [] |
| 584 | } |
| 585 | data += [ "${root_out_dir}/${target_name}.app" ] |
| 586 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 587 | } |
| 588 | } |
| 589 | |
| 590 | template("rtc_source_set") { |
| 591 | source_set(target_name) { |
| 592 | forward_variables_from(invoker, |
| 593 | "*", |
| 594 | [ |
| 595 | "configs", |
| 596 | "public_configs", |
| 597 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 598 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 599 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 600 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 | [diff] [blame] | 601 | if (!defined(visibility)) { |
| 602 | visibility = webrtc_default_visibility |
| 603 | } |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 604 | |
| 605 | # What's your poison? |
| 606 | if (defined(testonly) && testonly) { |
| 607 | assert(!defined(poisonous)) |
| 608 | assert(!defined(allow_poison)) |
| 609 | } else { |
| 610 | if (!defined(poisonous)) { |
| 611 | poisonous = [] |
| 612 | } |
| 613 | if (!defined(allow_poison)) { |
| 614 | allow_poison = [] |
| 615 | } |
| 616 | if (!defined(assert_no_deps)) { |
| 617 | assert_no_deps = [] |
| 618 | } |
| 619 | if (!defined(deps)) { |
| 620 | deps = [] |
| 621 | } |
| 622 | foreach(p, poisonous) { |
| 623 | deps += [ webrtc_root + ":poison_" + p ] |
| 624 | } |
| 625 | foreach(poison_type, all_poison_types) { |
| 626 | allow_dep = true |
| 627 | foreach(v, visibility) { |
| 628 | if (v == "*") { |
| 629 | allow_dep = false |
| 630 | } |
| 631 | } |
| 632 | foreach(p, allow_poison + poisonous) { |
| 633 | if (p == poison_type) { |
| 634 | allow_dep = true |
| 635 | } |
| 636 | } |
| 637 | if (!allow_dep) { |
| 638 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | |
Mirko Bonadei | 92dd35d | 2019-11-15 15:08:41 | [diff] [blame] | 643 | # Chromium should only depend on the WebRTC component in order to |
| 644 | # avoid to statically link WebRTC in a component build. |
| 645 | if (build_with_chromium) { |
| 646 | publicly_visible = false |
| 647 | foreach(v, visibility) { |
| 648 | if (v == "*") { |
| 649 | publicly_visible = true |
| 650 | } |
| 651 | } |
| 652 | if (publicly_visible) { |
| 653 | visibility = [] |
| 654 | visibility = webrtc_default_visibility |
| 655 | } |
| 656 | } |
| 657 | |
Mirko Bonadei | 96ede16a | 2018-09-06 11:45:44 | [diff] [blame] | 658 | if (!defined(testonly) || !testonly) { |
| 659 | configs += rtc_prod_configs |
| 660 | } |
| 661 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 662 | configs += invoker.configs |
Mirko Bonadei | 32ce18c | 2018-09-18 11:15:54 | [diff] [blame] | 663 | configs += rtc_library_impl_config |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 664 | configs -= rtc_remove_configs |
| 665 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 666 | public_configs = [ |
| 667 | rtc_common_inherited_config, |
| 668 | absl_include_config, |
| 669 | absl_define_config, |
| 670 | ] |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 671 | if (defined(testonly) && testonly) { |
| 672 | public_configs += [ absl_flags_config ] |
| 673 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 674 | if (defined(invoker.public_configs)) { |
| 675 | public_configs += invoker.public_configs |
| 676 | } |
Mirko Bonadei | 8b7cfa1 | 2020-06-03 19:23:41 | [diff] [blame] | 677 | |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 678 | assert( |
| 679 | !defined(absl_deps), |
| 680 | "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.") |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 681 | |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 682 | # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 683 | if (build_with_chromium && defined(deps)) { |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 684 | absl_dependencies = |
| 685 | filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ]) |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 686 | if (absl_dependencies != []) { |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 687 | filtered_deps = |
| 688 | filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ]) |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 689 | deps = [] |
| 690 | deps = filtered_deps |
Mirko Bonadei | 08ce986 | 2020-06-11 09:25:32 | [diff] [blame] | 691 | deps += [ "//third_party/abseil-cpp:absl" ] |
Mirko Bonadei | 8b7cfa1 | 2020-06-03 19:23:41 | [diff] [blame] | 692 | } |
| 693 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 694 | } |
| 695 | } |
| 696 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 697 | template("rtc_static_library") { |
| 698 | static_library(target_name) { |
| 699 | forward_variables_from(invoker, |
| 700 | "*", |
| 701 | [ |
| 702 | "configs", |
| 703 | "public_configs", |
| 704 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 705 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 706 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 707 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 | [diff] [blame] | 708 | if (!defined(visibility)) { |
| 709 | visibility = webrtc_default_visibility |
| 710 | } |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 711 | |
| 712 | # What's your poison? |
| 713 | if (defined(testonly) && testonly) { |
| 714 | assert(!defined(poisonous)) |
| 715 | assert(!defined(allow_poison)) |
| 716 | } else { |
| 717 | if (!defined(poisonous)) { |
| 718 | poisonous = [] |
| 719 | } |
| 720 | if (!defined(allow_poison)) { |
| 721 | allow_poison = [] |
| 722 | } |
| 723 | if (!defined(assert_no_deps)) { |
| 724 | assert_no_deps = [] |
| 725 | } |
| 726 | if (!defined(deps)) { |
| 727 | deps = [] |
| 728 | } |
| 729 | foreach(p, poisonous) { |
| 730 | deps += [ webrtc_root + ":poison_" + p ] |
| 731 | } |
| 732 | foreach(poison_type, all_poison_types) { |
| 733 | allow_dep = true |
| 734 | foreach(v, visibility) { |
| 735 | if (v == "*") { |
| 736 | allow_dep = false |
| 737 | } |
| 738 | } |
| 739 | foreach(p, allow_poison + poisonous) { |
| 740 | if (p == poison_type) { |
| 741 | allow_dep = true |
| 742 | } |
| 743 | } |
| 744 | if (!allow_dep) { |
| 745 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | |
Mirko Bonadei | 96ede16a | 2018-09-06 11:45:44 | [diff] [blame] | 750 | if (!defined(testonly) || !testonly) { |
| 751 | configs += rtc_prod_configs |
| 752 | } |
| 753 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 754 | configs += invoker.configs |
Mirko Bonadei | 32ce18c | 2018-09-18 11:15:54 | [diff] [blame] | 755 | configs += rtc_library_impl_config |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 756 | configs -= rtc_remove_configs |
| 757 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 758 | public_configs = [ |
| 759 | rtc_common_inherited_config, |
| 760 | absl_include_config, |
| 761 | absl_define_config, |
| 762 | ] |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 763 | if (defined(testonly) && testonly) { |
| 764 | public_configs += [ absl_flags_config ] |
| 765 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 766 | if (defined(invoker.public_configs)) { |
| 767 | public_configs += invoker.public_configs |
| 768 | } |
Mirko Bonadei | 8b7cfa1 | 2020-06-03 19:23:41 | [diff] [blame] | 769 | |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 770 | assert( |
| 771 | !defined(absl_deps), |
| 772 | "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.") |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 773 | |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 774 | # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 775 | if (build_with_chromium && defined(deps)) { |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 776 | absl_dependencies = |
| 777 | filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ]) |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 778 | if (absl_dependencies != []) { |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 779 | filtered_deps = |
| 780 | filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ]) |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 781 | deps = [] |
| 782 | deps = filtered_deps |
Mirko Bonadei | 08ce986 | 2020-06-11 09:25:32 | [diff] [blame] | 783 | deps += [ "//third_party/abseil-cpp:absl" ] |
Mirko Bonadei | 8b7cfa1 | 2020-06-03 19:23:41 | [diff] [blame] | 784 | } |
| 785 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 786 | } |
| 787 | } |
| 788 | |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame] | 789 | # This template automatically switches the target type between source_set |
| 790 | # and static_library. |
| 791 | # |
Florent Castelli | 87b6e7b | 2022-04-26 00:22:35 | [diff] [blame] | 792 | # This should be the default target type for all the WebRTC targets. |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame] | 793 | # |
| 794 | # How does it work: |
| 795 | # Since all files in a source_set are linked into a final binary, while files |
| 796 | # in a static library are only linked in if at least one symbol in them is |
| 797 | # referenced, in component builds source_sets are easy to deal with because |
| 798 | # all their object files are passed to the linker to create a shared library. |
| 799 | # In release builds instead, static_libraries are preferred since they allow |
| 800 | # the linker to discard dead code. |
| 801 | # For the same reason, testonly targets will always be expanded to |
| 802 | # source_set in order to be sure that tests are present in the test binary. |
| 803 | template("rtc_library") { |
Florent Castelli | 87b6e7b | 2022-04-26 00:22:35 | [diff] [blame] | 804 | header_only = true |
| 805 | if (defined(invoker.sources)) { |
| 806 | non_header_sources = filter_exclude(invoker.sources, |
| 807 | [ |
| 808 | "*.h", |
| 809 | "*.hh", |
| 810 | "*.inc", |
| 811 | ]) |
| 812 | if (non_header_sources != []) { |
| 813 | header_only = false |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | # Header only libraries should use source_set as a static_library with no |
| 818 | # source files will cause issues with macOS libtool. |
| 819 | if (header_only || is_component_build || |
| 820 | (defined(invoker.testonly) && invoker.testonly)) { |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame] | 821 | target_type = "source_set" |
| 822 | } else { |
| 823 | target_type = "static_library" |
| 824 | } |
| 825 | target(target_type, target_name) { |
| 826 | forward_variables_from(invoker, |
| 827 | "*", |
| 828 | [ |
| 829 | "configs", |
| 830 | "public_configs", |
| 831 | "suppressed_configs", |
| 832 | "visibility", |
| 833 | ]) |
| 834 | forward_variables_from(invoker, [ "visibility" ]) |
| 835 | if (!defined(visibility)) { |
| 836 | visibility = webrtc_default_visibility |
| 837 | } |
| 838 | |
| 839 | # What's your poison? |
| 840 | if (defined(testonly) && testonly) { |
| 841 | assert(!defined(poisonous)) |
| 842 | assert(!defined(allow_poison)) |
| 843 | } else { |
| 844 | if (!defined(poisonous)) { |
| 845 | poisonous = [] |
| 846 | } |
| 847 | if (!defined(allow_poison)) { |
| 848 | allow_poison = [] |
| 849 | } |
| 850 | if (!defined(assert_no_deps)) { |
| 851 | assert_no_deps = [] |
| 852 | } |
| 853 | if (!defined(deps)) { |
| 854 | deps = [] |
| 855 | } |
| 856 | foreach(p, poisonous) { |
| 857 | deps += [ webrtc_root + ":poison_" + p ] |
| 858 | } |
| 859 | foreach(poison_type, all_poison_types) { |
| 860 | allow_dep = true |
| 861 | foreach(v, visibility) { |
| 862 | if (v == "*") { |
| 863 | allow_dep = false |
| 864 | } |
| 865 | } |
| 866 | foreach(p, allow_poison + poisonous) { |
| 867 | if (p == poison_type) { |
| 868 | allow_dep = true |
| 869 | } |
| 870 | } |
| 871 | if (!allow_dep) { |
| 872 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 873 | } |
| 874 | } |
| 875 | } |
| 876 | |
Mirko Bonadei | 92dd35d | 2019-11-15 15:08:41 | [diff] [blame] | 877 | # Chromium should only depend on the WebRTC component in order to |
| 878 | # avoid to statically link WebRTC in a component build. |
| 879 | if (build_with_chromium) { |
| 880 | publicly_visible = false |
| 881 | foreach(v, visibility) { |
| 882 | if (v == "*") { |
| 883 | publicly_visible = true |
| 884 | } |
| 885 | } |
| 886 | if (publicly_visible) { |
| 887 | visibility = [] |
| 888 | visibility = webrtc_default_visibility |
| 889 | } |
| 890 | } |
| 891 | |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame] | 892 | if (!defined(testonly) || !testonly) { |
| 893 | configs += rtc_prod_configs |
| 894 | } |
| 895 | |
| 896 | configs += invoker.configs |
| 897 | configs += rtc_library_impl_config |
| 898 | configs -= rtc_remove_configs |
| 899 | configs -= invoker.suppressed_configs |
| 900 | public_configs = [ |
| 901 | rtc_common_inherited_config, |
| 902 | absl_include_config, |
| 903 | absl_define_config, |
| 904 | ] |
| 905 | if (defined(testonly) && testonly) { |
| 906 | public_configs += [ absl_flags_config ] |
| 907 | } |
| 908 | if (defined(invoker.public_configs)) { |
| 909 | public_configs += invoker.public_configs |
| 910 | } |
Mirko Bonadei | 8b7cfa1 | 2020-06-03 19:23:41 | [diff] [blame] | 911 | |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 912 | assert( |
| 913 | !defined(absl_deps), |
| 914 | "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.") |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 915 | |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 916 | # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 917 | if (build_with_chromium && defined(deps)) { |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 918 | absl_dependencies = |
| 919 | filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ]) |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 920 | if (absl_dependencies != []) { |
Florent Castelli | ae5d503 | 2024-05-27 10:19:05 | [diff] [blame] | 921 | filtered_deps = |
| 922 | filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ]) |
Florent Castelli | 3ffa0e8 | 2024-05-20 09:57:05 | [diff] [blame] | 923 | deps = [] |
| 924 | deps = filtered_deps |
Mirko Bonadei | 08ce986 | 2020-06-11 09:25:32 | [diff] [blame] | 925 | deps += [ "//third_party/abseil-cpp:absl" ] |
Mirko Bonadei | 8b7cfa1 | 2020-06-03 19:23:41 | [diff] [blame] | 926 | } |
| 927 | } |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame] | 928 | } |
| 929 | } |
| 930 | |
| 931 | template("rtc_executable") { |
| 932 | executable(target_name) { |
| 933 | forward_variables_from(invoker, |
| 934 | "*", |
| 935 | [ |
| 936 | "deps", |
| 937 | "configs", |
| 938 | "public_configs", |
| 939 | "suppressed_configs", |
| 940 | "visibility", |
| 941 | ]) |
| 942 | forward_variables_from(invoker, [ "visibility" ]) |
| 943 | if (!defined(visibility)) { |
| 944 | visibility = webrtc_default_visibility |
| 945 | } |
| 946 | configs += invoker.configs |
| 947 | configs -= rtc_remove_configs |
| 948 | configs -= invoker.suppressed_configs |
| 949 | deps = invoker.deps |
| 950 | |
| 951 | public_configs = [ |
| 952 | rtc_common_inherited_config, |
| 953 | absl_include_config, |
| 954 | absl_define_config, |
| 955 | ] |
| 956 | if (defined(testonly) && testonly) { |
| 957 | public_configs += [ absl_flags_config ] |
| 958 | } |
| 959 | if (defined(invoker.public_configs)) { |
| 960 | public_configs += invoker.public_configs |
| 961 | } |
| 962 | if (is_win) { |
| 963 | deps += [ |
| 964 | # Give executables the default manifest on Windows (a no-op elsewhere). |
| 965 | "//build/win:default_exe_manifest", |
| 966 | ] |
| 967 | } |
| 968 | } |
| 969 | } |
| 970 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 971 | template("rtc_shared_library") { |
| 972 | shared_library(target_name) { |
| 973 | forward_variables_from(invoker, |
| 974 | "*", |
| 975 | [ |
| 976 | "configs", |
| 977 | "public_configs", |
| 978 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 979 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 980 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 981 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 | [diff] [blame] | 982 | if (!defined(visibility)) { |
| 983 | visibility = webrtc_default_visibility |
| 984 | } |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 985 | |
| 986 | # What's your poison? |
| 987 | if (defined(testonly) && testonly) { |
| 988 | assert(!defined(poisonous)) |
| 989 | assert(!defined(allow_poison)) |
| 990 | } else { |
| 991 | if (!defined(poisonous)) { |
| 992 | poisonous = [] |
| 993 | } |
| 994 | if (!defined(allow_poison)) { |
| 995 | allow_poison = [] |
| 996 | } |
| 997 | if (!defined(assert_no_deps)) { |
| 998 | assert_no_deps = [] |
| 999 | } |
| 1000 | if (!defined(deps)) { |
| 1001 | deps = [] |
| 1002 | } |
| 1003 | foreach(p, poisonous) { |
| 1004 | deps += [ webrtc_root + ":poison_" + p ] |
| 1005 | } |
| 1006 | foreach(poison_type, all_poison_types) { |
| 1007 | allow_dep = true |
| 1008 | foreach(v, visibility) { |
| 1009 | if (v == "*") { |
| 1010 | allow_dep = false |
| 1011 | } |
| 1012 | } |
| 1013 | foreach(p, allow_poison + poisonous) { |
| 1014 | if (p == poison_type) { |
| 1015 | allow_dep = true |
| 1016 | } |
| 1017 | } |
| 1018 | if (!allow_dep) { |
| 1019 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 1020 | } |
| 1021 | } |
| 1022 | } |
| 1023 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 1024 | configs += invoker.configs |
| 1025 | configs -= rtc_remove_configs |
| 1026 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 1027 | public_configs = [ |
| 1028 | rtc_common_inherited_config, |
| 1029 | absl_include_config, |
| 1030 | absl_define_config, |
| 1031 | ] |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 1032 | if (defined(testonly) && testonly) { |
| 1033 | public_configs += [ absl_flags_config ] |
| 1034 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 1035 | if (defined(invoker.public_configs)) { |
| 1036 | public_configs += invoker.public_configs |
| 1037 | } |
| 1038 | } |
| 1039 | } |
kthelgason | 4065a576 | 2017-02-14 12:58:56 | [diff] [blame] | 1040 | |
Byoungchan Lee | 26b23b8 | 2022-04-08 09:23:14 | [diff] [blame] | 1041 | if (is_mac || is_ios) { |
| 1042 | template("apple_framework_bundle_with_umbrella_header") { |
Anders Carlsson | dc6b477 | 2018-01-15 12:31:03 | [diff] [blame] | 1043 | forward_variables_from(invoker, [ "output_name" ]) |
Daniel.L (Byoungchan Lee) | 32026ed | 2020-10-16 22:49:28 | [diff] [blame] | 1044 | this_target_name = target_name |
Anders Carlsson | dc6b477 | 2018-01-15 12:31:03 | [diff] [blame] | 1045 | umbrella_header_path = |
Daniel.L (Byoungchan Lee) | 32026ed | 2020-10-16 22:49:28 | [diff] [blame] | 1046 | "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h" |
Byoungchan Lee | 26b23b8 | 2022-04-08 09:23:14 | [diff] [blame] | 1047 | modulemap_path = "$target_gen_dir/Modules/module.modulemap" |
Byoungchan Lee | 1ce9a17 | 2024-04-30 08:14:18 | [diff] [blame] | 1048 | privacy_manifest_path = "$target_gen_dir/$target_name/PrivacyInfo.xcprivacy" |
Daniel.L (Byoungchan Lee) | 32026ed | 2020-10-16 22:49:28 | [diff] [blame] | 1049 | |
| 1050 | action_foreach("create_bracket_include_headers_$target_name") { |
| 1051 | script = "//tools_webrtc/apple/copy_framework_header.py" |
| 1052 | sources = invoker.sources |
| 1053 | output_name = invoker.output_name |
| 1054 | outputs = [ |
| 1055 | "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}", |
| 1056 | ] |
| 1057 | args = [ |
| 1058 | "--input", |
| 1059 | "{{source}}", |
| 1060 | "--output", |
| 1061 | rebase_path(target_gen_dir, root_build_dir) + |
| 1062 | "/$output_name.framework/WebRTC/{{source_file_part}}", |
| 1063 | ] |
| 1064 | } |
Anders Carlsson | dc6b477 | 2018-01-15 12:31:03 | [diff] [blame] | 1065 | |
Byoungchan Lee | 26b23b8 | 2022-04-08 09:23:14 | [diff] [blame] | 1066 | if (is_mac) { |
| 1067 | mac_framework_bundle(target_name) { |
| 1068 | forward_variables_from(invoker, "*", [ "configs" ]) |
| 1069 | if (defined(invoker.configs)) { |
| 1070 | configs += invoker.configs |
| 1071 | } |
| 1072 | |
| 1073 | framework_version = "A" |
| 1074 | framework_contents = [ |
| 1075 | "Headers", |
| 1076 | "Modules", |
| 1077 | "Resources", |
| 1078 | ] |
| 1079 | |
| 1080 | ldflags = [ |
| 1081 | "-all_load", |
| 1082 | "-install_name", |
| 1083 | "@rpath/$output_name.framework/$output_name", |
| 1084 | ] |
| 1085 | |
| 1086 | deps += [ |
| 1087 | ":copy_framework_headers_$this_target_name", |
| 1088 | ":copy_modulemap_$this_target_name", |
Byoungchan Lee | 1ce9a17 | 2024-04-30 08:14:18 | [diff] [blame] | 1089 | ":copy_privacy_manifest_$this_target_name", |
Byoungchan Lee | 26b23b8 | 2022-04-08 09:23:14 | [diff] [blame] | 1090 | ":copy_umbrella_header_$this_target_name", |
| 1091 | ":create_bracket_include_headers_$this_target_name", |
| 1092 | ":modulemap_$this_target_name", |
| 1093 | ":umbrella_header_$this_target_name", |
| 1094 | ] |
| 1095 | } |
| 1096 | } |
| 1097 | if (is_ios) { |
| 1098 | ios_framework_bundle(target_name) { |
| 1099 | forward_variables_from(invoker, |
| 1100 | "*", |
| 1101 | [ |
| 1102 | "configs", |
| 1103 | "public_headers", |
| 1104 | ]) |
| 1105 | if (defined(invoker.configs)) { |
| 1106 | configs += invoker.configs |
| 1107 | } |
| 1108 | public_headers = get_target_outputs( |
| 1109 | ":create_bracket_include_headers_$this_target_name") |
| 1110 | |
| 1111 | deps += [ |
Byoungchan Lee | 1ce9a17 | 2024-04-30 08:14:18 | [diff] [blame] | 1112 | ":copy_privacy_manifest_$this_target_name", |
Byoungchan Lee | 26b23b8 | 2022-04-08 09:23:14 | [diff] [blame] | 1113 | ":copy_umbrella_header_$this_target_name", |
| 1114 | ":create_bracket_include_headers_$this_target_name", |
| 1115 | ] |
| 1116 | } |
Anders Carlsson | dc6b477 | 2018-01-15 12:31:03 | [diff] [blame] | 1117 | } |
| 1118 | |
Byoungchan Lee | 26b23b8 | 2022-04-08 09:23:14 | [diff] [blame] | 1119 | if (is_mac || target_environment == "catalyst") { |
Jordan Rose | 53d3fc9 | 2021-07-06 19:16:41 | [diff] [blame] | 1120 | # Catalyst frameworks use the same layout as regular Mac frameworks. |
| 1121 | headers_dir = "Versions/A/Headers" |
Byoungchan Lee | 1ce9a17 | 2024-04-30 08:14:18 | [diff] [blame] | 1122 | |
| 1123 | # The path to the privacy manifest file differs between Mac and iOS. |
| 1124 | # https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/adding_a_privacy_manifest_to_your_app_or_third-party_sdk |
| 1125 | privacy_manifest_out_path = "Versions/A/Resources/PrivacyInfo.xcprivacy" |
Jordan Rose | 53d3fc9 | 2021-07-06 19:16:41 | [diff] [blame] | 1126 | } else { |
| 1127 | headers_dir = "Headers" |
Byoungchan Lee | 1ce9a17 | 2024-04-30 08:14:18 | [diff] [blame] | 1128 | privacy_manifest_out_path = "PrivacyInfo.xcprivacy" |
Jordan Rose | 53d3fc9 | 2021-07-06 19:16:41 | [diff] [blame] | 1129 | } |
Daniel.L (Byoungchan Lee) | 32026ed | 2020-10-16 22:49:28 | [diff] [blame] | 1130 | |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 1131 | bundle_data("copy_framework_headers_$this_target_name") { |
Daniel.L (Byoungchan Lee) | 32026ed | 2020-10-16 22:49:28 | [diff] [blame] | 1132 | sources = get_target_outputs( |
| 1133 | ":create_bracket_include_headers_$this_target_name") |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 1134 | |
Mirko Bonadei | ccbe95f | 2020-01-21 11:10:10 | [diff] [blame] | 1135 | outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ] |
Daniel.L (Byoungchan Lee) | 32026ed | 2020-10-16 22:49:28 | [diff] [blame] | 1136 | deps = [ ":create_bracket_include_headers_$this_target_name" ] |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 1137 | } |
| 1138 | |
Joel Sutherland | d2fb1bf | 2018-10-02 20:08:25 | [diff] [blame] | 1139 | action("modulemap_$this_target_name") { |
| 1140 | script = "//tools_webrtc/ios/generate_modulemap.py" |
| 1141 | args = [ |
| 1142 | "--out", |
| 1143 | rebase_path(modulemap_path, root_build_dir), |
| 1144 | "--name", |
| 1145 | output_name, |
| 1146 | ] |
Mirko Bonadei | ccbe95f | 2020-01-21 11:10:10 | [diff] [blame] | 1147 | outputs = [ modulemap_path ] |
Joel Sutherland | d2fb1bf | 2018-10-02 20:08:25 | [diff] [blame] | 1148 | } |
| 1149 | |
| 1150 | bundle_data("copy_modulemap_$this_target_name") { |
Mirko Bonadei | ccbe95f | 2020-01-21 11:10:10 | [diff] [blame] | 1151 | sources = [ modulemap_path ] |
| 1152 | outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ] |
| 1153 | deps = [ ":modulemap_$this_target_name" ] |
Joel Sutherland | d2fb1bf | 2018-10-02 20:08:25 | [diff] [blame] | 1154 | } |
| 1155 | |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 1156 | action("umbrella_header_$this_target_name") { |
Daniel.L (Byoungchan Lee) | 32026ed | 2020-10-16 22:49:28 | [diff] [blame] | 1157 | sources = get_target_outputs( |
| 1158 | ":create_bracket_include_headers_$this_target_name") |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 1159 | |
| 1160 | script = "//tools_webrtc/ios/generate_umbrella_header.py" |
| 1161 | |
Mirko Bonadei | ccbe95f | 2020-01-21 11:10:10 | [diff] [blame] | 1162 | outputs = [ umbrella_header_path ] |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 1163 | args = [ |
| 1164 | "--out", |
| 1165 | rebase_path(umbrella_header_path, root_build_dir), |
| 1166 | "--sources", |
| 1167 | ] + sources |
Daniel.L (Byoungchan Lee) | 32026ed | 2020-10-16 22:49:28 | [diff] [blame] | 1168 | deps = [ ":create_bracket_include_headers_$this_target_name" ] |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 1169 | } |
| 1170 | |
Byoungchan Lee | 26b23b8 | 2022-04-08 09:23:14 | [diff] [blame] | 1171 | copy("copy_umbrella_header_$target_name") { |
Mirko Bonadei | ccbe95f | 2020-01-21 11:10:10 | [diff] [blame] | 1172 | sources = [ umbrella_header_path ] |
Byoungchan Lee | 26b23b8 | 2022-04-08 09:23:14 | [diff] [blame] | 1173 | outputs = |
| 1174 | [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ] |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 1175 | |
Byoungchan Lee | 26b23b8 | 2022-04-08 09:23:14 | [diff] [blame] | 1176 | deps = [ ":umbrella_header_$target_name" ] |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 1177 | } |
Byoungchan Lee | 1ce9a17 | 2024-04-30 08:14:18 | [diff] [blame] | 1178 | |
| 1179 | action("create_privacy_manifest_$target_name") { |
| 1180 | script = "//tools_webrtc/apple/generate_privacy_manifest.py" |
| 1181 | |
| 1182 | args = [ |
| 1183 | "--output", |
| 1184 | rebase_path(privacy_manifest_path), |
| 1185 | ] |
| 1186 | |
| 1187 | outputs = [ privacy_manifest_path ] |
| 1188 | } |
| 1189 | |
| 1190 | copy("copy_privacy_manifest_$target_name") { |
| 1191 | sources = [ privacy_manifest_path ] |
| 1192 | outputs = |
| 1193 | [ "$root_out_dir/$output_name.framework/$privacy_manifest_out_path" ] |
| 1194 | |
| 1195 | deps = [ ":create_privacy_manifest_$target_name" ] |
| 1196 | } |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 1197 | } |
| 1198 | } |
| 1199 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1200 | if (is_android) { |
| 1201 | template("rtc_android_library") { |
| 1202 | android_library(target_name) { |
| 1203 | forward_variables_from(invoker, |
| 1204 | "*", |
| 1205 | [ |
| 1206 | "configs", |
| 1207 | "public_configs", |
| 1208 | "suppressed_configs", |
| 1209 | "visibility", |
| 1210 | ]) |
| 1211 | |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 1212 | errorprone_args = [] |
Sami Kalliomäki | e7fac68 | 2018-03-20 15:32:49 | [diff] [blame] | 1213 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1214 | # Treat warnings as errors. |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 1215 | errorprone_args += [ "-Werror" ] |
Sami Kalliomäki | e7fac68 | 2018-03-20 15:32:49 | [diff] [blame] | 1216 | |
| 1217 | # Add any arguments defined by the invoker. |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 1218 | if (defined(invoker.errorprone_args)) { |
| 1219 | errorprone_args += invoker.errorprone_args |
Sami Kalliomäki | e7fac68 | 2018-03-20 15:32:49 | [diff] [blame] | 1220 | } |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1221 | |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1222 | if (!defined(deps)) { |
| 1223 | deps = [] |
| 1224 | } |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1225 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1226 | no_build_hooks = true |
Mirko Bonadei | 8b7cfa1 | 2020-06-03 19:23:41 | [diff] [blame] | 1227 | not_needed([ "android_manifest" ]) |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | template("rtc_android_apk") { |
| 1232 | android_apk(target_name) { |
| 1233 | forward_variables_from(invoker, |
| 1234 | "*", |
| 1235 | [ |
| 1236 | "configs", |
| 1237 | "public_configs", |
| 1238 | "suppressed_configs", |
| 1239 | "visibility", |
| 1240 | ]) |
| 1241 | |
| 1242 | # Treat warnings as errors. |
Yves Gerey | 2f385d2 | 2019-11-20 11:10:08 | [diff] [blame] | 1243 | errorprone_args = [] |
| 1244 | errorprone_args += [ "-Werror" ] |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1245 | |
| 1246 | if (!defined(deps)) { |
| 1247 | deps = [] |
| 1248 | } |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1249 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1250 | no_build_hooks = true |
| 1251 | } |
| 1252 | } |
| 1253 | |
| 1254 | template("rtc_instrumentation_test_apk") { |
| 1255 | instrumentation_test_apk(target_name) { |
| 1256 | forward_variables_from(invoker, |
| 1257 | "*", |
| 1258 | [ |
| 1259 | "configs", |
| 1260 | "public_configs", |
| 1261 | "suppressed_configs", |
| 1262 | "visibility", |
| 1263 | ]) |
| 1264 | |
| 1265 | # Treat warnings as errors. |
Yves Gerey | 2f385d2 | 2019-11-20 11:10:08 | [diff] [blame] | 1266 | errorprone_args = [] |
| 1267 | errorprone_args += [ "-Werror" ] |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1268 | |
| 1269 | if (!defined(deps)) { |
| 1270 | deps = [] |
| 1271 | } |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1272 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1273 | no_build_hooks = true |
| 1274 | } |
| 1275 | } |
| 1276 | } |