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 | |
| 174 | # Enable libevent task queues on platforms that support it. |
| 175 | # rtc_link_task_queue_impl must be set to true for this to |
| 176 | # have an effect. |
Wez | 00cecb9 | 2018-02-09 10:41:00 -0800 | [diff] [blame] | 177 | if (is_win || is_mac || is_ios || is_nacl || is_fuchsia) { |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 178 | rtc_enable_libevent = false |
| 179 | rtc_build_libevent = false |
| 180 | } else { |
| 181 | rtc_enable_libevent = true |
| 182 | rtc_build_libevent = !build_with_mozilla |
| 183 | } |
| 184 | |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 185 | # Build sources requiring GTK. NOTICE: This is not present in Chrome OS |
| 186 | # build environments, even if available for Chromium builds. |
| 187 | rtc_use_gtk = !build_with_chromium && !build_with_mozilla |
| 188 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 189 | # Excluded in Chromium since its prerequisites don't require Pulse Audio. |
| 190 | rtc_include_pulse_audio = !build_with_chromium |
| 191 | |
| 192 | # Chromium uses its own IO handling, so the internal ADM is only built for |
| 193 | # standalone WebRTC. |
| 194 | rtc_include_internal_audio_device = !build_with_chromium |
| 195 | |
| 196 | # Include tests in standalone checkout. |
Dan Minor | 9c68613 | 2018-01-15 10:20:00 -0500 | [diff] [blame] | 197 | rtc_include_tests = !build_with_chromium && !build_with_mozilla |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | # Make it possible to provide custom locations for some libraries (move these |
| 201 | # up into declare_args should we need to actually use them for the GN build). |
| 202 | rtc_libvpx_dir = "//third_party/libvpx" |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 203 | rtc_opus_dir = "//third_party/opus" |
| 204 | |
| 205 | # Desktop capturer is supported only on Windows, OSX and Linux. |
Joachim Bauch | 75f18fc | 2017-12-20 21:25:47 +0100 | [diff] [blame] | 206 | rtc_desktop_capture_supported = is_win || is_mac || (is_linux && rtc_use_x11) |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 207 | |
| 208 | ############################################################################### |
| 209 | # Templates |
| 210 | # |
| 211 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 212 | # Points to // in webrtc stand-alone or to //third_party/webrtc/ in |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 213 | # chromium. |
| 214 | # We need absolute paths for all configs in templates as they are shared in |
| 215 | # different subdirectories. |
| 216 | webrtc_root = get_path_info(".", "abspath") |
| 217 | |
| 218 | # Global configuration that should be applied to all WebRTC targets. |
| 219 | # You normally shouldn't need to include this in your target as it's |
| 220 | # automatically included when using the rtc_* templates. |
| 221 | # It sets defines, include paths and compilation warnings accordingly, |
| 222 | # both for WebRTC stand-alone builds and for the scenario when WebRTC |
| 223 | # native code is built as part of Chromium. |
| 224 | rtc_common_configs = [ webrtc_root + ":common_config" ] |
| 225 | |
kthelgason | c097710 | 2017-04-24 00:57:16 -0700 | [diff] [blame] | 226 | if (is_mac || is_ios) { |
| 227 | rtc_common_configs += [ "//build/config/compiler:enable_arc" ] |
| 228 | } |
| 229 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 230 | # Global public configuration that should be applied to all WebRTC targets. You |
| 231 | # normally shouldn't need to include this in your target as it's automatically |
| 232 | # included when using the rtc_* templates. It set the defines, include paths and |
| 233 | # compilation warnings that should be propagated to dependents of the targets |
| 234 | # depending on the target having this config. |
| 235 | rtc_common_inherited_config = webrtc_root + ":common_inherited_config" |
| 236 | |
| 237 | # Common configs to remove or add in all rtc targets. |
| 238 | rtc_remove_configs = [] |
| 239 | rtc_add_configs = rtc_common_configs |
| 240 | |
| 241 | set_defaults("rtc_test") { |
| 242 | configs = rtc_add_configs |
| 243 | suppressed_configs = [] |
| 244 | } |
| 245 | |
| 246 | set_defaults("rtc_source_set") { |
| 247 | configs = rtc_add_configs |
| 248 | suppressed_configs = [] |
| 249 | } |
| 250 | |
| 251 | set_defaults("rtc_executable") { |
| 252 | configs = rtc_add_configs |
| 253 | suppressed_configs = [] |
| 254 | } |
| 255 | |
| 256 | set_defaults("rtc_static_library") { |
| 257 | configs = rtc_add_configs |
| 258 | suppressed_configs = [] |
| 259 | } |
| 260 | |
| 261 | set_defaults("rtc_shared_library") { |
| 262 | configs = rtc_add_configs |
| 263 | suppressed_configs = [] |
| 264 | } |
| 265 | |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 266 | webrtc_default_visibility = [ webrtc_root + "/*" ] |
| 267 | if (build_with_chromium) { |
| 268 | # Allow Chromium's WebRTC overrides targets to bypass the regular |
| 269 | # visibility restrictions. |
| 270 | webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ] |
| 271 | } |
| 272 | |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 273 | # ---- Poisons ---- |
| 274 | # |
| 275 | # The general idea is that some targets declare that they contain some |
| 276 | # kind of poison, which makes it impossible for other targets to |
| 277 | # depend on them (even transitively) unless they declare themselves |
| 278 | # immune to that particular type of poison. |
| 279 | # |
| 280 | # Targets that *contain* poison of type foo should contain the line |
| 281 | # |
| 282 | # poisonous = [ "foo" ] |
| 283 | # |
| 284 | # and targets that *are immune but arent't themselves poisonous* |
| 285 | # should contain |
| 286 | # |
| 287 | # allow_poison = [ "foo" ] |
| 288 | # |
| 289 | # This useful in cases where we have some large target or set of |
| 290 | # targets and want to ensure that most other targets do not |
| 291 | # transitively depend on them. For example, almost no high-level |
| 292 | # target should depend on the audio codecs, since we want WebRTC users |
| 293 | # to be able to inject any subset of them and actually end up with a |
| 294 | # binary that doesn't include the codecs they didn't inject. |
| 295 | # |
| 296 | # Test-only targets (`testonly` set to true) and non-public targets |
| 297 | # (`visibility` not containing "*") are automatically immune to all |
| 298 | # types of poison. |
| 299 | # |
| 300 | # Here's the complete list of all types of poison. It must be kept in |
| 301 | # 1:1 correspondence with the set of //:poison_* targets. |
| 302 | # |
| 303 | all_poison_types = [ |
| 304 | # Encoders and decoders for specific audio codecs such as Opus and iSAC. |
| 305 | "audio_codecs", |
Anders Carlsson | 1f433e4 | 2018-04-24 16:39:05 +0200 | [diff] [blame] | 306 | |
| 307 | # Software video codecs (VP8 and VP9 through libvpx). |
| 308 | "software_video_codecs", |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 309 | ] |
| 310 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 311 | template("rtc_test") { |
| 312 | test(target_name) { |
| 313 | forward_variables_from(invoker, |
| 314 | "*", |
| 315 | [ |
| 316 | "configs", |
| 317 | "public_configs", |
| 318 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 319 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 320 | ]) |
Mirko Bonadei | dd41194 | 2017-11-21 15:35:27 +0100 | [diff] [blame] | 321 | |
| 322 | # Always override to public because when target_os is Android the `test` |
| 323 | # template can override it to [ "*" ] and we want to avoid conditional |
| 324 | # visibility. |
Mirko Bonadei | 2155881 | 2017-11-21 12:47:34 +0100 | [diff] [blame] | 325 | visibility = [ "*" ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 326 | configs += invoker.configs |
| 327 | configs -= rtc_remove_configs |
| 328 | configs -= invoker.suppressed_configs |
Mirko Bonadei | d161eda | 2018-04-19 00:07:31 +0000 | [diff] [blame] | 329 | public_configs = [ rtc_common_inherited_config ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 330 | if (defined(invoker.public_configs)) { |
| 331 | public_configs += invoker.public_configs |
| 332 | } |
sakal | d7fdb80 | 2017-05-26 01:51:53 -0700 | [diff] [blame] | 333 | if (!build_with_chromium && is_android) { |
Jianjun Zhu | 037f3e4 | 2017-08-15 21:48:37 +0800 | [diff] [blame] | 334 | android_manifest = webrtc_root + "test/android/AndroidManifest.xml" |
| 335 | deps += [ webrtc_root + "test:native_test_java" ] |
sakal | d7fdb80 | 2017-05-26 01:51:53 -0700 | [diff] [blame] | 336 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 337 | } |
| 338 | } |
| 339 | |
| 340 | template("rtc_source_set") { |
| 341 | source_set(target_name) { |
| 342 | forward_variables_from(invoker, |
| 343 | "*", |
| 344 | [ |
| 345 | "configs", |
| 346 | "public_configs", |
| 347 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 348 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 349 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 350 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 351 | if (!defined(visibility)) { |
| 352 | visibility = webrtc_default_visibility |
| 353 | } |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 354 | |
| 355 | # What's your poison? |
| 356 | if (defined(testonly) && testonly) { |
| 357 | assert(!defined(poisonous)) |
| 358 | assert(!defined(allow_poison)) |
| 359 | } else { |
| 360 | if (!defined(poisonous)) { |
| 361 | poisonous = [] |
| 362 | } |
| 363 | if (!defined(allow_poison)) { |
| 364 | allow_poison = [] |
| 365 | } |
| 366 | if (!defined(assert_no_deps)) { |
| 367 | assert_no_deps = [] |
| 368 | } |
| 369 | if (!defined(deps)) { |
| 370 | deps = [] |
| 371 | } |
| 372 | foreach(p, poisonous) { |
| 373 | deps += [ webrtc_root + ":poison_" + p ] |
| 374 | } |
| 375 | foreach(poison_type, all_poison_types) { |
| 376 | allow_dep = true |
| 377 | foreach(v, visibility) { |
| 378 | if (v == "*") { |
| 379 | allow_dep = false |
| 380 | } |
| 381 | } |
| 382 | foreach(p, allow_poison + poisonous) { |
| 383 | if (p == poison_type) { |
| 384 | allow_dep = true |
| 385 | } |
| 386 | } |
| 387 | if (!allow_dep) { |
| 388 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 393 | configs += invoker.configs |
| 394 | configs -= rtc_remove_configs |
| 395 | configs -= invoker.suppressed_configs |
Mirko Bonadei | d161eda | 2018-04-19 00:07:31 +0000 | [diff] [blame] | 396 | public_configs = [ rtc_common_inherited_config ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 397 | if (defined(invoker.public_configs)) { |
| 398 | public_configs += invoker.public_configs |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | template("rtc_executable") { |
| 404 | executable(target_name) { |
| 405 | forward_variables_from(invoker, |
| 406 | "*", |
| 407 | [ |
| 408 | "deps", |
| 409 | "configs", |
| 410 | "public_configs", |
| 411 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 412 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 413 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 414 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 415 | if (!defined(visibility)) { |
| 416 | visibility = webrtc_default_visibility |
| 417 | } |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 418 | configs += invoker.configs |
| 419 | configs -= rtc_remove_configs |
| 420 | configs -= invoker.suppressed_configs |
| 421 | deps = [ |
thomasanderson | 7f52f08 | 2017-05-18 23:51:46 -0700 | [diff] [blame] | 422 | "//build/config:exe_and_shlib_deps", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 423 | ] |
| 424 | deps += invoker.deps |
perkj | 650fdae | 2017-08-25 05:00:11 -0700 | [diff] [blame] | 425 | |
Mirko Bonadei | d161eda | 2018-04-19 00:07:31 +0000 | [diff] [blame] | 426 | public_configs = [ rtc_common_inherited_config ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 427 | if (defined(invoker.public_configs)) { |
| 428 | public_configs += invoker.public_configs |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | template("rtc_static_library") { |
| 434 | static_library(target_name) { |
| 435 | forward_variables_from(invoker, |
| 436 | "*", |
| 437 | [ |
| 438 | "configs", |
| 439 | "public_configs", |
| 440 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 441 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 442 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 443 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 444 | if (!defined(visibility)) { |
| 445 | visibility = webrtc_default_visibility |
| 446 | } |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 447 | |
| 448 | # What's your poison? |
| 449 | if (defined(testonly) && testonly) { |
| 450 | assert(!defined(poisonous)) |
| 451 | assert(!defined(allow_poison)) |
| 452 | } else { |
| 453 | if (!defined(poisonous)) { |
| 454 | poisonous = [] |
| 455 | } |
| 456 | if (!defined(allow_poison)) { |
| 457 | allow_poison = [] |
| 458 | } |
| 459 | if (!defined(assert_no_deps)) { |
| 460 | assert_no_deps = [] |
| 461 | } |
| 462 | if (!defined(deps)) { |
| 463 | deps = [] |
| 464 | } |
| 465 | foreach(p, poisonous) { |
| 466 | deps += [ webrtc_root + ":poison_" + p ] |
| 467 | } |
| 468 | foreach(poison_type, all_poison_types) { |
| 469 | allow_dep = true |
| 470 | foreach(v, visibility) { |
| 471 | if (v == "*") { |
| 472 | allow_dep = false |
| 473 | } |
| 474 | } |
| 475 | foreach(p, allow_poison + poisonous) { |
| 476 | if (p == poison_type) { |
| 477 | allow_dep = true |
| 478 | } |
| 479 | } |
| 480 | if (!allow_dep) { |
| 481 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 486 | configs += invoker.configs |
| 487 | configs -= rtc_remove_configs |
| 488 | configs -= invoker.suppressed_configs |
Mirko Bonadei | d161eda | 2018-04-19 00:07:31 +0000 | [diff] [blame] | 489 | public_configs = [ rtc_common_inherited_config ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 490 | if (defined(invoker.public_configs)) { |
| 491 | public_configs += invoker.public_configs |
| 492 | } |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | template("rtc_shared_library") { |
| 497 | shared_library(target_name) { |
| 498 | forward_variables_from(invoker, |
| 499 | "*", |
| 500 | [ |
| 501 | "configs", |
| 502 | "public_configs", |
| 503 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 504 | "visibility", |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 505 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 506 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 507 | if (!defined(visibility)) { |
| 508 | visibility = webrtc_default_visibility |
| 509 | } |
Karl Wiberg | bb23c83 | 2018-04-22 19:55:00 +0200 | [diff] [blame] | 510 | |
| 511 | # What's your poison? |
| 512 | if (defined(testonly) && testonly) { |
| 513 | assert(!defined(poisonous)) |
| 514 | assert(!defined(allow_poison)) |
| 515 | } else { |
| 516 | if (!defined(poisonous)) { |
| 517 | poisonous = [] |
| 518 | } |
| 519 | if (!defined(allow_poison)) { |
| 520 | allow_poison = [] |
| 521 | } |
| 522 | if (!defined(assert_no_deps)) { |
| 523 | assert_no_deps = [] |
| 524 | } |
| 525 | if (!defined(deps)) { |
| 526 | deps = [] |
| 527 | } |
| 528 | foreach(p, poisonous) { |
| 529 | deps += [ webrtc_root + ":poison_" + p ] |
| 530 | } |
| 531 | foreach(poison_type, all_poison_types) { |
| 532 | allow_dep = true |
| 533 | foreach(v, visibility) { |
| 534 | if (v == "*") { |
| 535 | allow_dep = false |
| 536 | } |
| 537 | } |
| 538 | foreach(p, allow_poison + poisonous) { |
| 539 | if (p == poison_type) { |
| 540 | allow_dep = true |
| 541 | } |
| 542 | } |
| 543 | if (!allow_dep) { |
| 544 | assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 549 | configs += invoker.configs |
| 550 | configs -= rtc_remove_configs |
| 551 | configs -= invoker.suppressed_configs |
Mirko Bonadei | d161eda | 2018-04-19 00:07:31 +0000 | [diff] [blame] | 552 | public_configs = [ rtc_common_inherited_config ] |
mbonadei | 9aa3f0a | 2017-01-24 06:58:22 -0800 | [diff] [blame] | 553 | if (defined(invoker.public_configs)) { |
| 554 | public_configs += invoker.public_configs |
| 555 | } |
| 556 | } |
| 557 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 558 | |
| 559 | if (is_ios) { |
| 560 | set_defaults("rtc_ios_xctest_test") { |
| 561 | configs = rtc_add_configs |
| 562 | suppressed_configs = [] |
| 563 | } |
| 564 | |
| 565 | template("rtc_ios_xctest_test") { |
| 566 | ios_xctest_test(target_name) { |
| 567 | forward_variables_from(invoker, |
| 568 | "*", |
| 569 | [ |
| 570 | "configs", |
| 571 | "public_configs", |
| 572 | "suppressed_configs", |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 573 | "visibility", |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 574 | ]) |
Karl Wiberg | 138d4ac | 2017-10-16 11:16:19 +0200 | [diff] [blame] | 575 | forward_variables_from(invoker, [ "visibility" ]) |
Per Kjellander | a7f2d84 | 2018-01-10 15:54:53 +0000 | [diff] [blame] | 576 | if (!defined(visibility)) { |
| 577 | visibility = webrtc_default_visibility |
| 578 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 579 | configs += invoker.configs |
| 580 | configs -= rtc_remove_configs |
| 581 | configs -= invoker.suppressed_configs |
| 582 | public_configs = [ rtc_common_inherited_config ] |
| 583 | if (defined(invoker.public_configs)) { |
| 584 | public_configs += invoker.public_configs |
| 585 | } |
| 586 | } |
| 587 | } |
Anders Carlsson | dc6b477 | 2018-01-15 13:31:03 +0100 | [diff] [blame] | 588 | |
| 589 | template("ios_framework_bundle_with_umbrella_header") { |
| 590 | forward_variables_from(invoker, [ "output_name" ]) |
| 591 | umbrella_header_path = |
| 592 | "$target_gen_dir/$output_name.framework/Headers/$output_name.h" |
| 593 | |
| 594 | ios_framework_bundle(target_name) { |
| 595 | forward_variables_from(invoker, "*", []) |
| 596 | |
| 597 | deps += [ ":copy_umbrella_header_$target_name" ] |
| 598 | } |
| 599 | |
| 600 | action("umbrella_header_$target_name") { |
| 601 | forward_variables_from(invoker, [ "public_headers" ]) |
| 602 | |
| 603 | script = "//tools_webrtc/ios/generate_umbrella_header.py" |
| 604 | |
| 605 | outputs = [ |
| 606 | umbrella_header_path, |
| 607 | ] |
| 608 | args = [ |
| 609 | "--out", |
| 610 | rebase_path(umbrella_header_path, root_build_dir), |
| 611 | "--sources", |
| 612 | ] + rebase_path(public_headers, "objc/Framework/Headers/") |
| 613 | } |
| 614 | |
| 615 | copy("copy_umbrella_header_$target_name") { |
| 616 | sources = [ |
| 617 | umbrella_header_path, |
| 618 | ] |
| 619 | outputs = [ |
| 620 | "$root_out_dir/$output_name.framework/Headers/$output_name.h", |
| 621 | ] |
| 622 | |
| 623 | deps = [ |
| 624 | ":umbrella_header_$target_name", |
| 625 | ] |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | set_defaults("ios_framework_bundle_with_umbrella_header") { |
| 630 | configs = default_shared_library_configs |
| 631 | } |
kthelgason | 4065a57 | 2017-02-14 04:58:56 -0800 | [diff] [blame] | 632 | } |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 633 | |
| 634 | if (is_android) { |
| 635 | template("rtc_android_library") { |
| 636 | android_library(target_name) { |
| 637 | forward_variables_from(invoker, |
| 638 | "*", |
| 639 | [ |
| 640 | "configs", |
| 641 | "public_configs", |
| 642 | "suppressed_configs", |
| 643 | "visibility", |
| 644 | ]) |
| 645 | |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 646 | javac_args = [] |
| 647 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 648 | # Treat warnings as errors. |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 649 | javac_args += [ "-Werror" ] |
| 650 | |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 651 | # TODO(crbug.com/824679): Find out why this fails in Chromium |
| 652 | if (!build_with_chromium) { |
| 653 | javac_args += [ |
| 654 | "-Xep:ParameterNotNullable:ERROR", |
| 655 | "-Xep:FieldMissingNullable:ERROR", |
| 656 | "-Xep:ReturnMissingNullable:ERROR", |
| 657 | ] |
| 658 | } |
| 659 | |
Sami Kalliomäki | e7fac68 | 2018-03-20 16:32:49 +0100 | [diff] [blame] | 660 | # Add any arguments defined by the invoker. |
| 661 | if (defined(invoker.javac_args)) { |
| 662 | javac_args += invoker.javac_args |
| 663 | } |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 664 | |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 665 | if (!defined(deps)) { |
| 666 | deps = [] |
| 667 | } |
| 668 | deps += [ "//third_party/jsr-305:jsr_305_javalib" ] |
| 669 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 670 | no_build_hooks = true |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | template("rtc_android_apk") { |
| 675 | android_apk(target_name) { |
| 676 | forward_variables_from(invoker, |
| 677 | "*", |
| 678 | [ |
| 679 | "configs", |
| 680 | "public_configs", |
| 681 | "suppressed_configs", |
| 682 | "visibility", |
| 683 | ]) |
| 684 | |
| 685 | # Treat warnings as errors. |
| 686 | javac_args = [ "-Werror" ] |
| 687 | |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 688 | # TODO(crbug.com/824679): Find out why this fails in Chromium |
| 689 | if (!build_with_chromium) { |
| 690 | javac_args += [ |
| 691 | "-Xep:ParameterNotNullable:ERROR", |
| 692 | "-Xep:FieldMissingNullable:ERROR", |
| 693 | "-Xep:ReturnMissingNullable:ERROR", |
| 694 | ] |
| 695 | } |
| 696 | |
| 697 | if (!defined(deps)) { |
| 698 | deps = [] |
| 699 | } |
| 700 | deps += [ "//third_party/jsr-305:jsr_305_javalib" ] |
| 701 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 702 | no_build_hooks = true |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | template("rtc_instrumentation_test_apk") { |
| 707 | instrumentation_test_apk(target_name) { |
| 708 | forward_variables_from(invoker, |
| 709 | "*", |
| 710 | [ |
| 711 | "configs", |
| 712 | "public_configs", |
| 713 | "suppressed_configs", |
| 714 | "visibility", |
| 715 | ]) |
| 716 | |
| 717 | # Treat warnings as errors. |
| 718 | javac_args = [ "-Werror" ] |
| 719 | |
Sami Kalliomäki | dc52651 | 2018-03-27 17:07:27 +0200 | [diff] [blame] | 720 | # TODO(crbug.com/824679): Find out why this fails in Chromium |
| 721 | if (!build_with_chromium) { |
| 722 | javac_args += [ |
| 723 | "-Xep:ParameterNotNullable:ERROR", |
| 724 | "-Xep:FieldMissingNullable:ERROR", |
| 725 | "-Xep:ReturnMissingNullable:ERROR", |
| 726 | ] |
| 727 | } |
| 728 | |
| 729 | if (!defined(deps)) { |
| 730 | deps = [] |
| 731 | } |
| 732 | deps += [ "//third_party/jsr-305:jsr_305_javalib" ] |
| 733 | |
Mirko Bonadei | fbb3b7d | 2017-11-07 15:36:33 +0000 | [diff] [blame] | 734 | no_build_hooks = true |
| 735 | } |
| 736 | } |
| 737 | } |