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") |
ehmaldonado | 0d729b3 | 2017-02-10 01:38:23 -0800 | [diff] [blame] | 12 | import("//build/config/ui.gni") |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 13 | import("//build_overrides/build.gni") |
mbonadei | 9660627 | 2017-03-03 19:41:59 -0800 | [diff] [blame] | 14 | |
| 15 | if (!build_with_chromium && is_component_build) { |
| 16 | print("The Gn argument `is_component_build` is currently " + |
| 17 | "ignored for WebRTC builds.") |
| 18 | print("Component builds are supported by Chromium and the argument " + |
| 19 | "`is_component_build` makes it possible to create shared libraries " + |
| 20 | "instead of static libraries.") |
| 21 | print("If an app depends on WebRTC it makes sense to just depend on the " + |
| 22 | "WebRTC static library, so there is no difference between " + |
| 23 | "`is_component_build=true` and `is_component_build=false`.") |
| 24 | print( |
| 25 | "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md") |
| 26 | assert(!is_component_build, "Component builds are not supported in WebRTC.") |
| 27 | } |
| 28 | |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 29 | if (is_ios) { |
| 30 | import("//build/config/ios/rules.gni") |
| 31 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 32 | |
| 33 | declare_args() { |
Mirko Bonadei | 7040090 | 2018-08-21 15:44:28 +0200 | [diff] [blame] | 34 | # WARNING: This argument doesn't have any effect on the WebRTC build until |
| 35 | # https://webrtc-review.googlesource.com/c/src/+/94766 will land. |
Mirko Bonadei | 31b0b45 | 2018-08-22 10:37:11 +0200 | [diff] [blame] | 36 | # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which |
Mirko Bonadei | 7040090 | 2018-08-21 15:44:28 +0200 | [diff] [blame] | 37 | # will tell the pre-processor to remove the default definition of symbols |
| 38 | # needed to use field_trial. In that case a new implementation needs to be |
| 39 | # provided. |
Mirko Bonadei | 31b0b45 | 2018-08-22 10:37:11 +0200 | [diff] [blame] | 40 | if (build_with_chromium) { |
| 41 | # When WebRTC is built as part of Chromium it should exclude the default |
| 42 | # implementation of field_trial unless it is building for NACL or |
| 43 | # Chromecast. |
| 44 | rtc_exclude_field_trial_default = !is_nacl && !is_chromecast |
| 45 | } else { |
| 46 | rtc_exclude_field_trial_default = false |
| 47 | } |
Mirko Bonadei | 7040090 | 2018-08-21 15:44:28 +0200 | [diff] [blame] | 48 | |
Benjamin Wright | d6f86e8 | 2018-05-08 13:12:25 -0700 | [diff] [blame] | 49 | # Setting this to false will require the API user to pass in their own |
| 50 | # SSLCertificateVerifier to verify the certificates presented from a |
| 51 | # TLS-TURN server. In return disabling this saves around 100kb in the binary. |
| 52 | rtc_builtin_ssl_root_certificates = true |
| 53 | |
Karl Wiberg | eb254b4 | 2017-11-01 15:08:12 +0100 | [diff] [blame] | 54 | # Include the iLBC audio codec? |
| 55 | rtc_include_ilbc = true |
| 56 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 57 | # Disable this to avoid building the Opus audio codec. |
| 58 | rtc_include_opus = true |
| 59 | |
minyue | 2e03c66 | 2017-02-01 17:31:11 -0800 | [diff] [blame] | 60 | # Enable this if the Opus version upon which WebRTC is built supports direct |
| 61 | # encoding of 120 ms packets. |
minyue-webrtc | 516711c | 2017-07-27 17:45:49 +0200 | [diff] [blame] | 62 | rtc_opus_support_120ms_ptime = true |
minyue | 2e03c66 | 2017-02-01 17:31:11 -0800 | [diff] [blame] | 63 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 64 | # Enable this to let the Opus audio codec change complexity on the fly. |
| 65 | rtc_opus_variable_complexity = false |
| 66 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 67 | # Used to specify an external Jsoncpp include path when not compiling the |
| 68 | # library that comes with WebRTC (i.e. rtc_build_json == 0). |
| 69 | rtc_jsoncpp_root = "//third_party/jsoncpp/source/include" |
| 70 | |
| 71 | # Used to specify an external OpenSSL include path when not compiling the |
| 72 | # library that comes with WebRTC (i.e. rtc_build_ssl == 0). |
| 73 | rtc_ssl_root = "" |
| 74 | |
| 75 | # Selects fixed-point code where possible. |
| 76 | rtc_prefer_fixed_point = false |
| 77 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 78 | # Disable the code for the intelligibility enhancer by default. |
| 79 | rtc_enable_intelligibility_enhancer = false |
| 80 | |
| 81 | # Enable when an external authentication mechanism is used for performing |
| 82 | # packet authentication for RTP packets instead of libsrtp. |
| 83 | rtc_enable_external_auth = build_with_chromium |
| 84 | |
| 85 | # Selects whether debug dumps for the audio processing module |
| 86 | # should be generated. |
| 87 | apm_debug_dump = false |
| 88 | |
| 89 | # Set this to true to enable BWE test logging. |
| 90 | rtc_enable_bwe_test_logging = false |
| 91 | |
Joachim Bauch | 93e9134 | 2017-12-07 01:25:53 +0100 | [diff] [blame] | 92 | # Set this to false to skip building examples. |
| 93 | rtc_build_examples = true |
| 94 | |
| 95 | # Set this to false to skip building tools. |
| 96 | rtc_build_tools = true |
| 97 | |
Joachim Bauch | 75f18fc | 2017-12-20 21:25:47 +0100 | [diff] [blame] | 98 | # Set this to false to skip building code that requires X11. |
| 99 | rtc_use_x11 = use_x11 |
| 100 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 101 | # Enable to use the Mozilla internal settings. |
| 102 | build_with_mozilla = false |
| 103 | |
henrika | 883d00f | 2018-03-16 10:09:49 +0100 | [diff] [blame] | 104 | # Enable use of Android AAudio which requires Android SDK 26 or above and |
| 105 | # NDK r16 or above. |
| 106 | rtc_enable_android_aaudio = false |
| 107 | |
| 108 | # TODO(henrika): can this flag be removed? |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 109 | rtc_enable_android_opensl = false |
| 110 | |
| 111 | # Link-Time Optimizations. |
| 112 | # Executes code generation at link-time instead of compile-time. |
| 113 | # https://gcc.gnu.org/wiki/LinkTimeOptimization |
| 114 | rtc_use_lto = false |
| 115 | |
| 116 | # Set to "func", "block", "edge" for coverage generation. |
| 117 | # At unit test runtime set UBSAN_OPTIONS="coverage=1". |
| 118 | # It is recommend to set include_examples=0. |
| 119 | # Use llvm's sancov -html-report for human readable reports. |
| 120 | # See http://clang.llvm.org/docs/SanitizerCoverage.html . |
| 121 | rtc_sanitize_coverage = "" |
| 122 | |
perkj | 650fdae | 2017-08-25 05:00:11 -0700 | [diff] [blame] | 123 | # Links a default implementation of task queues to targets |
| 124 | # that depend on the target rtc_task_queue. Set to false to |
| 125 | # use an external implementation. |
| 126 | rtc_link_task_queue_impl = true |
| 127 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 128 | if (current_cpu == "arm" || current_cpu == "arm64") { |
| 129 | rtc_prefer_fixed_point = true |
| 130 | } |
| 131 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 132 | # Determines whether NEON code will be built. |
| 133 | rtc_build_with_neon = |
| 134 | (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64" |
| 135 | |
| 136 | # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on |
| 137 | # all platforms except Android and iOS. Because FFmpeg can be built |
| 138 | # with/without H.264 support, |ffmpeg_branding| has to separately be set to a |
| 139 | # 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] | 140 | # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 141 | # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING. |
| 142 | # http://www.openh264.org, https://www.ffmpeg.org/ |
Patrik Höglund | 3bb1194 | 2018-03-16 12:36:26 +0000 | [diff] [blame] | 143 | rtc_use_h264 = proprietary_codecs && !is_android && !is_ios |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 144 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 145 | # By default, use normal platform audio support or dummy audio, but don't |
| 146 | # use file-based audio playout and record. |
| 147 | rtc_use_dummy_audio_file_devices = false |
| 148 | |
henrika | 7be7883 | 2017-06-13 17:34:16 +0200 | [diff] [blame] | 149 | # When set to true, replace the audio output with a sinus tone at 440Hz. |
| 150 | # The ADM will ask for audio data from WebRTC but instead of reading real |
| 151 | # audio samples from NetEQ, a sinus tone will be generated and replace the |
| 152 | # real audio samples. |
| 153 | rtc_audio_device_plays_sinus_tone = false |
| 154 | |
Anders Carlsson | dd8c165 | 2018-01-30 10:32:13 +0100 | [diff] [blame] | 155 | # Disable this to build without support for built-in software codecs. |
| 156 | rtc_use_builtin_sw_codecs = true |
Anders Carlsson | 358f2e0 | 2018-06-04 10:24:37 +0200 | [diff] [blame] | 157 | |
| 158 | if (is_ios) { |
| 159 | # Build broadcast extension in AppRTCMobile for iOS. This results in the |
| 160 | # binary only running on iOS 11+, which is why it is disabled by default. |
| 161 | rtc_apprtcmobile_broadcast_extension = false |
| 162 | } |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 163 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 164 | |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 165 | if (!build_with_mozilla) { |
| 166 | import("//testing/test.gni") |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | # A second declare_args block, so that declarations within it can |
| 170 | # depend on the possibly overridden variables in the first |
| 171 | # declare_args block. |
| 172 | declare_args() { |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 173 | # Enables the use of protocol buffers for debug recordings. |
| 174 | rtc_enable_protobuf = !build_with_mozilla |
| 175 | |
| 176 | # Set this to disable building with support for SCTP data channels. |
| 177 | rtc_enable_sctp = !build_with_mozilla |
| 178 | |
| 179 | # Disable these to not build components which can be externally provided. |
| 180 | rtc_build_json = !build_with_mozilla |
| 181 | rtc_build_libsrtp = !build_with_mozilla |
| 182 | rtc_build_libvpx = !build_with_mozilla |
| 183 | rtc_libvpx_build_vp9 = !build_with_mozilla |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 184 | rtc_build_opus = !build_with_mozilla |
| 185 | rtc_build_ssl = !build_with_mozilla |
| 186 | rtc_build_usrsctp = !build_with_mozilla |
| 187 | |
| 188 | # Enable libevent task queues on platforms that support it. |
| 189 | # rtc_link_task_queue_impl must be set to true for this to |
| 190 | # have an effect. |
Wez | 00cecb9 | 2018-02-09 10:41:00 -0800 | [diff] [blame] | 191 | if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) { |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 192 | rtc_enable_libevent = false |
| 193 | rtc_build_libevent = false |
| 194 | } else { |
| 195 | rtc_enable_libevent = true |
| 196 | rtc_build_libevent = !build_with_mozilla |
| 197 | } |
| 198 | |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 199 | # Build sources requiring GTK. NOTICE: This is not present in Chrome OS |
| 200 | # build environments, even if available for Chromium builds. |
| 201 | rtc_use_gtk = !build_with_chromium && !build_with_mozilla |
| 202 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 203 | # Excluded in Chromium since its prerequisites don't require Pulse Audio. |
| 204 | rtc_include_pulse_audio = !build_with_chromium |
| 205 | |
| 206 | # Chromium uses its own IO handling, so the internal ADM is only built for |
| 207 | # standalone WebRTC. |
| 208 | rtc_include_internal_audio_device = !build_with_chromium |
| 209 | |
| 210 | # Include tests in standalone checkout. |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 211 | rtc_include_tests = !build_with_chromium && !build_with_mozilla |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | # Make it possible to provide custom locations for some libraries (move these |
| 215 | # up into declare_args should we need to actually use them for the GN build). |
| 216 | rtc_libvpx_dir = "//third_party/libvpx" |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 217 | rtc_opus_dir = "//third_party/opus" |
| 218 | |
| 219 | # Desktop capturer is supported only on Windows, OSX and Linux. |
Joachim Bauch | 75f18fc | 2017-12-20 21:25:47 +0100 | [diff] [blame] | 220 | rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 221 | |
| 222 | ############################################################################### |
| 223 | # Templates |
| 224 | # |
| 225 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 226 | # Points to // in webrtc stand-alone or to //third_party/webrtc/ in |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 227 | # chromium. |
| 228 | # We need absolute paths for all configs in templates as they are shared in |
| 229 | # different subdirectories. |
| 230 | webrtc_root = get_path_info(".", "abspath") |
| 231 | |
| 232 | # Global configuration that should be applied to all WebRTC targets. |
| 233 | # You normally shouldn't need to include this in your target as it's |
| 234 | # automatically included when using the rtc_* templates. |
| 235 | # It sets defines, include paths and compilation warnings accordingly, |
| 236 | # both for WebRTC stand-alone builds and for the scenario when WebRTC |
| 237 | # native code is built as part of Chromium. |
| 238 | rtc_common_configs = [ webrtc_root + ":common_config" ] |
| 239 | |
kthelgason | c097710 | 2017-04-24 00:57:16 -0700 | [diff] [blame] | 240 | if (is_mac || is_ios) { |
| 241 | rtc_common_configs += [ "//build/config/compiler:enable_arc" ] |
| 242 | } |
| 243 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 244 | # Global public configuration that should be applied to all WebRTC targets. You |
| 245 | # normally shouldn't need to include this in your target as it's automatically |
| 246 | # included when using the rtc_* templates. It set the defines, include paths and |
| 247 | # compilation warnings that should be propagated to dependents of the targets |
| 248 | # depending on the target having this config. |
| 249 | rtc_common_inherited_config = webrtc_root + ":common_inherited_config" |
| 250 | |
| 251 | # Common configs to remove or add in all rtc targets. |
| 252 | rtc_remove_configs = [] |
| 253 | rtc_add_configs = rtc_common_configs |
| 254 | |
| 255 | set_defaults("rtc_test") { |
| 256 | configs = rtc_add_configs |
| 257 | suppressed_configs = [] |
| 258 | } |
| 259 | |
| 260 | set_defaults("rtc_source_set") { |
| 261 | configs = rtc_add_configs |
| 262 | suppressed_configs = [] |
| 263 | } |
| 264 | |
| 265 | set_defaults("rtc_executable") { |
| 266 | configs = rtc_add_configs |
| 267 | suppressed_configs = [] |
| 268 | } |
| 269 | |
| 270 | set_defaults("rtc_static_library") { |
| 271 | configs = rtc_add_configs |
| 272 | suppressed_configs = [] |
| 273 | } |
| 274 | |
| 275 | set_defaults("rtc_shared_library") { |
| 276 | configs = rtc_add_configs |
| 277 | suppressed_configs = [] |
| 278 | } |
| 279 | |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 280 | webrtc_default_visibility = [ webrtc_root + "/*" ] |
| 281 | if (build_with_chromium) { |
| 282 | # Allow Chromium's WebRTC overrides targets to bypass the regular |
| 283 | # visibility restrictions. |
| 284 | webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ] |
| 285 | } |
| 286 | |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 287 | # ---- Poisons ---- |
| 288 | # |
| 289 | # The general idea is that some targets declare that they contain some |
| 290 | # kind of poison, which makes it impossible for other targets to |
| 291 | # depend on them (even transitively) unless they declare themselves |
| 292 | # immune to that particular type of poison. |
| 293 | # |
| 294 | # Targets that *contain* poison of type foo should contain the line |
| 295 | # |
| 296 | # poisonous = [ "foo" ] |
| 297 | # |
| 298 | # and targets that *are immune but arent't themselves poisonous* |
| 299 | # should contain |
| 300 | # |
| 301 | # allow_poison = [ "foo" ] |
| 302 | # |
| 303 | # This useful in cases where we have some large target or set of |
| 304 | # targets and want to ensure that most other targets do not |
| 305 | # transitively depend on them. For example, almost no high-level |
| 306 | # target should depend on the audio codecs, since we want WebRTC users |
| 307 | # to be able to inject any subset of them and actually end up with a |
| 308 | # binary that doesn't include the codecs they didn't inject. |
| 309 | # |
| 310 | # Test-only targets (`testonly` set to true) and non-public targets |
| 311 | # (`visibility` not containing "*") are automatically immune to all |
| 312 | # types of poison. |
| 313 | # |
| 314 | # Here's the complete list of all types of poison. It must be kept in |
| 315 | # 1:1 correspondence with the set of //:poison_* targets. |
| 316 | # |
| 317 | all_poison_types = [ |
| 318 | # Encoders and decoders for specific audio codecs such as Opus and iSAC. |
| 319 | "audio_codecs", |
Anders Carlsson | 1f433e4 | 2018-04-24 16:39:05 +0200 | [diff] [blame] | 320 | |
| 321 | # Software video codecs (VP8 and VP9 through libvpx). |
| 322 | "software_video_codecs", |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 323 | ] |
| 324 | |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 325 | absl_include_config = "//third_party/abseil-cpp:absl_include_config" |
| 326 | absl_define_config = "//third_party/abseil-cpp:absl_define_config" |
| 327 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 328 | template("rtc_test") { |
| 329 | test(target_name) { |
| 330 | forward_variables_from(invoker, |
| 331 | "*", |
| 332 | [ |
| 333 | "configs", |
| 334 | "public_configs", |
| 335 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 336 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 337 | ]) |
Mirko Bonadei | dd41194 | 2017-11-21 15:35:27 +0100 | [diff] [blame] | 338 | |
| 339 | # Always override to public because when target_os is Android the `test` |
| 340 | # template can override it to [ "*" ] and we want to avoid conditional |
| 341 | # visibility. |
Mirko Bonadei | 2155881 | 2017-11-21 12:47:34 +0100 | [diff] [blame] | 342 | visibility = [ "*" ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 343 | configs += invoker.configs |
| 344 | configs -= rtc_remove_configs |
| 345 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 346 | public_configs = [ |
| 347 | rtc_common_inherited_config, |
| 348 | absl_include_config, |
| 349 | absl_define_config, |
| 350 | ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 351 | if (defined(invoker.public_configs)) { |
| 352 | public_configs += invoker.public_configs |
| 353 | } |
sakal | d7fdb80 | 2017-05-26 01:51:53 -0700 | [diff] [blame] | 354 | if (!build_with_chromium && is_android) { |
Jianjun Zhu | 037f3e4 | 2017-08-15 21:48:37 +0800 | [diff] [blame] | 355 | android_manifest = webrtc_root + "test/android/AndroidManifest.xml" |
| 356 | deps += [ webrtc_root + "test:native_test_java" ] |
sakal | d7fdb80 | 2017-05-26 01:51:53 -0700 | [diff] [blame] | 357 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | |
| 361 | template("rtc_source_set") { |
| 362 | source_set(target_name) { |
| 363 | forward_variables_from(invoker, |
| 364 | "*", |
| 365 | [ |
| 366 | "configs", |
| 367 | "public_configs", |
| 368 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 369 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 370 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 371 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 372 | if (!defined(visibility)) { |
| 373 | visibility = webrtc_default_visibility |
| 374 | } |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 375 | |
| 376 | # What's your poison? |
| 377 | if (defined(testonly) && testonly) { |
| 378 | assert(!defined(poisonous)) |
| 379 | assert(!defined(allow_poison)) |
| 380 | } else { |
| 381 | if (!defined(poisonous)) { |
| 382 | poisonous = [] |
| 383 | } |
| 384 | if (!defined(allow_poison)) { |
| 385 | allow_poison = [] |
| 386 | } |
| 387 | if (!defined(assert_no_deps)) { |
| 388 | assert_no_deps = [] |
| 389 | } |
| 390 | if (!defined(deps)) { |
| 391 | deps = [] |
| 392 | } |
| 393 | foreach(p, poisonous) { |
| 394 | deps += [ webrtc_root + ":poison_" + p ] |
| 395 | } |
| 396 | foreach(poison_type, all_poison_types) { |
| 397 | allow_dep = true |
| 398 | foreach(v, visibility) { |
| 399 | if (v == "*") { |
| 400 | allow_dep = false |
| 401 | } |
| 402 | } |
| 403 | foreach(p, allow_poison + poisonous) { |
| 404 | if (p == poison_type) { |
| 405 | allow_dep = true |
| 406 | } |
| 407 | } |
| 408 | if (!allow_dep) { |
| 409 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | |
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, |
| 421 | ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 422 | if (defined(invoker.public_configs)) { |
| 423 | public_configs += invoker.public_configs |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | template("rtc_executable") { |
| 429 | executable(target_name) { |
| 430 | forward_variables_from(invoker, |
| 431 | "*", |
| 432 | [ |
| 433 | "deps", |
| 434 | "configs", |
| 435 | "public_configs", |
| 436 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 437 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 438 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 439 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 440 | if (!defined(visibility)) { |
| 441 | visibility = webrtc_default_visibility |
| 442 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 443 | configs += invoker.configs |
| 444 | configs -= rtc_remove_configs |
| 445 | configs -= invoker.suppressed_configs |
Tom Anderson | 9614a31 | 2018-06-11 15:10:34 -0700 | [diff] [blame] | 446 | deps = invoker.deps |
perkj | 650fdae | 2017-08-25 05:00:11 -0700 | [diff] [blame] | 447 | |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 448 | public_configs = [ |
| 449 | rtc_common_inherited_config, |
| 450 | absl_include_config, |
| 451 | absl_define_config, |
| 452 | ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 453 | if (defined(invoker.public_configs)) { |
| 454 | public_configs += invoker.public_configs |
| 455 | } |
Mirko Bonadei | 9427f48 | 2018-08-28 14:39:27 +0200 | [diff] [blame] | 456 | if (is_win) { |
| 457 | deps += [ |
| 458 | # Give executables the default manifest on Windows (a no-op elsewhere). |
| 459 | "//build/win:default_exe_manifest", |
| 460 | ] |
| 461 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 462 | } |
| 463 | } |
| 464 | |
| 465 | template("rtc_static_library") { |
| 466 | static_library(target_name) { |
| 467 | forward_variables_from(invoker, |
| 468 | "*", |
| 469 | [ |
| 470 | "configs", |
| 471 | "public_configs", |
| 472 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 473 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 474 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 475 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 476 | if (!defined(visibility)) { |
| 477 | visibility = webrtc_default_visibility |
| 478 | } |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 479 | |
| 480 | # What's your poison? |
| 481 | if (defined(testonly) && testonly) { |
| 482 | assert(!defined(poisonous)) |
| 483 | assert(!defined(allow_poison)) |
| 484 | } else { |
| 485 | if (!defined(poisonous)) { |
| 486 | poisonous = [] |
| 487 | } |
| 488 | if (!defined(allow_poison)) { |
| 489 | allow_poison = [] |
| 490 | } |
| 491 | if (!defined(assert_no_deps)) { |
| 492 | assert_no_deps = [] |
| 493 | } |
| 494 | if (!defined(deps)) { |
| 495 | deps = [] |
| 496 | } |
| 497 | foreach(p, poisonous) { |
| 498 | deps += [ webrtc_root + ":poison_" + p ] |
| 499 | } |
| 500 | foreach(poison_type, all_poison_types) { |
| 501 | allow_dep = true |
| 502 | foreach(v, visibility) { |
| 503 | if (v == "*") { |
| 504 | allow_dep = false |
| 505 | } |
| 506 | } |
| 507 | foreach(p, allow_poison + poisonous) { |
| 508 | if (p == poison_type) { |
| 509 | allow_dep = true |
| 510 | } |
| 511 | } |
| 512 | if (!allow_dep) { |
| 513 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 514 | } |
| 515 | } |
| 516 | } |
| 517 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 518 | configs += invoker.configs |
| 519 | configs -= rtc_remove_configs |
| 520 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 521 | public_configs = [ |
| 522 | rtc_common_inherited_config, |
| 523 | absl_include_config, |
| 524 | absl_define_config, |
| 525 | ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 526 | if (defined(invoker.public_configs)) { |
| 527 | public_configs += invoker.public_configs |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | template("rtc_shared_library") { |
| 533 | shared_library(target_name) { |
| 534 | forward_variables_from(invoker, |
| 535 | "*", |
| 536 | [ |
| 537 | "configs", |
| 538 | "public_configs", |
| 539 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 540 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 541 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 542 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 543 | if (!defined(visibility)) { |
| 544 | visibility = webrtc_default_visibility |
| 545 | } |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 546 | |
| 547 | # What's your poison? |
| 548 | if (defined(testonly) && testonly) { |
| 549 | assert(!defined(poisonous)) |
| 550 | assert(!defined(allow_poison)) |
| 551 | } else { |
| 552 | if (!defined(poisonous)) { |
| 553 | poisonous = [] |
| 554 | } |
| 555 | if (!defined(allow_poison)) { |
| 556 | allow_poison = [] |
| 557 | } |
| 558 | if (!defined(assert_no_deps)) { |
| 559 | assert_no_deps = [] |
| 560 | } |
| 561 | if (!defined(deps)) { |
| 562 | deps = [] |
| 563 | } |
| 564 | foreach(p, poisonous) { |
| 565 | deps += [ webrtc_root + ":poison_" + p ] |
| 566 | } |
| 567 | foreach(poison_type, all_poison_types) { |
| 568 | allow_dep = true |
| 569 | foreach(v, visibility) { |
| 570 | if (v == "*") { |
| 571 | allow_dep = false |
| 572 | } |
| 573 | } |
| 574 | foreach(p, allow_poison + poisonous) { |
| 575 | if (p == poison_type) { |
| 576 | allow_dep = true |
| 577 | } |
| 578 | } |
| 579 | if (!allow_dep) { |
| 580 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 581 | } |
| 582 | } |
| 583 | } |
| 584 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 585 | configs += invoker.configs |
| 586 | configs -= rtc_remove_configs |
| 587 | configs -= invoker.suppressed_configs |
Mirko Bonadei | 9a89a49 | 2018-05-29 14:22:32 +0000 | [diff] [blame] | 588 | public_configs = [ |
| 589 | rtc_common_inherited_config, |
| 590 | absl_include_config, |
| 591 | absl_define_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 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 598 | |
| 599 | if (is_ios) { |
| 600 | set_defaults("rtc_ios_xctest_test") { |
| 601 | configs = rtc_add_configs |
| 602 | suppressed_configs = [] |
| 603 | } |
| 604 | |
| 605 | template("rtc_ios_xctest_test") { |
| 606 | ios_xctest_test(target_name) { |
| 607 | forward_variables_from(invoker, |
| 608 | "*", |
| 609 | [ |
| 610 | "configs", |
| 611 | "public_configs", |
| 612 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 613 | "visibility", |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 614 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 615 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 616 | if (!defined(visibility)) { |
| 617 | visibility = webrtc_default_visibility |
| 618 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 619 | configs += invoker.configs |
| 620 | configs -= rtc_remove_configs |
| 621 | configs -= invoker.suppressed_configs |
| 622 | public_configs = [ rtc_common_inherited_config ] |
| 623 | if (defined(invoker.public_configs)) { |
| 624 | public_configs += invoker.public_configs |
| 625 | } |
| 626 | } |
| 627 | } |
Anders Carlsson | dc6b477 | 2018-01-15 13:31:03 +0100 | [diff] [blame] | 628 | |
| 629 | template("ios_framework_bundle_with_umbrella_header") { |
| 630 | forward_variables_from(invoker, [ "output_name" ]) |
| 631 | umbrella_header_path = |
| 632 | "$target_gen_dir/$output_name.framework/Headers/$output_name.h" |
| 633 | |
| 634 | ios_framework_bundle(target_name) { |
| 635 | forward_variables_from(invoker, "*", []) |
| 636 | |
| 637 | deps += [ ":copy_umbrella_header_$target_name" ] |
| 638 | } |
| 639 | |
| 640 | action("umbrella_header_$target_name") { |
| 641 | forward_variables_from(invoker, [ "public_headers" ]) |
| 642 | |
| 643 | script = "//tools_webrtc/ios/generate_umbrella_header.py" |
| 644 | |
| 645 | outputs = [ |
| 646 | umbrella_header_path, |
| 647 | ] |
| 648 | args = [ |
| 649 | "--out", |
| 650 | rebase_path(umbrella_header_path, root_build_dir), |
| 651 | "--sources", |
| 652 | ] + rebase_path(public_headers, "objc/Framework/Headers/") |
| 653 | } |
| 654 | |
| 655 | copy("copy_umbrella_header_$target_name") { |
| 656 | sources = [ |
| 657 | umbrella_header_path, |
| 658 | ] |
| 659 | outputs = [ |
| 660 | "$root_out_dir/$output_name.framework/Headers/$output_name.h", |
| 661 | ] |
| 662 | |
| 663 | deps = [ |
| 664 | ":umbrella_header_$target_name", |
| 665 | ] |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | set_defaults("ios_framework_bundle_with_umbrella_header") { |
| 670 | configs = default_shared_library_configs |
| 671 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 672 | } |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 673 | |
| 674 | if (is_android) { |
| 675 | template("rtc_android_library") { |
| 676 | android_library(target_name) { |
| 677 | forward_variables_from(invoker, |
| 678 | "*", |
| 679 | [ |
| 680 | "configs", |
| 681 | "public_configs", |
| 682 | "suppressed_configs", |
| 683 | "visibility", |
| 684 | ]) |
| 685 | |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 686 | javac_args = [] |
| 687 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 688 | # Treat warnings as errors. |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 689 | javac_args += [ "-Werror" ] |
| 690 | |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 691 | # TODO(crbug.com/824679): Find out why this fails in Chromium |
| 692 | if (!build_with_chromium) { |
| 693 | javac_args += [ |
| 694 | "-Xep:ParameterNotNullable:ERROR", |
| 695 | "-Xep:FieldMissingNullable:ERROR", |
| 696 | "-Xep:ReturnMissingNullable:ERROR", |
| 697 | ] |
| 698 | } |
| 699 | |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 700 | # Add any arguments defined by the invoker. |
| 701 | if (defined(invoker.javac_args)) { |
| 702 | javac_args += invoker.javac_args |
| 703 | } |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 704 | |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 705 | if (!defined(deps)) { |
| 706 | deps = [] |
| 707 | } |
| 708 | deps += [ "//third_party/jsr-305:jsr_305_javalib" ] |
| 709 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 710 | no_build_hooks = true |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | template("rtc_android_apk") { |
| 715 | android_apk(target_name) { |
| 716 | forward_variables_from(invoker, |
| 717 | "*", |
| 718 | [ |
| 719 | "configs", |
| 720 | "public_configs", |
| 721 | "suppressed_configs", |
| 722 | "visibility", |
| 723 | ]) |
| 724 | |
| 725 | # Treat warnings as errors. |
| 726 | javac_args = [ "-Werror" ] |
| 727 | |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 728 | # TODO(crbug.com/824679): Find out why this fails in Chromium |
| 729 | if (!build_with_chromium) { |
| 730 | javac_args += [ |
| 731 | "-Xep:ParameterNotNullable:ERROR", |
| 732 | "-Xep:FieldMissingNullable:ERROR", |
| 733 | "-Xep:ReturnMissingNullable:ERROR", |
| 734 | ] |
| 735 | } |
| 736 | |
| 737 | if (!defined(deps)) { |
| 738 | deps = [] |
| 739 | } |
| 740 | deps += [ "//third_party/jsr-305:jsr_305_javalib" ] |
| 741 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 742 | no_build_hooks = true |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | template("rtc_instrumentation_test_apk") { |
| 747 | instrumentation_test_apk(target_name) { |
| 748 | forward_variables_from(invoker, |
| 749 | "*", |
| 750 | [ |
| 751 | "configs", |
| 752 | "public_configs", |
| 753 | "suppressed_configs", |
| 754 | "visibility", |
| 755 | ]) |
| 756 | |
| 757 | # Treat warnings as errors. |
| 758 | javac_args = [ "-Werror" ] |
| 759 | |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 760 | # TODO(crbug.com/824679): Find out why this fails in Chromium |
| 761 | if (!build_with_chromium) { |
| 762 | javac_args += [ |
| 763 | "-Xep:ParameterNotNullable:ERROR", |
| 764 | "-Xep:FieldMissingNullable:ERROR", |
| 765 | "-Xep:ReturnMissingNullable:ERROR", |
| 766 | ] |
| 767 | } |
| 768 | |
| 769 | if (!defined(deps)) { |
| 770 | deps = [] |
| 771 | } |
| 772 | deps += [ "//third_party/jsr-305:jsr_305_javalib" ] |
| 773 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 774 | no_build_hooks = true |
| 775 | } |
| 776 | } |
| 777 | } |