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