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