summaryrefslogtreecommitdiff
path: root/BUILD.gn
blob: 157be6f9af92c00cd119d445282fda7071432a36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS.  All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.

# TODO(kjellander): Rebase this to webrtc/build/common.gypi changes after r6330.

import("//build/config/arm.gni")
import("//build/config/crypto.gni")
import("//build/config/linux/pkg_config.gni")
import("build/webrtc.gni")

# Contains the defines and includes in common.gypi that are duplicated both as
# target_defaults and direct_dependent_settings.
config("common_inherited_config") {
  defines = []
  if (build_with_mozilla) {
    defines += [ "WEBRTC_MOZILLA_BUILD" ]
  }
  if (build_with_chromium) {
    defines = [
      "WEBRTC_CHROMIUM_BUILD",
    ]
    include_dirs = [
      # overrides must be included first as that is the mechanism for
      # selecting the override headers in Chromium.
      "overrides",
      # Allow includes to be prefixed with webrtc/ in case it is not an
      # immediate subdirectory of the top-level.
      "..",
    ]
  }
  if (is_posix) {
    defines += [ "WEBRTC_POSIX" ]
  }
  if (is_ios) {
    defines += [
      "WEBRTC_MAC",
      "WEBRTC_IOS",
    ]
  }
  if (is_linux) {
    defines += [ "WEBRTC_LINUX" ]
  }
  if (is_mac) {
    defines += [ "WEBRTC_MAC" ]
  }
  if (is_win) {
    defines += [ "WEBRTC_WIN" ]
  }
  if (is_android) {
    defines += [
      "WEBRTC_LINUX",
      "WEBRTC_ANDROID",
    ]
    if (rtc_enable_android_opensl) {
      defines += [ "WEBRTC_ANDROID_OPENSLES" ]
    }
  }
}

if (rtc_have_dbus_glib) {
  pkg_config("dbus-glib") {
    packages = [ "dbus-glib-1" ]
  }
}

config("common_config") {
  cflags = []
  cflags_cc = []
  if (rtc_restrict_logging) {
    defines = [ "WEBRTC_RESTRICT_LOGGING" ]
  }

  if (rtc_have_dbus_glib) {
    defines += [ "HAVE_DBUS_GLIB" ]
    # TODO(kjellander): Investigate this, it seems like include <dbus/dbus.h>
    # is still not found even if the execution of
    # build/config/linux/pkg-config.py dbus-glib-1 returns correct include
    # dirs on Linux.
    all_dependent_configs = [ "dbus-glib" ]
  }

  if (rtc_enable_video) {
    defines += [ "WEBRTC_MODULE_UTILITY_VIDEO" ]
  }

  if (build_with_chromium) {
    defines += [ "LOGGING_INSIDE_WEBRTC" ]
  } else {
    if (is_posix) {
      # -Wextra is currently disabled in Chromium"s common.gypi. Enable
      # for targets that can handle it. For Android/arm64 right now
      # there will be an "enumeral and non-enumeral type in conditional
      # expression" warning in android_tools/ndk_experimental"s version
      # of stlport.
      # See: https://code.google.com/p/chromium/issues/detail?id=379699
      if (cpu_arch != "arm64" || !is_android) {
        cflags = [
          "-Wextra",
          # We need to repeat some flags from Chromium"s common.gypi
          # here that get overridden by -Wextra.
          "-Wno-unused-parameter",
          "-Wno-missing-field-initializers",
          "-Wno-strict-overflow",
        ]
        cflags_cc = [
          "-Wnon-virtual-dtor",
          # This is enabled for clang; enable for gcc as well.
          "-Woverloaded-virtual",
        ]
      }
    }

    if (is_clang) {
      cflags += [ "-Wthread-safety" ]
    }
  }

  if (cpu_arch == "arm64") {
    defines += [ "WEBRTC_ARCH_ARM" ]
  }

  if (cpu_arch == "arm") {
    defines += [ "WEBRTC_ARCH_ARM" ]
    if (arm_version == 7) {
      defines += [ "WEBRTC_ARCH_ARM_V7" ]
      if (arm_use_neon) {
        defines += [ "WEBRTC_ARCH_ARM_NEON" ]
      } else {
        defines += [ "WEBRTC_DETECT_ARM_NEON" ]
      }
    }
  }

  if (cpu_arch == "mipsel") {
    defines += [ "MIPS32_LE" ]
    if (mips_fpu) {
      defines += [ "MIPS_FPU_LE" ]
      cflags += [ "-mhard-float" ]
    } else {
      cflags += [ "-msoft-float" ]
    }
    if (mips_arch_variant == "mips32r2") {
      defines += [ "MIPS32_R2_LE" ]
      cflags += [ "-mips32r2" ]
      cflags_cc += [ "-mips32r2" ]
    }
    if (mips_dsp_rev == 1) {
      defines += [ "MIPS_DSP_R1_LE" ]
      cflags += [ "-mdsp" ]
      cflags_cc += [ "-mdsp" ]
    } else if (mips_dsp_rev == 2) {
      defines += [
        "MIPS_DSP_R1_LE",
        "MIPS_DSP_R2_LE",
      ]
      cflags += [ "-mdspr2" ]
      cflags_cc += [ "-mdspr2" ]
    }
  }

  # TODO(kjellander): Handle warnings on Windows where WebRTC differ from the
  # default warnings set in build/config/compiler/BUILD.gn.

  if (is_android && is_clang) {
    # The Android NDK doesn"t provide optimized versions of these
    # functions. Ensure they are disabled for all compilers.
    cflags += [
      "-fno-builtin-cos",
      "-fno-builtin-sin",
      "-fno-builtin-cosf",
      "-fno-builtin-sinf",
    ]
  }
}

static_library("webrtc") {
  sources = [
    "call.h",
    "config.h",
    "experiments.h",
    "frame_callback.h",
    "transport.h",
  ]

  configs += [ ":common_config" ]
  public_configs = [ ":common_inherited_config"]

  deps = [
    ":webrtc_common",
    "base:webrtc_base",
    "common_audio",
    "common_video",
    "modules/audio_coding",
    "modules/audio_conference_mixer",
    "modules/audio_device",
    "modules/audio_processing",
    "modules/bitrate_controller",
    "modules/desktop_capture",
    "modules/media_file",
    "modules/rtp_rtcp",
    "modules/utility",
    "modules/video_capture",
    "modules/video_coding",
    "modules/video_processing",
    "modules/video_render",
    "system_wrappers",
    "tools",
    "video",
    "video_engine",
    "voice_engine",
  ]
}

if (!build_with_chromium) {
  executable("webrtc_tests") {
    testonly = true
    deps = [
      ":webrtc",
      "modules/video_render:video_render_internal_impl",
      "modules/video_capture:video_capture_internal_impl",
      "test",
    ]
  }
}

source_set("webrtc_common") {
  sources = [
    "config.h",
    "config.cc",
  ]

  if (is_clang) {
    # Suppress warnings from Chrome's Clang plugins.
    # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
    configs -= [ "//build/config/clang:find_bad_constructs" ]
  }

  configs += [ ":common_config" ]
  public_configs = [ ":common_inherited_config" ]
}