mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [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 06:58:22 -0800 | [diff] [blame] | 8 | import("//build/config/arm.gni") |
| 9 | import("//build/config/features.gni") |
| 10 | import("//build/config/mips.gni") |
| 11 | import("//build/config/sanitizers/sanitizers.gni") |
Tomas Popela | 318da51 | 2018-11-13 06:32:23 +0100 | [diff] [blame] | 12 | import("//build/config/sysroot.gni") |
ehmaldonado | 0d729b3 | 2017-02-10 01:38:23 -0800 | [diff] [blame] | 13 | import("//build/config/ui.gni") |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 14 | import("//build_overrides/build.gni") |
mbonadei | 9660627 | 2017-03-03 19:41:59 -0800 | [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( |
| 26 | "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md") |
| 27 | assert(!is_component_build, "Component builds are not supported in WebRTC.") |
| 28 | } |
| 29 | |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 30 | if (is_ios) { |
| 31 | import("//build/config/ios/rules.gni") |
| 32 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 33 | |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 34 | if (is_mac) { |
| 35 | import("//build/config/mac/rules.gni") |
| 36 | } |
| 37 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 38 | declare_args() { |
Mirko Bonadei | 028248c | 2018-10-10 12:19:02 +0200 | [diff] [blame] | 39 | # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h) |
| 40 | # expand to code that will manage symbols visibility. |
| 41 | rtc_enable_symbol_export = false |
| 42 | |
Mirko Bonadei | 31b0b45 | 2018-08-22 10:37:11 +0200 | [diff] [blame] | 43 | # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which |
Mirko Bonadei | 7040090 | 2018-08-21 15:44:28 +0200 | [diff] [blame] | 44 | # will tell the pre-processor to remove the default definition of symbols |
| 45 | # needed to use field_trial. In that case a new implementation needs to be |
| 46 | # provided. |
Mirko Bonadei | 31b0b45 | 2018-08-22 10:37:11 +0200 | [diff] [blame] | 47 | if (build_with_chromium) { |
| 48 | # When WebRTC is built as part of Chromium it should exclude the default |
| 49 | # implementation of field_trial unless it is building for NACL or |
| 50 | # Chromecast. |
| 51 | rtc_exclude_field_trial_default = !is_nacl && !is_chromecast |
| 52 | } else { |
| 53 | rtc_exclude_field_trial_default = false |
| 54 | } |
Mirko Bonadei | 7040090 | 2018-08-21 15:44:28 +0200 | [diff] [blame] | 55 | |
Mirko Bonadei | 906add4 | 2018-09-05 16:03:16 +0200 | [diff] [blame] | 56 | # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which |
| 57 | # will tell the pre-processor to remove the default definition of symbols |
| 58 | # needed to use metrics. In that case a new implementation needs to be |
| 59 | # provided. |
| 60 | rtc_exclude_metrics_default = build_with_chromium |
| 61 | |
Benjamin Wright | d6f86e8 | 2018-05-08 13:12:25 -0700 | [diff] [blame] | 62 | # Setting this to false will require the API user to pass in their own |
| 63 | # SSLCertificateVerifier to verify the certificates presented from a |
| 64 | # TLS-TURN server. In return disabling this saves around 100kb in the binary. |
| 65 | rtc_builtin_ssl_root_certificates = true |
| 66 | |
Karl Wiberg | eb254b4 | 2017-11-01 15:08:12 +0100 | [diff] [blame] | 67 | # Include the iLBC audio codec? |
| 68 | rtc_include_ilbc = true |
| 69 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 70 | # Disable this to avoid building the Opus audio codec. |
| 71 | rtc_include_opus = true |
| 72 | |
minyue | 2e03c66 | 2017-02-01 17:31:11 -0800 | [diff] [blame] | 73 | # Enable this if the Opus version upon which WebRTC is built supports direct |
| 74 | # encoding of 120 ms packets. |
minyue-webrtc | 516711c | 2017-07-27 17:45:49 +0200 | [diff] [blame] | 75 | rtc_opus_support_120ms_ptime = true |
minyue | 2e03c66 | 2017-02-01 17:31:11 -0800 | [diff] [blame] | 76 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 77 | # Enable this to let the Opus audio codec change complexity on the fly. |
| 78 | rtc_opus_variable_complexity = false |
| 79 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 80 | # Used to specify an external Jsoncpp include path when not compiling the |
| 81 | # library that comes with WebRTC (i.e. rtc_build_json == 0). |
| 82 | rtc_jsoncpp_root = "//third_party/jsoncpp/source/include" |
| 83 | |
| 84 | # Used to specify an external OpenSSL include path when not compiling the |
| 85 | # library that comes with WebRTC (i.e. rtc_build_ssl == 0). |
| 86 | rtc_ssl_root = "" |
| 87 | |
| 88 | # Selects fixed-point code where possible. |
| 89 | rtc_prefer_fixed_point = false |
| 90 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 91 | # Enable when an external authentication mechanism is used for performing |
| 92 | # packet authentication for RTP packets instead of libsrtp. |
| 93 | rtc_enable_external_auth = build_with_chromium |
| 94 | |
| 95 | # Selects whether debug dumps for the audio processing module |
| 96 | # should be generated. |
| 97 | apm_debug_dump = false |
| 98 | |
| 99 | # Set this to true to enable BWE test logging. |
| 100 | rtc_enable_bwe_test_logging = false |
| 101 | |
Joachim Bauch | 93e9134 | 2017-12-07 01:25:53 +0100 | [diff] [blame] | 102 | # Set this to false to skip building examples. |
| 103 | rtc_build_examples = true |
| 104 | |
| 105 | # Set this to false to skip building tools. |
| 106 | rtc_build_tools = true |
| 107 | |
Joachim Bauch | 75f18fc | 2017-12-20 21:25:47 +0100 | [diff] [blame] | 108 | # Set this to false to skip building code that requires X11. |
| 109 | rtc_use_x11 = use_x11 |
| 110 | |
Tomas Popela | 318da51 | 2018-11-13 06:32:23 +0100 | [diff] [blame] | 111 | # Set this to use PipeWire on the Wayland display server. |
Tomas Popela | 762543f | 2018-12-12 14:37:51 +0100 | [diff] [blame] | 112 | # By default it's only enabled on desktop Linux (excludes ChromeOS) and |
| 113 | # only when using the sysroot as PipeWire is not available in older and |
| 114 | # supported Ubuntu and Debian distributions. |
| 115 | rtc_use_pipewire = is_desktop_linux && use_sysroot |
| 116 | |
| 117 | # Set this to link PipeWire directly instead of using the dlopen. |
| 118 | rtc_link_pipewire = false |
Tomas Popela | 318da51 | 2018-11-13 06:32:23 +0100 | [diff] [blame] | 119 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 120 | # Enable to use the Mozilla internal settings. |
| 121 | build_with_mozilla = false |
| 122 | |
henrika | 883d00f | 2018-03-16 10:09:49 +0100 | [diff] [blame] | 123 | # Enable use of Android AAudio which requires Android SDK 26 or above and |
| 124 | # NDK r16 or above. |
| 125 | rtc_enable_android_aaudio = false |
| 126 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 127 | # Set to "func", "block", "edge" for coverage generation. |
| 128 | # At unit test runtime set UBSAN_OPTIONS="coverage=1". |
| 129 | # It is recommend to set include_examples=0. |
| 130 | # Use llvm's sancov -html-report for human readable reports. |
| 131 | # See http://clang.llvm.org/docs/SanitizerCoverage.html . |
| 132 | rtc_sanitize_coverage = "" |
| 133 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 134 | if (current_cpu == "arm" || current_cpu == "arm64") { |
| 135 | rtc_prefer_fixed_point = true |
| 136 | } |
| 137 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 138 | # Determines whether NEON code will be built. |
| 139 | rtc_build_with_neon = |
| 140 | (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64" |
| 141 | |
| 142 | # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on |
| 143 | # all platforms except Android and iOS. Because FFmpeg can be built |
| 144 | # with/without H.264 support, |ffmpeg_branding| has to separately be set to a |
| 145 | # value that includes H.264, for example "Chrome". If FFmpeg is built without |
Sergey Silkin | fe288eb | 2018-06-25 16:22:38 +0200 | [diff] [blame] | 146 | # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 147 | # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING. |
| 148 | # http://www.openh264.org, https://www.ffmpeg.org/ |
Mirko Bonadei | ee0a85c | 2019-01-15 10:47:18 +0100 | [diff] [blame] | 149 | # |
| 150 | # Enabling H264 when building with MSVC is currently not supported, see |
| 151 | # bugs.webrtc.org/9213#c13 for more info. |
| 152 | rtc_use_h264 = |
| 153 | proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 154 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 155 | # By default, use normal platform audio support or dummy audio, but don't |
| 156 | # use file-based audio playout and record. |
| 157 | rtc_use_dummy_audio_file_devices = false |
| 158 | |
henrika | 7be7883 | 2017-06-13 17:34:16 +0200 | [diff] [blame] | 159 | # When set to true, replace the audio output with a sinus tone at 440Hz. |
| 160 | # The ADM will ask for audio data from WebRTC but instead of reading real |
| 161 | # audio samples from NetEQ, a sinus tone will be generated and replace the |
| 162 | # real audio samples. |
| 163 | rtc_audio_device_plays_sinus_tone = false |
| 164 | |
Anders Carlsson | 358f2e0 | 2018-06-04 10:24:37 +0200 | [diff] [blame] | 165 | if (is_ios) { |
| 166 | # Build broadcast extension in AppRTCMobile for iOS. This results in the |
| 167 | # binary only running on iOS 11+, which is why it is disabled by default. |
| 168 | rtc_apprtcmobile_broadcast_extension = false |
| 169 | } |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 170 | |
| 171 | # Determines whether Metal is available on iOS/macOS. |
| 172 | rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64") |
Jiawei Ou | 0874530 | 2019-02-12 11:36:13 -0800 | [diff] [blame] | 173 | |
| 174 | # When set to false, builtin audio encoder/decoder factories and all the |
| 175 | # audio codecs they depend on will not be included in libwebrtc.{a|lib} |
| 176 | # (they will still be included in libjingle_peerconnection_so.so and |
| 177 | # WebRTC.framework) |
| 178 | rtc_include_builtin_audio_codecs = true |
| 179 | |
| 180 | # When set to false, builtin video encoder/decoder factories and all the |
| 181 | # video codecs they depends on will not be included in libwebrtc.{a|lib} |
| 182 | # (they will still be included in libjingle_peerconnection_so.so and |
| 183 | # WebRTC.framework) |
| 184 | rtc_include_builtin_video_codecs = true |
Mirko Bonadei | 20574f4 | 2019-03-28 07:50:07 +0100 | [diff] [blame] | 185 | |
| 186 | # When set to true and in a standalone build, it will undefine UNICODE and |
| 187 | # _UNICODE (which are always defined globally by the Chromium Windows |
| 188 | # toolchain). |
| 189 | # This is only needed for testing purposes, WebRTC wants to be sure it |
| 190 | # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses |
| 191 | # wide character functions. |
| 192 | rtc_win_undef_unicode = false |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 193 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 194 | |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 195 | if (!build_with_mozilla) { |
| 196 | import("//testing/test.gni") |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | # A second declare_args block, so that declarations within it can |
| 200 | # depend on the possibly overridden variables in the first |
| 201 | # declare_args block. |
| 202 | declare_args() { |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 203 | # Enables the use of protocol buffers for debug recordings. |
| 204 | rtc_enable_protobuf = !build_with_mozilla |
| 205 | |
| 206 | # Set this to disable building with support for SCTP data channels. |
| 207 | rtc_enable_sctp = !build_with_mozilla |
| 208 | |
| 209 | # Disable these to not build components which can be externally provided. |
| 210 | rtc_build_json = !build_with_mozilla |
| 211 | rtc_build_libsrtp = !build_with_mozilla |
| 212 | rtc_build_libvpx = !build_with_mozilla |
| 213 | rtc_libvpx_build_vp9 = !build_with_mozilla |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 214 | rtc_build_opus = !build_with_mozilla |
| 215 | rtc_build_ssl = !build_with_mozilla |
| 216 | rtc_build_usrsctp = !build_with_mozilla |
| 217 | |
| 218 | # Enable libevent task queues on platforms that support it. |
Mirko Bonadei | 775c02e | 2019-06-19 19:05:00 +0200 | [diff] [blame] | 219 | if (is_win || is_mac || is_ios || is_nacl || is_fuchsia || |
| 220 | target_cpu == "wasm") { |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 221 | rtc_enable_libevent = false |
| 222 | rtc_build_libevent = false |
| 223 | } else { |
| 224 | rtc_enable_libevent = true |
| 225 | rtc_build_libevent = !build_with_mozilla |
| 226 | } |
| 227 | |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 228 | # Build sources requiring GTK. NOTICE: This is not present in Chrome OS |
| 229 | # build environments, even if available for Chromium builds. |
| 230 | rtc_use_gtk = !build_with_chromium && !build_with_mozilla |
| 231 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 232 | # Excluded in Chromium since its prerequisites don't require Pulse Audio. |
| 233 | rtc_include_pulse_audio = !build_with_chromium |
| 234 | |
| 235 | # Chromium uses its own IO handling, so the internal ADM is only built for |
| 236 | # standalone WebRTC. |
| 237 | rtc_include_internal_audio_device = !build_with_chromium |
| 238 | |
| 239 | # Include tests in standalone checkout. |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 240 | rtc_include_tests = !build_with_chromium && !build_with_mozilla |
Oleh Prypin | 240b893 | 2019-06-07 13:27:07 +0200 | [diff] [blame] | 241 | |
| 242 | # Set this to false to skip building code that also requires X11 extensions |
| 243 | # such as Xdamage, Xfixes. |
| 244 | rtc_use_x11_extensions = rtc_use_x11 |
Artem Titov | 6a4a146 | 2019-11-26 16:24:46 +0100 | [diff] [blame] | 245 | |
| 246 | # Set this to true to fully remove logging from WebRTC. |
| 247 | rtc_disable_logging = false |
Doudou Kisabaka | 2dec496 | 2019-11-28 14:24:31 +0100 | [diff] [blame] | 248 | |
| 249 | # Set this to true to disable trace events. |
| 250 | rtc_disable_trace_events = false |
Artem Titov | 9dc209a | 2019-11-28 17:09:30 +0100 | [diff] [blame] | 251 | |
| 252 | # Set this to true to disable detailed error message and logging for |
| 253 | # RTC_CHECKs. |
| 254 | rtc_disable_check_msg = false |
Ying Wang | ef3998f | 2019-12-09 13:06:53 +0100 | [diff] [blame] | 255 | |
| 256 | # Set this to true to disable webrtc metrics. |
Mirko Bonadei | 3c4fda2 | 2019-12-10 15:02:53 +0100 | [diff] [blame] | 257 | rtc_disable_metrics = false |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | # Make it possible to provide custom locations for some libraries (move these |
| 261 | # up into declare_args should we need to actually use them for the GN build). |
| 262 | rtc_libvpx_dir = "//third_party/libvpx" |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 263 | rtc_opus_dir = "//third_party/opus" |
| 264 | |
| 265 | # Desktop capturer is supported only on Windows, OSX and Linux. |
Oleh Prypin | 240b893 | 2019-06-07 13:27:07 +0200 | [diff] [blame] | 266 | rtc_desktop_capture_supported = |
| 267 | (is_win && current_os != "winuwp") || is_mac || |
| 268 | (is_linux && (rtc_use_x11_extensions || rtc_use_pipewire)) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 269 | |
| 270 | ############################################################################### |
| 271 | # Templates |
| 272 | # |
| 273 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 274 | # Points to // in webrtc stand-alone or to //third_party/webrtc/ in |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 275 | # chromium. |
| 276 | # We need absolute paths for all configs in templates as they are shared in |
| 277 | # different subdirectories. |
| 278 | webrtc_root = get_path_info(".", "abspath") |
| 279 | |
| 280 | # Global configuration that should be applied to all WebRTC targets. |
| 281 | # You normally shouldn't need to include this in your target as it's |
| 282 | # automatically included when using the rtc_* templates. |
| 283 | # It sets defines, include paths and compilation warnings accordingly, |
| 284 | # both for WebRTC stand-alone builds and for the scenario when WebRTC |
| 285 | # native code is built as part of Chromium. |
Will Harris | fc173d0 | 2018-08-29 13:56:00 -0700 | [diff] [blame] | 286 | rtc_common_configs = [ |
| 287 | webrtc_root + ":common_config", |
| 288 | "//build/config/compiler:no_size_t_to_int_warning", |
| 289 | ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 290 | |
kthelgason | c097710 | 2017-04-24 00:57:16 -0700 | [diff] [blame] | 291 | if (is_mac || is_ios) { |
| 292 | rtc_common_configs += [ "//build/config/compiler:enable_arc" ] |
| 293 | } |
| 294 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 295 | # Global public configuration that should be applied to all WebRTC targets. You |
| 296 | # normally shouldn't need to include this in your target as it's automatically |
| 297 | # included when using the rtc_* templates. It set the defines, include paths and |
| 298 | # compilation warnings that should be propagated to dependents of the targets |
| 299 | # depending on the target having this config. |
| 300 | rtc_common_inherited_config = webrtc_root + ":common_inherited_config" |
| 301 | |
| 302 | # Common configs to remove or add in all rtc targets. |
| 303 | rtc_remove_configs = [] |
Mirko Bonadei | fc52b91 | 2019-03-01 10:32:56 +0100 | [diff] [blame] | 304 | if (!build_with_chromium && is_clang) { |
| 305 | rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ] |
| 306 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 307 | rtc_add_configs = rtc_common_configs |
Mirko Bonadei | 96ede16 | 2018-09-06 13:45:44 +0200 | [diff] [blame] | 308 | rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ] |
Mirko Bonadei | 32ce18c | 2018-09-18 13:15:54 +0200 | [diff] [blame] | 309 | rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 310 | |
| 311 | set_defaults("rtc_test") { |
| 312 | configs = rtc_add_configs |
| 313 | suppressed_configs = [] |
| 314 | } |
| 315 | |
Mirko Bonadei | 86d053c | 2019-10-17 21:32:04 +0200 | [diff] [blame] | 316 | set_defaults("rtc_library") { |
| 317 | configs = rtc_add_configs |
| 318 | suppressed_configs = [] |
| 319 | } |
| 320 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 321 | set_defaults("rtc_source_set") { |
| 322 | configs = rtc_add_configs |
| 323 | suppressed_configs = [] |
| 324 | } |
| 325 | |
Mirko Bonadei | 86d053c | 2019-10-17 21:32:04 +0200 | [diff] [blame] | 326 | set_defaults("rtc_static_library") { |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 327 | configs = rtc_add_configs |
| 328 | suppressed_configs = [] |
| 329 | } |
| 330 | |
Mirko Bonadei | 86d053c | 2019-10-17 21:32:04 +0200 | [diff] [blame] | 331 | set_defaults("rtc_executable") { |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 332 | configs = rtc_add_configs |
| 333 | suppressed_configs = [] |
| 334 | } |
| 335 | |
| 336 | set_defaults("rtc_shared_library") { |
| 337 | configs = rtc_add_configs |
| 338 | suppressed_configs = [] |
| 339 | } |
| 340 | |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 341 | webrtc_default_visibility = [ webrtc_root + "/*" ] |
| 342 | if (build_with_chromium) { |
| 343 | # Allow Chromium's WebRTC overrides targets to bypass the regular |
| 344 | # visibility restrictions. |
| 345 | webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ] |
| 346 | } |
| 347 | |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 348 | # ---- Poisons ---- |
| 349 | # |
| 350 | # The general idea is that some targets declare that they contain some |
| 351 | # kind of poison, which makes it impossible for other targets to |
| 352 | # depend on them (even transitively) unless they declare themselves |
| 353 | # immune to that particular type of poison. |
| 354 | # |
| 355 | # Targets that *contain* poison of type foo should contain the line |
| 356 | # |
| 357 | # poisonous = [ "foo" ] |
| 358 | # |
| 359 | # and targets that *are immune but arent't themselves poisonous* |
| 360 | # should contain |
| 361 | # |
| 362 | # allow_poison = [ "foo" ] |
| 363 | # |
| 364 | # This useful in cases where we have some large target or set of |
| 365 | # targets and want to ensure that most other targets do not |
| 366 | # transitively depend on them. For example, almost no high-level |
| 367 | # target should depend on the audio codecs, since we want WebRTC users |
| 368 | # to be able to inject any subset of them and actually end up with a |
| 369 | # binary that doesn't include the codecs they didn't inject. |
| 370 | # |
| 371 | # Test-only targets (`testonly` set to true) and non-public targets |
| 372 | # (`visibility` not containing "*") are automatically immune to all |
| 373 | # types of poison. |
| 374 | # |
| 375 | # Here's the complete list of all types of poison. It must be kept in |
| 376 | # 1:1 correspondence with the set of //:poison_* targets. |
| 377 | # |
| 378 | all_poison_types = [ |
| 379 | # Encoders and decoders for specific audio codecs such as Opus and iSAC. |
| 380 | "audio_codecs", |
Anders Carlsson | 1f433e4 | 2018-04-24 16:39:05 +0200 | [diff] [blame] | 381 | |
Danil Chapovalov | 41300af | 2019-07-10 12:44:43 +0200 | [diff] [blame] | 382 | # Default task queue implementation. |
| 383 | "default_task_queue", |
Sam Zackrisson | 492fdf4 | 2019-10-25 10:45:58 +0200 | [diff] [blame] | 384 | |
| 385 | # JSON parsing should not be needed in the "slim and modular" WebRTC. |
| 386 | "rtc_json", |
| 387 | |
| 388 | # Software video codecs (VP8 and VP9 through libvpx). |
| 389 | "software_video_codecs", |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 390 | ] |
| 391 | |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 392 | absl_include_config = "//third_party/abseil-cpp:absl_include_config" |
| 393 | absl_define_config = "//third_party/abseil-cpp:absl_define_config" |
| 394 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 395 | # Abseil Flags are testonly, so this config will only be applied to WebRTC targets |
| 396 | # that are testonly. |
| 397 | absl_flags_config = webrtc_root + ":absl_flags_configs" |
| 398 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 399 | template("rtc_test") { |
| 400 | test(target_name) { |
| 401 | forward_variables_from(invoker, |
| 402 | "*", |
| 403 | [ |
| 404 | "configs", |
| 405 | "public_configs", |
| 406 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 407 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 408 | ]) |
Mirko Bonadei | dd41194 | 2017-11-21 15:35:27 +0100 | [diff] [blame] | 409 | |
| 410 | # Always override to public because when target_os is Android the `test` |
| 411 | # template can override it to [ "*" ] and we want to avoid conditional |
| 412 | # visibility. |
Mirko Bonadei | 2155881 | 2017-11-21 12:47:34 +0100 | [diff] [blame] | 413 | visibility = [ "*" ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 414 | configs += invoker.configs |
| 415 | configs -= rtc_remove_configs |
| 416 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 417 | public_configs = [ |
| 418 | rtc_common_inherited_config, |
| 419 | absl_include_config, |
| 420 | absl_define_config, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 421 | absl_flags_config, |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 422 | ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 423 | if (defined(invoker.public_configs)) { |
| 424 | public_configs += invoker.public_configs |
| 425 | } |
sakal | d7fdb80 | 2017-05-26 01:51:53 -0700 | [diff] [blame] | 426 | if (!build_with_chromium && is_android) { |
Jianjun Zhu | 037f3e4 | 2017-08-15 21:48:37 +0800 | [diff] [blame] | 427 | android_manifest = webrtc_root + "test/android/AndroidManifest.xml" |
Oleh Prypin | a79abd4 | 2019-06-25 23:19:17 +0200 | [diff] [blame] | 428 | min_sdk_version = 16 |
Jianjun Zhu | 037f3e4 | 2017-08-15 21:48:37 +0800 | [diff] [blame] | 429 | deps += [ webrtc_root + "test:native_test_java" ] |
sakal | d7fdb80 | 2017-05-26 01:51:53 -0700 | [diff] [blame] | 430 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 431 | } |
| 432 | } |
| 433 | |
| 434 | template("rtc_source_set") { |
| 435 | source_set(target_name) { |
| 436 | forward_variables_from(invoker, |
| 437 | "*", |
| 438 | [ |
| 439 | "configs", |
| 440 | "public_configs", |
| 441 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 442 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 443 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 444 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 445 | if (!defined(visibility)) { |
| 446 | visibility = webrtc_default_visibility |
| 447 | } |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 448 | |
| 449 | # What's your poison? |
| 450 | if (defined(testonly) && testonly) { |
| 451 | assert(!defined(poisonous)) |
| 452 | assert(!defined(allow_poison)) |
| 453 | } else { |
| 454 | if (!defined(poisonous)) { |
| 455 | poisonous = [] |
| 456 | } |
| 457 | if (!defined(allow_poison)) { |
| 458 | allow_poison = [] |
| 459 | } |
| 460 | if (!defined(assert_no_deps)) { |
| 461 | assert_no_deps = [] |
| 462 | } |
| 463 | if (!defined(deps)) { |
| 464 | deps = [] |
| 465 | } |
| 466 | foreach(p, poisonous) { |
| 467 | deps += [ webrtc_root + ":poison_" + p ] |
| 468 | } |
| 469 | foreach(poison_type, all_poison_types) { |
| 470 | allow_dep = true |
| 471 | foreach(v, visibility) { |
| 472 | if (v == "*") { |
| 473 | allow_dep = false |
| 474 | } |
| 475 | } |
| 476 | foreach(p, allow_poison + poisonous) { |
| 477 | if (p == poison_type) { |
| 478 | allow_dep = true |
| 479 | } |
| 480 | } |
| 481 | if (!allow_dep) { |
| 482 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
Mirko Bonadei | 92dd35d | 2019-11-15 16:08:41 +0100 | [diff] [blame] | 487 | # Chromium should only depend on the WebRTC component in order to |
| 488 | # avoid to statically link WebRTC in a component build. |
| 489 | if (build_with_chromium) { |
| 490 | publicly_visible = false |
| 491 | foreach(v, visibility) { |
| 492 | if (v == "*") { |
| 493 | publicly_visible = true |
| 494 | } |
| 495 | } |
| 496 | if (publicly_visible) { |
| 497 | visibility = [] |
| 498 | visibility = webrtc_default_visibility |
| 499 | } |
| 500 | } |
| 501 | |
Mirko Bonadei | 96ede16 | 2018-09-06 13:45:44 +0200 | [diff] [blame] | 502 | if (!defined(testonly) || !testonly) { |
| 503 | configs += rtc_prod_configs |
| 504 | } |
| 505 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 506 | configs += invoker.configs |
Mirko Bonadei | 32ce18c | 2018-09-18 13:15:54 +0200 | [diff] [blame] | 507 | configs += rtc_library_impl_config |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 508 | configs -= rtc_remove_configs |
| 509 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 510 | public_configs = [ |
| 511 | rtc_common_inherited_config, |
| 512 | absl_include_config, |
| 513 | absl_define_config, |
| 514 | ] |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 515 | if (defined(testonly) && testonly) { |
| 516 | public_configs += [ absl_flags_config ] |
| 517 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 518 | if (defined(invoker.public_configs)) { |
| 519 | public_configs += invoker.public_configs |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 524 | template("rtc_static_library") { |
| 525 | static_library(target_name) { |
| 526 | forward_variables_from(invoker, |
| 527 | "*", |
| 528 | [ |
| 529 | "configs", |
| 530 | "public_configs", |
| 531 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 532 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 533 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 534 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 535 | if (!defined(visibility)) { |
| 536 | visibility = webrtc_default_visibility |
| 537 | } |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 538 | |
| 539 | # What's your poison? |
| 540 | if (defined(testonly) && testonly) { |
| 541 | assert(!defined(poisonous)) |
| 542 | assert(!defined(allow_poison)) |
| 543 | } else { |
| 544 | if (!defined(poisonous)) { |
| 545 | poisonous = [] |
| 546 | } |
| 547 | if (!defined(allow_poison)) { |
| 548 | allow_poison = [] |
| 549 | } |
| 550 | if (!defined(assert_no_deps)) { |
| 551 | assert_no_deps = [] |
| 552 | } |
| 553 | if (!defined(deps)) { |
| 554 | deps = [] |
| 555 | } |
| 556 | foreach(p, poisonous) { |
| 557 | deps += [ webrtc_root + ":poison_" + p ] |
| 558 | } |
| 559 | foreach(poison_type, all_poison_types) { |
| 560 | allow_dep = true |
| 561 | foreach(v, visibility) { |
| 562 | if (v == "*") { |
| 563 | allow_dep = false |
| 564 | } |
| 565 | } |
| 566 | foreach(p, allow_poison + poisonous) { |
| 567 | if (p == poison_type) { |
| 568 | allow_dep = true |
| 569 | } |
| 570 | } |
| 571 | if (!allow_dep) { |
| 572 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 573 | } |
| 574 | } |
| 575 | } |
| 576 | |
Mirko Bonadei | 96ede16 | 2018-09-06 13:45:44 +0200 | [diff] [blame] | 577 | if (!defined(testonly) || !testonly) { |
| 578 | configs += rtc_prod_configs |
| 579 | } |
| 580 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 581 | configs += invoker.configs |
Mirko Bonadei | 32ce18c | 2018-09-18 13:15:54 +0200 | [diff] [blame] | 582 | configs += rtc_library_impl_config |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 583 | configs -= rtc_remove_configs |
| 584 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 585 | public_configs = [ |
| 586 | rtc_common_inherited_config, |
| 587 | absl_include_config, |
| 588 | absl_define_config, |
| 589 | ] |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 590 | if (defined(testonly) && testonly) { |
| 591 | public_configs += [ absl_flags_config ] |
| 592 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 593 | if (defined(invoker.public_configs)) { |
| 594 | public_configs += invoker.public_configs |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | |
Mirko Bonadei | 86d053c | 2019-10-17 21:32:04 +0200 | [diff] [blame] | 599 | # This template automatically switches the target type between source_set |
| 600 | # and static_library. |
| 601 | # |
| 602 | # This should be the default target type for all the WebRTC targets with |
| 603 | # one exception. Do not use this template for header only targets, in that case |
| 604 | # rtc_source_set must be used in order to avoid build errors (e.g. libtool |
| 605 | # complains if the output .a file is empty). |
| 606 | # |
| 607 | # How does it work: |
| 608 | # Since all files in a source_set are linked into a final binary, while files |
| 609 | # in a static library are only linked in if at least one symbol in them is |
| 610 | # referenced, in component builds source_sets are easy to deal with because |
| 611 | # all their object files are passed to the linker to create a shared library. |
| 612 | # In release builds instead, static_libraries are preferred since they allow |
| 613 | # the linker to discard dead code. |
| 614 | # For the same reason, testonly targets will always be expanded to |
| 615 | # source_set in order to be sure that tests are present in the test binary. |
| 616 | template("rtc_library") { |
| 617 | if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) { |
| 618 | target_type = "source_set" |
| 619 | } else { |
| 620 | target_type = "static_library" |
| 621 | } |
| 622 | target(target_type, target_name) { |
| 623 | forward_variables_from(invoker, |
| 624 | "*", |
| 625 | [ |
| 626 | "configs", |
| 627 | "public_configs", |
| 628 | "suppressed_configs", |
| 629 | "visibility", |
| 630 | ]) |
| 631 | forward_variables_from(invoker, [ "visibility" ]) |
| 632 | if (!defined(visibility)) { |
| 633 | visibility = webrtc_default_visibility |
| 634 | } |
| 635 | |
| 636 | # What's your poison? |
| 637 | if (defined(testonly) && testonly) { |
| 638 | assert(!defined(poisonous)) |
| 639 | assert(!defined(allow_poison)) |
| 640 | } else { |
| 641 | if (!defined(poisonous)) { |
| 642 | poisonous = [] |
| 643 | } |
| 644 | if (!defined(allow_poison)) { |
| 645 | allow_poison = [] |
| 646 | } |
| 647 | if (!defined(assert_no_deps)) { |
| 648 | assert_no_deps = [] |
| 649 | } |
| 650 | if (!defined(deps)) { |
| 651 | deps = [] |
| 652 | } |
| 653 | foreach(p, poisonous) { |
| 654 | deps += [ webrtc_root + ":poison_" + p ] |
| 655 | } |
| 656 | foreach(poison_type, all_poison_types) { |
| 657 | allow_dep = true |
| 658 | foreach(v, visibility) { |
| 659 | if (v == "*") { |
| 660 | allow_dep = false |
| 661 | } |
| 662 | } |
| 663 | foreach(p, allow_poison + poisonous) { |
| 664 | if (p == poison_type) { |
| 665 | allow_dep = true |
| 666 | } |
| 667 | } |
| 668 | if (!allow_dep) { |
| 669 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 670 | } |
| 671 | } |
| 672 | } |
| 673 | |
Mirko Bonadei | 92dd35d | 2019-11-15 16:08:41 +0100 | [diff] [blame] | 674 | # Chromium should only depend on the WebRTC component in order to |
| 675 | # avoid to statically link WebRTC in a component build. |
| 676 | if (build_with_chromium) { |
| 677 | publicly_visible = false |
| 678 | foreach(v, visibility) { |
| 679 | if (v == "*") { |
| 680 | publicly_visible = true |
| 681 | } |
| 682 | } |
| 683 | if (publicly_visible) { |
| 684 | visibility = [] |
| 685 | visibility = webrtc_default_visibility |
| 686 | } |
| 687 | } |
| 688 | |
Mirko Bonadei | 86d053c | 2019-10-17 21:32:04 +0200 | [diff] [blame] | 689 | if (!defined(testonly) || !testonly) { |
| 690 | configs += rtc_prod_configs |
| 691 | } |
| 692 | |
| 693 | configs += invoker.configs |
| 694 | configs += rtc_library_impl_config |
| 695 | configs -= rtc_remove_configs |
| 696 | configs -= invoker.suppressed_configs |
| 697 | public_configs = [ |
| 698 | rtc_common_inherited_config, |
| 699 | absl_include_config, |
| 700 | absl_define_config, |
| 701 | ] |
| 702 | if (defined(testonly) && testonly) { |
| 703 | public_configs += [ absl_flags_config ] |
| 704 | } |
| 705 | if (defined(invoker.public_configs)) { |
| 706 | public_configs += invoker.public_configs |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | template("rtc_executable") { |
| 712 | executable(target_name) { |
| 713 | forward_variables_from(invoker, |
| 714 | "*", |
| 715 | [ |
| 716 | "deps", |
| 717 | "configs", |
| 718 | "public_configs", |
| 719 | "suppressed_configs", |
| 720 | "visibility", |
| 721 | ]) |
| 722 | forward_variables_from(invoker, [ "visibility" ]) |
| 723 | if (!defined(visibility)) { |
| 724 | visibility = webrtc_default_visibility |
| 725 | } |
| 726 | configs += invoker.configs |
| 727 | configs -= rtc_remove_configs |
| 728 | configs -= invoker.suppressed_configs |
| 729 | deps = invoker.deps |
| 730 | |
| 731 | public_configs = [ |
| 732 | rtc_common_inherited_config, |
| 733 | absl_include_config, |
| 734 | absl_define_config, |
| 735 | ] |
| 736 | if (defined(testonly) && testonly) { |
| 737 | public_configs += [ absl_flags_config ] |
| 738 | } |
| 739 | if (defined(invoker.public_configs)) { |
| 740 | public_configs += invoker.public_configs |
| 741 | } |
| 742 | if (is_win) { |
| 743 | deps += [ |
| 744 | # Give executables the default manifest on Windows (a no-op elsewhere). |
| 745 | "//build/win:default_exe_manifest", |
| 746 | ] |
| 747 | } |
| 748 | } |
| 749 | } |
| 750 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 751 | template("rtc_shared_library") { |
| 752 | shared_library(target_name) { |
| 753 | forward_variables_from(invoker, |
| 754 | "*", |
| 755 | [ |
| 756 | "configs", |
| 757 | "public_configs", |
| 758 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 759 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 760 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 761 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 762 | if (!defined(visibility)) { |
| 763 | visibility = webrtc_default_visibility |
| 764 | } |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 765 | |
| 766 | # What's your poison? |
| 767 | if (defined(testonly) && testonly) { |
| 768 | assert(!defined(poisonous)) |
| 769 | assert(!defined(allow_poison)) |
| 770 | } else { |
| 771 | if (!defined(poisonous)) { |
| 772 | poisonous = [] |
| 773 | } |
| 774 | if (!defined(allow_poison)) { |
| 775 | allow_poison = [] |
| 776 | } |
| 777 | if (!defined(assert_no_deps)) { |
| 778 | assert_no_deps = [] |
| 779 | } |
| 780 | if (!defined(deps)) { |
| 781 | deps = [] |
| 782 | } |
| 783 | foreach(p, poisonous) { |
| 784 | deps += [ webrtc_root + ":poison_" + p ] |
| 785 | } |
| 786 | foreach(poison_type, all_poison_types) { |
| 787 | allow_dep = true |
| 788 | foreach(v, visibility) { |
| 789 | if (v == "*") { |
| 790 | allow_dep = false |
| 791 | } |
| 792 | } |
| 793 | foreach(p, allow_poison + poisonous) { |
| 794 | if (p == poison_type) { |
| 795 | allow_dep = true |
| 796 | } |
| 797 | } |
| 798 | if (!allow_dep) { |
| 799 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 804 | configs += invoker.configs |
| 805 | configs -= rtc_remove_configs |
| 806 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 807 | public_configs = [ |
| 808 | rtc_common_inherited_config, |
| 809 | absl_include_config, |
| 810 | absl_define_config, |
| 811 | ] |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 812 | if (defined(testonly) && testonly) { |
| 813 | public_configs += [ absl_flags_config ] |
| 814 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 815 | if (defined(invoker.public_configs)) { |
| 816 | public_configs += invoker.public_configs |
| 817 | } |
| 818 | } |
| 819 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 820 | |
| 821 | if (is_ios) { |
| 822 | set_defaults("rtc_ios_xctest_test") { |
| 823 | configs = rtc_add_configs |
| 824 | suppressed_configs = [] |
| 825 | } |
| 826 | |
| 827 | template("rtc_ios_xctest_test") { |
| 828 | ios_xctest_test(target_name) { |
| 829 | forward_variables_from(invoker, |
| 830 | "*", |
| 831 | [ |
| 832 | "configs", |
| 833 | "public_configs", |
| 834 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 835 | "visibility", |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 836 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 837 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 838 | if (!defined(visibility)) { |
| 839 | visibility = webrtc_default_visibility |
| 840 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 841 | configs += invoker.configs |
| 842 | configs -= rtc_remove_configs |
| 843 | configs -= invoker.suppressed_configs |
| 844 | public_configs = [ rtc_common_inherited_config ] |
| 845 | if (defined(invoker.public_configs)) { |
| 846 | public_configs += invoker.public_configs |
| 847 | } |
| 848 | } |
| 849 | } |
Anders Carlsson | dc6b477 | 2018-01-15 13:31:03 +0100 | [diff] [blame] | 850 | |
Joel Sutherland | d2fb1bf | 2018-10-02 16:08:25 -0400 | [diff] [blame] | 851 | # TODO: Generate module.modulemap file to enable use in Swift |
| 852 | # projects. See "mac_framework_bundle_with_umbrella_header". |
Anders Carlsson | dc6b477 | 2018-01-15 13:31:03 +0100 | [diff] [blame] | 853 | template("ios_framework_bundle_with_umbrella_header") { |
| 854 | forward_variables_from(invoker, [ "output_name" ]) |
| 855 | umbrella_header_path = |
| 856 | "$target_gen_dir/$output_name.framework/Headers/$output_name.h" |
| 857 | |
| 858 | ios_framework_bundle(target_name) { |
| 859 | forward_variables_from(invoker, "*", []) |
| 860 | |
| 861 | deps += [ ":copy_umbrella_header_$target_name" ] |
| 862 | } |
| 863 | |
| 864 | action("umbrella_header_$target_name") { |
| 865 | forward_variables_from(invoker, [ "public_headers" ]) |
| 866 | |
| 867 | script = "//tools_webrtc/ios/generate_umbrella_header.py" |
| 868 | |
Mirko Bonadei | ccbe95f | 2020-01-21 12:10:10 +0100 | [diff] [blame] | 869 | outputs = [ umbrella_header_path ] |
Anders Carlsson | dc6b477 | 2018-01-15 13:31:03 +0100 | [diff] [blame] | 870 | args = [ |
| 871 | "--out", |
| 872 | rebase_path(umbrella_header_path, root_build_dir), |
| 873 | "--sources", |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 874 | ] + public_headers |
Anders Carlsson | dc6b477 | 2018-01-15 13:31:03 +0100 | [diff] [blame] | 875 | } |
| 876 | |
| 877 | copy("copy_umbrella_header_$target_name") { |
Mirko Bonadei | ccbe95f | 2020-01-21 12:10:10 +0100 | [diff] [blame] | 878 | sources = [ umbrella_header_path ] |
| 879 | outputs = |
| 880 | [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ] |
Anders Carlsson | dc6b477 | 2018-01-15 13:31:03 +0100 | [diff] [blame] | 881 | |
Mirko Bonadei | ccbe95f | 2020-01-21 12:10:10 +0100 | [diff] [blame] | 882 | deps = [ ":umbrella_header_$target_name" ] |
Anders Carlsson | dc6b477 | 2018-01-15 13:31:03 +0100 | [diff] [blame] | 883 | } |
| 884 | } |
| 885 | |
| 886 | set_defaults("ios_framework_bundle_with_umbrella_header") { |
| 887 | configs = default_shared_library_configs |
| 888 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 889 | } |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 890 | |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 891 | if (is_mac) { |
| 892 | template("mac_framework_bundle_with_umbrella_header") { |
| 893 | forward_variables_from(invoker, [ "output_name" ]) |
Anders Carlsson | 95c56ee | 2018-09-06 15:48:17 +0200 | [diff] [blame] | 894 | this_target_name = target_name |
| 895 | umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h" |
Joel Sutherland | d2fb1bf | 2018-10-02 16:08:25 -0400 | [diff] [blame] | 896 | modulemap_path = "$target_gen_dir/Modules/module.modulemap" |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 897 | |
| 898 | mac_framework_bundle(target_name) { |
Thomas Anderson | 6fde78c | 2019-01-23 10:40:29 -0800 | [diff] [blame] | 899 | forward_variables_from(invoker, "*", [ "configs" ]) |
| 900 | if (defined(invoker.configs)) { |
| 901 | configs += invoker.configs |
| 902 | } |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 903 | |
| 904 | framework_version = "A" |
Joel Sutherland | d2fb1bf | 2018-10-02 16:08:25 -0400 | [diff] [blame] | 905 | framework_contents = [ |
| 906 | "Headers", |
| 907 | "Modules", |
| 908 | "Resources", |
| 909 | ] |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 910 | |
| 911 | ldflags = [ |
| 912 | "-all_load", |
| 913 | "-install_name", |
| 914 | "@rpath/$output_name.framework/$output_name", |
| 915 | ] |
| 916 | |
| 917 | deps += [ |
Anders Carlsson | 95c56ee | 2018-09-06 15:48:17 +0200 | [diff] [blame] | 918 | ":copy_framework_headers_$this_target_name", |
Joel Sutherland | d2fb1bf | 2018-10-02 16:08:25 -0400 | [diff] [blame] | 919 | ":copy_modulemap_$this_target_name", |
Anders Carlsson | 95c56ee | 2018-09-06 15:48:17 +0200 | [diff] [blame] | 920 | ":copy_umbrella_header_$this_target_name", |
Joel Sutherland | d2fb1bf | 2018-10-02 16:08:25 -0400 | [diff] [blame] | 921 | ":modulemap_$this_target_name", |
Anders Carlsson | 95c56ee | 2018-09-06 15:48:17 +0200 | [diff] [blame] | 922 | ":umbrella_header_$this_target_name", |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 923 | ] |
| 924 | } |
| 925 | |
Anders Carlsson | 95c56ee | 2018-09-06 15:48:17 +0200 | [diff] [blame] | 926 | bundle_data("copy_framework_headers_$this_target_name") { |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 927 | forward_variables_from(invoker, [ "sources" ]) |
| 928 | |
Mirko Bonadei | ccbe95f | 2020-01-21 12:10:10 +0100 | [diff] [blame] | 929 | outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ] |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 930 | } |
| 931 | |
Joel Sutherland | d2fb1bf | 2018-10-02 16:08:25 -0400 | [diff] [blame] | 932 | action("modulemap_$this_target_name") { |
| 933 | script = "//tools_webrtc/ios/generate_modulemap.py" |
| 934 | args = [ |
| 935 | "--out", |
| 936 | rebase_path(modulemap_path, root_build_dir), |
| 937 | "--name", |
| 938 | output_name, |
| 939 | ] |
Mirko Bonadei | ccbe95f | 2020-01-21 12:10:10 +0100 | [diff] [blame] | 940 | outputs = [ modulemap_path ] |
Joel Sutherland | d2fb1bf | 2018-10-02 16:08:25 -0400 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | bundle_data("copy_modulemap_$this_target_name") { |
Mirko Bonadei | ccbe95f | 2020-01-21 12:10:10 +0100 | [diff] [blame] | 944 | sources = [ modulemap_path ] |
| 945 | outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ] |
| 946 | deps = [ ":modulemap_$this_target_name" ] |
Joel Sutherland | d2fb1bf | 2018-10-02 16:08:25 -0400 | [diff] [blame] | 947 | } |
| 948 | |
Anders Carlsson | 95c56ee | 2018-09-06 15:48:17 +0200 | [diff] [blame] | 949 | action("umbrella_header_$this_target_name") { |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 950 | forward_variables_from(invoker, [ "sources" ]) |
| 951 | |
| 952 | script = "//tools_webrtc/ios/generate_umbrella_header.py" |
| 953 | |
Mirko Bonadei | ccbe95f | 2020-01-21 12:10:10 +0100 | [diff] [blame] | 954 | outputs = [ umbrella_header_path ] |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 955 | args = [ |
| 956 | "--out", |
| 957 | rebase_path(umbrella_header_path, root_build_dir), |
| 958 | "--sources", |
| 959 | ] + sources |
| 960 | } |
| 961 | |
Anders Carlsson | 95c56ee | 2018-09-06 15:48:17 +0200 | [diff] [blame] | 962 | bundle_data("copy_umbrella_header_$this_target_name") { |
Mirko Bonadei | ccbe95f | 2020-01-21 12:10:10 +0100 | [diff] [blame] | 963 | sources = [ umbrella_header_path ] |
| 964 | outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ] |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 965 | |
Mirko Bonadei | ccbe95f | 2020-01-21 12:10:10 +0100 | [diff] [blame] | 966 | deps = [ ":umbrella_header_$this_target_name" ] |
Anders Carlsson | 37bbf79 | 2018-09-05 16:29:27 +0200 | [diff] [blame] | 967 | } |
| 968 | } |
| 969 | } |
| 970 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 971 | if (is_android) { |
| 972 | template("rtc_android_library") { |
| 973 | android_library(target_name) { |
| 974 | forward_variables_from(invoker, |
| 975 | "*", |
| 976 | [ |
| 977 | "configs", |
| 978 | "public_configs", |
| 979 | "suppressed_configs", |
| 980 | "visibility", |
| 981 | ]) |
| 982 | |
Oleh Prypin | 05aee74 | 2018-11-23 17:29:44 +0100 | [diff] [blame] | 983 | errorprone_args = [] |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 984 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 985 | # Treat warnings as errors. |
Oleh Prypin | 05aee74 | 2018-11-23 17:29:44 +0100 | [diff] [blame] | 986 | errorprone_args += [ "-Werror" ] |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 987 | |
Sami Kalliomäki | 68d5860 | 2019-01-24 12:56:12 +0100 | [diff] [blame] | 988 | # WebRTC supports API level 16 while Chromium only supports 19. |
| 989 | # (the manifest defines minimum supported SDK version) |
Oleh Prypin | 4cbb4ef | 2019-06-18 17:09:51 +0200 | [diff] [blame] | 990 | if (defined(invoker.min_sdk_version)) { |
| 991 | min_sdk_version = invoker.min_sdk_version |
Sami Kalliomäki | 68d5860 | 2019-01-24 12:56:12 +0100 | [diff] [blame] | 992 | } else { |
Oleh Prypin | 4cbb4ef | 2019-06-18 17:09:51 +0200 | [diff] [blame] | 993 | min_sdk_version = 16 |
Sami Kalliomäki | 68d5860 | 2019-01-24 12:56:12 +0100 | [diff] [blame] | 994 | } |
| 995 | |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 996 | # Add any arguments defined by the invoker. |
Oleh Prypin | 05aee74 | 2018-11-23 17:29:44 +0100 | [diff] [blame] | 997 | if (defined(invoker.errorprone_args)) { |
| 998 | errorprone_args += invoker.errorprone_args |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 999 | } |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 1000 | |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 1001 | if (!defined(deps)) { |
| 1002 | deps = [] |
| 1003 | } |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 1004 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 1005 | no_build_hooks = true |
| 1006 | } |
| 1007 | } |
| 1008 | |
| 1009 | template("rtc_android_apk") { |
| 1010 | android_apk(target_name) { |
| 1011 | forward_variables_from(invoker, |
| 1012 | "*", |
| 1013 | [ |
| 1014 | "configs", |
| 1015 | "public_configs", |
| 1016 | "suppressed_configs", |
| 1017 | "visibility", |
| 1018 | ]) |
| 1019 | |
| 1020 | # Treat warnings as errors. |
Yves Gerey | 2f385d2 | 2019-11-20 12:10:08 +0100 | [diff] [blame] | 1021 | errorprone_args = [] |
| 1022 | errorprone_args += [ "-Werror" ] |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 1023 | |
| 1024 | if (!defined(deps)) { |
| 1025 | deps = [] |
| 1026 | } |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 1027 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 1028 | no_build_hooks = true |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | template("rtc_instrumentation_test_apk") { |
| 1033 | instrumentation_test_apk(target_name) { |
| 1034 | forward_variables_from(invoker, |
| 1035 | "*", |
| 1036 | [ |
| 1037 | "configs", |
| 1038 | "public_configs", |
| 1039 | "suppressed_configs", |
| 1040 | "visibility", |
| 1041 | ]) |
| 1042 | |
| 1043 | # Treat warnings as errors. |
Yves Gerey | 2f385d2 | 2019-11-20 12:10:08 +0100 | [diff] [blame] | 1044 | errorprone_args = [] |
| 1045 | errorprone_args += [ "-Werror" ] |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 1046 | |
| 1047 | if (!defined(deps)) { |
| 1048 | deps = [] |
| 1049 | } |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 1050 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 1051 | no_build_hooks = true |
| 1052 | } |
| 1053 | } |
| 1054 | } |