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") |
| 11 | import("//build/config/sanitizers/sanitizers.gni") |
Tomas Popela | 318da51 | 2018-11-13 05:32:23 | [diff] [blame] | 12 | import("//build/config/sysroot.gni") |
ehmaldonado | 0d729b3 | 2017-02-10 09:38:23 | [diff] [blame] | 13 | import("//build/config/ui.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( |
| 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 | 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 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 38 | declare_args() { |
Mirko Bonadei | 028248c | 2018-10-10 10:19:02 | [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 08:37:11 | [diff] [blame] | 43 | # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which |
Mirko Bonadei | 7040090 | 2018-08-21 13:44:28 | [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 08:37:11 | [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 13:44:28 | [diff] [blame] | 55 | |
Mirko Bonadei | 906add4 | 2018-09-05 14:03:16 | [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 20:12:25 | [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 14:08:12 | [diff] [blame] | 67 | # Include the iLBC audio codec? |
| 68 | rtc_include_ilbc = true |
| 69 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 70 | # Disable this to avoid building the Opus audio codec. |
| 71 | rtc_include_opus = true |
| 72 | |
minyue | 2e03c66 | 2017-02-02 01:31:11 | [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 15:45:49 | [diff] [blame] | 75 | rtc_opus_support_120ms_ptime = true |
minyue | 2e03c66 | 2017-02-02 01:31:11 | [diff] [blame] | 76 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [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 14:58:22 | [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 14:58:22 | [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 00:25:53 | [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 20:25:47 | [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 05:32:23 | [diff] [blame] | 111 | # Set this to use PipeWire on the Wayland display server. |
Tomas Popela | 762543f | 2018-12-12 13:37:51 | [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 05:32:23 | [diff] [blame] | 119 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 120 | # Enable to use the Mozilla internal settings. |
| 121 | build_with_mozilla = false |
| 122 | |
henrika | 883d00f | 2018-03-16 09:09:49 | [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 14:58:22 | [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 14:58:22 | [diff] [blame] | 134 | if (current_cpu == "arm" || current_cpu == "arm64") { |
| 135 | rtc_prefer_fixed_point = true |
| 136 | } |
| 137 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [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 14:22:38 | [diff] [blame] | 146 | # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [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 09:47:18 | [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 14:58:22 | [diff] [blame] | 154 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [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 15:34:16 | [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 08:24:37 | [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 07:30:29 | [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 19:36:13 | [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 06:50:07 | [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 15:20:00 | [diff] [blame] | 193 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 194 | |
Dan Minor | 9c68613 | 2018-01-15 15:20:00 | [diff] [blame] | 195 | if (!build_with_mozilla) { |
| 196 | import("//testing/test.gni") |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [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 15:20:00 | [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 15:20:00 | [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 17:05:00 | [diff] [blame] | 219 | if (is_win || is_mac || is_ios || is_nacl || is_fuchsia || |
| 220 | target_cpu == "wasm") { |
Dan Minor | 9c68613 | 2018-01-15 15:20:00 | [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 15:20:00 | [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 14:58:22 | [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 15:20:00 | [diff] [blame] | 240 | rtc_include_tests = !build_with_chromium && !build_with_mozilla |
Oleh Prypin | 240b893 | 2019-06-07 11:27:07 | [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 |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | # Make it possible to provide custom locations for some libraries (move these |
| 248 | # up into declare_args should we need to actually use them for the GN build). |
| 249 | rtc_libvpx_dir = "//third_party/libvpx" |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 250 | rtc_opus_dir = "//third_party/opus" |
| 251 | |
| 252 | # Desktop capturer is supported only on Windows, OSX and Linux. |
Oleh Prypin | 240b893 | 2019-06-07 11:27:07 | [diff] [blame] | 253 | rtc_desktop_capture_supported = |
| 254 | (is_win && current_os != "winuwp") || is_mac || |
| 255 | (is_linux && (rtc_use_x11_extensions || rtc_use_pipewire)) |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 256 | |
| 257 | ############################################################################### |
| 258 | # Templates |
| 259 | # |
| 260 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 261 | # Points to // in webrtc stand-alone or to //third_party/webrtc/ in |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 262 | # chromium. |
| 263 | # We need absolute paths for all configs in templates as they are shared in |
| 264 | # different subdirectories. |
| 265 | webrtc_root = get_path_info(".", "abspath") |
| 266 | |
| 267 | # Global configuration that should be applied to all WebRTC targets. |
| 268 | # You normally shouldn't need to include this in your target as it's |
| 269 | # automatically included when using the rtc_* templates. |
| 270 | # It sets defines, include paths and compilation warnings accordingly, |
| 271 | # both for WebRTC stand-alone builds and for the scenario when WebRTC |
| 272 | # native code is built as part of Chromium. |
Will Harris | fc173d0 | 2018-08-29 20:56:00 | [diff] [blame] | 273 | rtc_common_configs = [ |
| 274 | webrtc_root + ":common_config", |
| 275 | "//build/config/compiler:no_size_t_to_int_warning", |
| 276 | ] |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 277 | |
kthelgason | c097710 | 2017-04-24 07:57:16 | [diff] [blame] | 278 | if (is_mac || is_ios) { |
| 279 | rtc_common_configs += [ "//build/config/compiler:enable_arc" ] |
| 280 | } |
| 281 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 282 | # Global public configuration that should be applied to all WebRTC targets. You |
| 283 | # normally shouldn't need to include this in your target as it's automatically |
| 284 | # included when using the rtc_* templates. It set the defines, include paths and |
| 285 | # compilation warnings that should be propagated to dependents of the targets |
| 286 | # depending on the target having this config. |
| 287 | rtc_common_inherited_config = webrtc_root + ":common_inherited_config" |
| 288 | |
| 289 | # Common configs to remove or add in all rtc targets. |
| 290 | rtc_remove_configs = [] |
Mirko Bonadei | fc52b91 | 2019-03-01 09:32:56 | [diff] [blame] | 291 | if (!build_with_chromium && is_clang) { |
| 292 | rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ] |
| 293 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 294 | rtc_add_configs = rtc_common_configs |
Mirko Bonadei | 96ede16a | 2018-09-06 11:45:44 | [diff] [blame] | 295 | rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ] |
Mirko Bonadei | 32ce18c | 2018-09-18 11:15:54 | [diff] [blame] | 296 | rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ] |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 297 | |
| 298 | set_defaults("rtc_test") { |
| 299 | configs = rtc_add_configs |
| 300 | suppressed_configs = [] |
| 301 | } |
| 302 | |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame^] | 303 | set_defaults("rtc_library") { |
| 304 | configs = rtc_add_configs |
| 305 | suppressed_configs = [] |
| 306 | } |
| 307 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 308 | set_defaults("rtc_source_set") { |
| 309 | configs = rtc_add_configs |
| 310 | suppressed_configs = [] |
| 311 | } |
| 312 | |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame^] | 313 | set_defaults("rtc_static_library") { |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 314 | configs = rtc_add_configs |
| 315 | suppressed_configs = [] |
| 316 | } |
| 317 | |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame^] | 318 | set_defaults("rtc_executable") { |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 319 | configs = rtc_add_configs |
| 320 | suppressed_configs = [] |
| 321 | } |
| 322 | |
| 323 | set_defaults("rtc_shared_library") { |
| 324 | configs = rtc_add_configs |
| 325 | suppressed_configs = [] |
| 326 | } |
| 327 | |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 | [diff] [blame] | 328 | webrtc_default_visibility = [ webrtc_root + "/*" ] |
| 329 | if (build_with_chromium) { |
| 330 | # Allow Chromium's WebRTC overrides targets to bypass the regular |
| 331 | # visibility restrictions. |
| 332 | webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ] |
| 333 | } |
| 334 | |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 335 | # ---- Poisons ---- |
| 336 | # |
| 337 | # The general idea is that some targets declare that they contain some |
| 338 | # kind of poison, which makes it impossible for other targets to |
| 339 | # depend on them (even transitively) unless they declare themselves |
| 340 | # immune to that particular type of poison. |
| 341 | # |
| 342 | # Targets that *contain* poison of type foo should contain the line |
| 343 | # |
| 344 | # poisonous = [ "foo" ] |
| 345 | # |
| 346 | # and targets that *are immune but arent't themselves poisonous* |
| 347 | # should contain |
| 348 | # |
| 349 | # allow_poison = [ "foo" ] |
| 350 | # |
| 351 | # This useful in cases where we have some large target or set of |
| 352 | # targets and want to ensure that most other targets do not |
| 353 | # transitively depend on them. For example, almost no high-level |
| 354 | # target should depend on the audio codecs, since we want WebRTC users |
| 355 | # to be able to inject any subset of them and actually end up with a |
| 356 | # binary that doesn't include the codecs they didn't inject. |
| 357 | # |
| 358 | # Test-only targets (`testonly` set to true) and non-public targets |
| 359 | # (`visibility` not containing "*") are automatically immune to all |
| 360 | # types of poison. |
| 361 | # |
| 362 | # Here's the complete list of all types of poison. It must be kept in |
| 363 | # 1:1 correspondence with the set of //:poison_* targets. |
| 364 | # |
| 365 | all_poison_types = [ |
| 366 | # Encoders and decoders for specific audio codecs such as Opus and iSAC. |
| 367 | "audio_codecs", |
Anders Carlsson | 1f433e4 | 2018-04-24 14:39:05 | [diff] [blame] | 368 | |
| 369 | # Software video codecs (VP8 and VP9 through libvpx). |
| 370 | "software_video_codecs", |
Danil Chapovalov | 41300af | 2019-07-10 10:44:43 | [diff] [blame] | 371 | |
| 372 | # Default task queue implementation. |
| 373 | "default_task_queue", |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 374 | ] |
| 375 | |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 376 | absl_include_config = "//third_party/abseil-cpp:absl_include_config" |
| 377 | absl_define_config = "//third_party/abseil-cpp:absl_define_config" |
| 378 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 379 | # Abseil Flags are testonly, so this config will only be applied to WebRTC targets |
| 380 | # that are testonly. |
| 381 | absl_flags_config = webrtc_root + ":absl_flags_configs" |
| 382 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 383 | template("rtc_test") { |
| 384 | test(target_name) { |
| 385 | forward_variables_from(invoker, |
| 386 | "*", |
| 387 | [ |
| 388 | "configs", |
| 389 | "public_configs", |
| 390 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 391 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 392 | ]) |
Mirko Bonadei | dd41194 | 2017-11-21 14:35:27 | [diff] [blame] | 393 | |
| 394 | # Always override to public because when target_os is Android the `test` |
| 395 | # template can override it to [ "*" ] and we want to avoid conditional |
| 396 | # visibility. |
Mirko Bonadei | 2155881 | 2017-11-21 11:47:34 | [diff] [blame] | 397 | visibility = [ "*" ] |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 398 | configs += invoker.configs |
| 399 | configs -= rtc_remove_configs |
| 400 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 401 | public_configs = [ |
| 402 | rtc_common_inherited_config, |
| 403 | absl_include_config, |
| 404 | absl_define_config, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 405 | absl_flags_config, |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 406 | ] |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 407 | if (defined(invoker.public_configs)) { |
| 408 | public_configs += invoker.public_configs |
| 409 | } |
sakal | d7fdb80 | 2017-05-26 08:51:53 | [diff] [blame] | 410 | if (!build_with_chromium && is_android) { |
Jianjun Zhu | 037f3e4 | 2017-08-15 13:48:37 | [diff] [blame] | 411 | android_manifest = webrtc_root + "test/android/AndroidManifest.xml" |
Oleh Prypin | a79abd4 | 2019-06-25 21:19:17 | [diff] [blame] | 412 | min_sdk_version = 16 |
Jianjun Zhu | 037f3e4 | 2017-08-15 13:48:37 | [diff] [blame] | 413 | deps += [ webrtc_root + "test:native_test_java" ] |
sakal | d7fdb80 | 2017-05-26 08:51:53 | [diff] [blame] | 414 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | |
| 418 | template("rtc_source_set") { |
| 419 | source_set(target_name) { |
| 420 | forward_variables_from(invoker, |
| 421 | "*", |
| 422 | [ |
| 423 | "configs", |
| 424 | "public_configs", |
| 425 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 426 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 427 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 428 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 | [diff] [blame] | 429 | if (!defined(visibility)) { |
| 430 | visibility = webrtc_default_visibility |
| 431 | } |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 432 | |
| 433 | # What's your poison? |
| 434 | if (defined(testonly) && testonly) { |
| 435 | assert(!defined(poisonous)) |
| 436 | assert(!defined(allow_poison)) |
| 437 | } else { |
| 438 | if (!defined(poisonous)) { |
| 439 | poisonous = [] |
| 440 | } |
| 441 | if (!defined(allow_poison)) { |
| 442 | allow_poison = [] |
| 443 | } |
| 444 | if (!defined(assert_no_deps)) { |
| 445 | assert_no_deps = [] |
| 446 | } |
| 447 | if (!defined(deps)) { |
| 448 | deps = [] |
| 449 | } |
| 450 | foreach(p, poisonous) { |
| 451 | deps += [ webrtc_root + ":poison_" + p ] |
| 452 | } |
| 453 | foreach(poison_type, all_poison_types) { |
| 454 | allow_dep = true |
| 455 | foreach(v, visibility) { |
| 456 | if (v == "*") { |
| 457 | allow_dep = false |
| 458 | } |
| 459 | } |
| 460 | foreach(p, allow_poison + poisonous) { |
| 461 | if (p == poison_type) { |
| 462 | allow_dep = true |
| 463 | } |
| 464 | } |
| 465 | if (!allow_dep) { |
| 466 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 467 | } |
| 468 | } |
| 469 | } |
| 470 | |
Mirko Bonadei | 96ede16a | 2018-09-06 11:45:44 | [diff] [blame] | 471 | if (!defined(testonly) || !testonly) { |
| 472 | configs += rtc_prod_configs |
| 473 | } |
| 474 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 475 | configs += invoker.configs |
Mirko Bonadei | 32ce18c | 2018-09-18 11:15:54 | [diff] [blame] | 476 | configs += rtc_library_impl_config |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 477 | configs -= rtc_remove_configs |
| 478 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 479 | public_configs = [ |
| 480 | rtc_common_inherited_config, |
| 481 | absl_include_config, |
| 482 | absl_define_config, |
| 483 | ] |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 484 | if (defined(testonly) && testonly) { |
| 485 | public_configs += [ absl_flags_config ] |
| 486 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 487 | if (defined(invoker.public_configs)) { |
| 488 | public_configs += invoker.public_configs |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 493 | template("rtc_static_library") { |
| 494 | static_library(target_name) { |
| 495 | forward_variables_from(invoker, |
| 496 | "*", |
| 497 | [ |
| 498 | "configs", |
| 499 | "public_configs", |
| 500 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 501 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 502 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 503 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 | [diff] [blame] | 504 | if (!defined(visibility)) { |
| 505 | visibility = webrtc_default_visibility |
| 506 | } |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 507 | |
| 508 | # What's your poison? |
| 509 | if (defined(testonly) && testonly) { |
| 510 | assert(!defined(poisonous)) |
| 511 | assert(!defined(allow_poison)) |
| 512 | } else { |
| 513 | if (!defined(poisonous)) { |
| 514 | poisonous = [] |
| 515 | } |
| 516 | if (!defined(allow_poison)) { |
| 517 | allow_poison = [] |
| 518 | } |
| 519 | if (!defined(assert_no_deps)) { |
| 520 | assert_no_deps = [] |
| 521 | } |
| 522 | if (!defined(deps)) { |
| 523 | deps = [] |
| 524 | } |
| 525 | foreach(p, poisonous) { |
| 526 | deps += [ webrtc_root + ":poison_" + p ] |
| 527 | } |
| 528 | foreach(poison_type, all_poison_types) { |
| 529 | allow_dep = true |
| 530 | foreach(v, visibility) { |
| 531 | if (v == "*") { |
| 532 | allow_dep = false |
| 533 | } |
| 534 | } |
| 535 | foreach(p, allow_poison + poisonous) { |
| 536 | if (p == poison_type) { |
| 537 | allow_dep = true |
| 538 | } |
| 539 | } |
| 540 | if (!allow_dep) { |
| 541 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | |
Mirko Bonadei | 96ede16a | 2018-09-06 11:45:44 | [diff] [blame] | 546 | if (!defined(testonly) || !testonly) { |
| 547 | configs += rtc_prod_configs |
| 548 | } |
| 549 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 550 | configs += invoker.configs |
Mirko Bonadei | 32ce18c | 2018-09-18 11:15:54 | [diff] [blame] | 551 | configs += rtc_library_impl_config |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 552 | configs -= rtc_remove_configs |
| 553 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 554 | public_configs = [ |
| 555 | rtc_common_inherited_config, |
| 556 | absl_include_config, |
| 557 | absl_define_config, |
| 558 | ] |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 559 | if (defined(testonly) && testonly) { |
| 560 | public_configs += [ absl_flags_config ] |
| 561 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 562 | if (defined(invoker.public_configs)) { |
| 563 | public_configs += invoker.public_configs |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | |
Mirko Bonadei | 86d053c | 2019-10-17 19:32:04 | [diff] [blame^] | 568 | # This template automatically switches the target type between source_set |
| 569 | # and static_library. |
| 570 | # |
| 571 | # This should be the default target type for all the WebRTC targets with |
| 572 | # one exception. Do not use this template for header only targets, in that case |
| 573 | # rtc_source_set must be used in order to avoid build errors (e.g. libtool |
| 574 | # complains if the output .a file is empty). |
| 575 | # |
| 576 | # How does it work: |
| 577 | # Since all files in a source_set are linked into a final binary, while files |
| 578 | # in a static library are only linked in if at least one symbol in them is |
| 579 | # referenced, in component builds source_sets are easy to deal with because |
| 580 | # all their object files are passed to the linker to create a shared library. |
| 581 | # In release builds instead, static_libraries are preferred since they allow |
| 582 | # the linker to discard dead code. |
| 583 | # For the same reason, testonly targets will always be expanded to |
| 584 | # source_set in order to be sure that tests are present in the test binary. |
| 585 | template("rtc_library") { |
| 586 | if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) { |
| 587 | target_type = "source_set" |
| 588 | } else { |
| 589 | target_type = "static_library" |
| 590 | } |
| 591 | target(target_type, target_name) { |
| 592 | forward_variables_from(invoker, |
| 593 | "*", |
| 594 | [ |
| 595 | "configs", |
| 596 | "public_configs", |
| 597 | "suppressed_configs", |
| 598 | "visibility", |
| 599 | ]) |
| 600 | forward_variables_from(invoker, [ "visibility" ]) |
| 601 | if (!defined(visibility)) { |
| 602 | visibility = webrtc_default_visibility |
| 603 | } |
| 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 | |
| 643 | if (!defined(testonly) || !testonly) { |
| 644 | configs += rtc_prod_configs |
| 645 | } |
| 646 | |
| 647 | configs += invoker.configs |
| 648 | configs += rtc_library_impl_config |
| 649 | configs -= rtc_remove_configs |
| 650 | configs -= invoker.suppressed_configs |
| 651 | public_configs = [ |
| 652 | rtc_common_inherited_config, |
| 653 | absl_include_config, |
| 654 | absl_define_config, |
| 655 | ] |
| 656 | if (defined(testonly) && testonly) { |
| 657 | public_configs += [ absl_flags_config ] |
| 658 | } |
| 659 | if (defined(invoker.public_configs)) { |
| 660 | public_configs += invoker.public_configs |
| 661 | } |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | template("rtc_executable") { |
| 666 | executable(target_name) { |
| 667 | forward_variables_from(invoker, |
| 668 | "*", |
| 669 | [ |
| 670 | "deps", |
| 671 | "configs", |
| 672 | "public_configs", |
| 673 | "suppressed_configs", |
| 674 | "visibility", |
| 675 | ]) |
| 676 | forward_variables_from(invoker, [ "visibility" ]) |
| 677 | if (!defined(visibility)) { |
| 678 | visibility = webrtc_default_visibility |
| 679 | } |
| 680 | configs += invoker.configs |
| 681 | configs -= rtc_remove_configs |
| 682 | configs -= invoker.suppressed_configs |
| 683 | deps = invoker.deps |
| 684 | |
| 685 | public_configs = [ |
| 686 | rtc_common_inherited_config, |
| 687 | absl_include_config, |
| 688 | absl_define_config, |
| 689 | ] |
| 690 | if (defined(testonly) && testonly) { |
| 691 | public_configs += [ absl_flags_config ] |
| 692 | } |
| 693 | if (defined(invoker.public_configs)) { |
| 694 | public_configs += invoker.public_configs |
| 695 | } |
| 696 | if (is_win) { |
| 697 | deps += [ |
| 698 | # Give executables the default manifest on Windows (a no-op elsewhere). |
| 699 | "//build/win:default_exe_manifest", |
| 700 | ] |
| 701 | } |
| 702 | } |
| 703 | } |
| 704 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 705 | template("rtc_shared_library") { |
| 706 | shared_library(target_name) { |
| 707 | forward_variables_from(invoker, |
| 708 | "*", |
| 709 | [ |
| 710 | "configs", |
| 711 | "public_configs", |
| 712 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 713 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 714 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 715 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 | [diff] [blame] | 716 | if (!defined(visibility)) { |
| 717 | visibility = webrtc_default_visibility |
| 718 | } |
Karl Wiberg | bb23c83 | 2018-04-22 17:55:00 | [diff] [blame] | 719 | |
| 720 | # What's your poison? |
| 721 | if (defined(testonly) && testonly) { |
| 722 | assert(!defined(poisonous)) |
| 723 | assert(!defined(allow_poison)) |
| 724 | } else { |
| 725 | if (!defined(poisonous)) { |
| 726 | poisonous = [] |
| 727 | } |
| 728 | if (!defined(allow_poison)) { |
| 729 | allow_poison = [] |
| 730 | } |
| 731 | if (!defined(assert_no_deps)) { |
| 732 | assert_no_deps = [] |
| 733 | } |
| 734 | if (!defined(deps)) { |
| 735 | deps = [] |
| 736 | } |
| 737 | foreach(p, poisonous) { |
| 738 | deps += [ webrtc_root + ":poison_" + p ] |
| 739 | } |
| 740 | foreach(poison_type, all_poison_types) { |
| 741 | allow_dep = true |
| 742 | foreach(v, visibility) { |
| 743 | if (v == "*") { |
| 744 | allow_dep = false |
| 745 | } |
| 746 | } |
| 747 | foreach(p, allow_poison + poisonous) { |
| 748 | if (p == poison_type) { |
| 749 | allow_dep = true |
| 750 | } |
| 751 | } |
| 752 | if (!allow_dep) { |
| 753 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 754 | } |
| 755 | } |
| 756 | } |
| 757 | |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 758 | configs += invoker.configs |
| 759 | configs -= rtc_remove_configs |
| 760 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 | [diff] [blame] | 761 | public_configs = [ |
| 762 | rtc_common_inherited_config, |
| 763 | absl_include_config, |
| 764 | absl_define_config, |
| 765 | ] |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 766 | if (defined(testonly) && testonly) { |
| 767 | public_configs += [ absl_flags_config ] |
| 768 | } |
mbonadei | 9aa3f0a | 2017-01-24 14:58:22 | [diff] [blame] | 769 | if (defined(invoker.public_configs)) { |
| 770 | public_configs += invoker.public_configs |
| 771 | } |
| 772 | } |
| 773 | } |
kthelgason | 4065a576 | 2017-02-14 12:58:56 | [diff] [blame] | 774 | |
| 775 | if (is_ios) { |
| 776 | set_defaults("rtc_ios_xctest_test") { |
| 777 | configs = rtc_add_configs |
| 778 | suppressed_configs = [] |
| 779 | } |
| 780 | |
| 781 | template("rtc_ios_xctest_test") { |
| 782 | ios_xctest_test(target_name) { |
| 783 | forward_variables_from(invoker, |
| 784 | "*", |
| 785 | [ |
| 786 | "configs", |
| 787 | "public_configs", |
| 788 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 789 | "visibility", |
kthelgason | 4065a576 | 2017-02-14 12:58:56 | [diff] [blame] | 790 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 09:16:19 | [diff] [blame] | 791 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 | [diff] [blame] | 792 | if (!defined(visibility)) { |
| 793 | visibility = webrtc_default_visibility |
| 794 | } |
kthelgason | 4065a576 | 2017-02-14 12:58:56 | [diff] [blame] | 795 | configs += invoker.configs |
| 796 | configs -= rtc_remove_configs |
| 797 | configs -= invoker.suppressed_configs |
| 798 | public_configs = [ rtc_common_inherited_config ] |
| 799 | if (defined(invoker.public_configs)) { |
| 800 | public_configs += invoker.public_configs |
| 801 | } |
| 802 | } |
| 803 | } |
Anders Carlsson | dc6b477 | 2018-01-15 12:31:03 | [diff] [blame] | 804 | |
Joel Sutherland | d2fb1bf | 2018-10-02 20:08:25 | [diff] [blame] | 805 | # TODO: Generate module.modulemap file to enable use in Swift |
| 806 | # projects. See "mac_framework_bundle_with_umbrella_header". |
Anders Carlsson | dc6b477 | 2018-01-15 12:31:03 | [diff] [blame] | 807 | template("ios_framework_bundle_with_umbrella_header") { |
| 808 | forward_variables_from(invoker, [ "output_name" ]) |
| 809 | umbrella_header_path = |
| 810 | "$target_gen_dir/$output_name.framework/Headers/$output_name.h" |
| 811 | |
| 812 | ios_framework_bundle(target_name) { |
| 813 | forward_variables_from(invoker, "*", []) |
| 814 | |
| 815 | deps += [ ":copy_umbrella_header_$target_name" ] |
| 816 | } |
| 817 | |
| 818 | action("umbrella_header_$target_name") { |
| 819 | forward_variables_from(invoker, [ "public_headers" ]) |
| 820 | |
| 821 | script = "//tools_webrtc/ios/generate_umbrella_header.py" |
| 822 | |
| 823 | outputs = [ |
| 824 | umbrella_header_path, |
| 825 | ] |
| 826 | args = [ |
| 827 | "--out", |
| 828 | rebase_path(umbrella_header_path, root_build_dir), |
| 829 | "--sources", |
Anders Carlsson | 7bca8ca | 2018-08-30 07:30:29 | [diff] [blame] | 830 | ] + public_headers |
Anders Carlsson | dc6b477 | 2018-01-15 12:31:03 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | copy("copy_umbrella_header_$target_name") { |
| 834 | sources = [ |
| 835 | umbrella_header_path, |
| 836 | ] |
| 837 | outputs = [ |
| 838 | "$root_out_dir/$output_name.framework/Headers/$output_name.h", |
| 839 | ] |
| 840 | |
| 841 | deps = [ |
| 842 | ":umbrella_header_$target_name", |
| 843 | ] |
| 844 | } |
| 845 | } |
| 846 | |
| 847 | set_defaults("ios_framework_bundle_with_umbrella_header") { |
| 848 | configs = default_shared_library_configs |
| 849 | } |
kthelgason | 4065a576 | 2017-02-14 12:58:56 | [diff] [blame] | 850 | } |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 851 | |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 852 | if (is_mac) { |
| 853 | template("mac_framework_bundle_with_umbrella_header") { |
| 854 | forward_variables_from(invoker, [ "output_name" ]) |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 855 | this_target_name = target_name |
| 856 | umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h" |
Joel Sutherland | d2fb1bf | 2018-10-02 20:08:25 | [diff] [blame] | 857 | modulemap_path = "$target_gen_dir/Modules/module.modulemap" |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 858 | |
| 859 | mac_framework_bundle(target_name) { |
Thomas Anderson | 6fde78c | 2019-01-23 18:40:29 | [diff] [blame] | 860 | forward_variables_from(invoker, "*", [ "configs" ]) |
| 861 | if (defined(invoker.configs)) { |
| 862 | configs += invoker.configs |
| 863 | } |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 864 | |
| 865 | framework_version = "A" |
Joel Sutherland | d2fb1bf | 2018-10-02 20:08:25 | [diff] [blame] | 866 | framework_contents = [ |
| 867 | "Headers", |
| 868 | "Modules", |
| 869 | "Resources", |
| 870 | ] |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 871 | |
| 872 | ldflags = [ |
| 873 | "-all_load", |
| 874 | "-install_name", |
| 875 | "@rpath/$output_name.framework/$output_name", |
| 876 | ] |
| 877 | |
| 878 | deps += [ |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 879 | ":copy_framework_headers_$this_target_name", |
Joel Sutherland | d2fb1bf | 2018-10-02 20:08:25 | [diff] [blame] | 880 | ":copy_modulemap_$this_target_name", |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 881 | ":copy_umbrella_header_$this_target_name", |
Joel Sutherland | d2fb1bf | 2018-10-02 20:08:25 | [diff] [blame] | 882 | ":modulemap_$this_target_name", |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 883 | ":umbrella_header_$this_target_name", |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 884 | ] |
| 885 | } |
| 886 | |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 887 | bundle_data("copy_framework_headers_$this_target_name") { |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 888 | forward_variables_from(invoker, [ "sources" ]) |
| 889 | |
| 890 | outputs = [ |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 891 | "{{bundle_contents_dir}}/Headers/{{source_file_part}}", |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 892 | ] |
| 893 | } |
| 894 | |
Joel Sutherland | d2fb1bf | 2018-10-02 20:08:25 | [diff] [blame] | 895 | action("modulemap_$this_target_name") { |
| 896 | script = "//tools_webrtc/ios/generate_modulemap.py" |
| 897 | args = [ |
| 898 | "--out", |
| 899 | rebase_path(modulemap_path, root_build_dir), |
| 900 | "--name", |
| 901 | output_name, |
| 902 | ] |
| 903 | outputs = [ |
| 904 | modulemap_path, |
| 905 | ] |
| 906 | } |
| 907 | |
| 908 | bundle_data("copy_modulemap_$this_target_name") { |
| 909 | sources = [ |
| 910 | modulemap_path, |
| 911 | ] |
| 912 | outputs = [ |
| 913 | "{{bundle_contents_dir}}/Modules/module.modulemap", |
| 914 | ] |
| 915 | deps = [ |
| 916 | ":modulemap_$this_target_name", |
| 917 | ] |
| 918 | } |
| 919 | |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 920 | action("umbrella_header_$this_target_name") { |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 921 | forward_variables_from(invoker, [ "sources" ]) |
| 922 | |
| 923 | script = "//tools_webrtc/ios/generate_umbrella_header.py" |
| 924 | |
| 925 | outputs = [ |
| 926 | umbrella_header_path, |
| 927 | ] |
| 928 | args = [ |
| 929 | "--out", |
| 930 | rebase_path(umbrella_header_path, root_build_dir), |
| 931 | "--sources", |
| 932 | ] + sources |
| 933 | } |
| 934 | |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 935 | bundle_data("copy_umbrella_header_$this_target_name") { |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 936 | sources = [ |
| 937 | umbrella_header_path, |
| 938 | ] |
| 939 | outputs = [ |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 940 | "{{bundle_contents_dir}}/Headers/$output_name.h", |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 941 | ] |
| 942 | |
| 943 | deps = [ |
Anders Carlsson | 95c56ee | 2018-09-06 13:48:17 | [diff] [blame] | 944 | ":umbrella_header_$this_target_name", |
Anders Carlsson | 37bbf79 | 2018-09-05 14:29:27 | [diff] [blame] | 945 | ] |
| 946 | } |
| 947 | } |
| 948 | } |
| 949 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 950 | if (is_android) { |
| 951 | template("rtc_android_library") { |
| 952 | android_library(target_name) { |
| 953 | forward_variables_from(invoker, |
| 954 | "*", |
| 955 | [ |
| 956 | "configs", |
| 957 | "public_configs", |
| 958 | "suppressed_configs", |
| 959 | "visibility", |
| 960 | ]) |
| 961 | |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 962 | errorprone_args = [] |
Sami Kalliomäki | e7fac68 | 2018-03-20 15:32:49 | [diff] [blame] | 963 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 964 | # Treat warnings as errors. |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 965 | errorprone_args += [ "-Werror" ] |
Sami Kalliomäki | e7fac68 | 2018-03-20 15:32:49 | [diff] [blame] | 966 | |
Sami Kalliomäki | 68d5860 | 2019-01-24 11:56:12 | [diff] [blame] | 967 | # WebRTC supports API level 16 while Chromium only supports 19. |
| 968 | # (the manifest defines minimum supported SDK version) |
Oleh Prypin | 4cbb4ef | 2019-06-18 15:09:51 | [diff] [blame] | 969 | if (defined(invoker.min_sdk_version)) { |
| 970 | min_sdk_version = invoker.min_sdk_version |
Sami Kalliomäki | 68d5860 | 2019-01-24 11:56:12 | [diff] [blame] | 971 | } else { |
Oleh Prypin | 4cbb4ef | 2019-06-18 15:09:51 | [diff] [blame] | 972 | min_sdk_version = 16 |
Sami Kalliomäki | 68d5860 | 2019-01-24 11:56:12 | [diff] [blame] | 973 | } |
| 974 | |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 975 | # TODO(crbug.com/824679): Find out why this fails in Chromium |
| 976 | if (!build_with_chromium) { |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 977 | errorprone_args += [ |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 978 | "-Xep:ParameterNotNullable:ERROR", |
| 979 | "-Xep:FieldMissingNullable:ERROR", |
| 980 | "-Xep:ReturnMissingNullable:ERROR", |
| 981 | ] |
| 982 | } |
| 983 | |
Sami Kalliomäki | e7fac68 | 2018-03-20 15:32:49 | [diff] [blame] | 984 | # Add any arguments defined by the invoker. |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 985 | if (defined(invoker.errorprone_args)) { |
| 986 | errorprone_args += invoker.errorprone_args |
Sami Kalliomäki | e7fac68 | 2018-03-20 15:32:49 | [diff] [blame] | 987 | } |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 988 | |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 989 | if (!defined(deps)) { |
| 990 | deps = [] |
| 991 | } |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 992 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 993 | no_build_hooks = true |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | template("rtc_android_apk") { |
| 998 | android_apk(target_name) { |
| 999 | forward_variables_from(invoker, |
| 1000 | "*", |
| 1001 | [ |
| 1002 | "configs", |
| 1003 | "public_configs", |
| 1004 | "suppressed_configs", |
| 1005 | "visibility", |
| 1006 | ]) |
| 1007 | |
| 1008 | # Treat warnings as errors. |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 1009 | errorprone_args = [ "-Werror" ] |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1010 | |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1011 | # TODO(crbug.com/824679): Find out why this fails in Chromium |
| 1012 | if (!build_with_chromium) { |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 1013 | errorprone_args += [ |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1014 | "-Xep:ParameterNotNullable:ERROR", |
| 1015 | "-Xep:FieldMissingNullable:ERROR", |
| 1016 | "-Xep:ReturnMissingNullable:ERROR", |
| 1017 | ] |
| 1018 | } |
| 1019 | |
| 1020 | if (!defined(deps)) { |
| 1021 | deps = [] |
| 1022 | } |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1023 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1024 | no_build_hooks = true |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | template("rtc_instrumentation_test_apk") { |
| 1029 | instrumentation_test_apk(target_name) { |
| 1030 | forward_variables_from(invoker, |
| 1031 | "*", |
| 1032 | [ |
| 1033 | "configs", |
| 1034 | "public_configs", |
| 1035 | "suppressed_configs", |
| 1036 | "visibility", |
| 1037 | ]) |
| 1038 | |
| 1039 | # Treat warnings as errors. |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 1040 | errorprone_args = [ "-Werror" ] |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1041 | |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1042 | # TODO(crbug.com/824679): Find out why this fails in Chromium |
| 1043 | if (!build_with_chromium) { |
Oleh Prypin | 05aee74 | 2018-11-23 16:29:44 | [diff] [blame] | 1044 | errorprone_args += [ |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1045 | "-Xep:ParameterNotNullable:ERROR", |
| 1046 | "-Xep:FieldMissingNullable:ERROR", |
| 1047 | "-Xep:ReturnMissingNullable:ERROR", |
| 1048 | ] |
| 1049 | } |
| 1050 | |
| 1051 | if (!defined(deps)) { |
| 1052 | deps = [] |
| 1053 | } |
Sami Kalliomäki | dc52651 | 2018-03-27 15:07:27 | [diff] [blame] | 1054 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 | [diff] [blame] | 1055 | no_build_hooks = true |
| 1056 | } |
| 1057 | } |
| 1058 | } |