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