Initial GN work for WebRTC
This CL makes it possible to build the 'webrtc_base'
target using GN.
The majority of our GYP stuff in webrtc/build/common.gypi has been
translated into the configs of webrtc/BUILD.gn.
The webrtc/base/base.gyp file is translated into webrtc/base/BUILD.gn.
This CL depends on https://codereview.chromium.org/322373002/ for the
jsoncpp BUILD.gn file and the ssl config.
To build inside Chromium, https://codereview.chromium.org/321313006/
needs to be landed first.
BUG=webrtc:3441
TEST=
Successful compilation of WebRTC as standalone:
gn gen out/Default --args="build_with_chromium=false" && ninja -C out/Default
gn gen out/Default --args="build_with_chromium=false is_clang=true" && ninja -C out/Default
I also ran:
gn gen out/Default --args="build_with_chromium=false have_dbus_glib=true"
but it fails to compile: something is probably wrong with with pkg-config for that.
For Chromium, I symlinked src/third_party/webrtc to the webrtc subfolder of the
WebRTC checkout and applied the following patches:
https://codereview.chromium.org/322373002 (for jsoncpp and ssl config)
https://codereview.chromium.org/321313006 (enable building WebRTC)
Then I built successfully using:
gn gen out/Default && ninja -C out/Default webrtc_base
R=brettw@chromium.org
TBR=niklas.enbom@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/17669004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6461 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn
new file mode 100644
index 0000000..a86c8a7
--- /dev/null
+++ b/webrtc/BUILD.gn
@@ -0,0 +1,174 @@
+# 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.
+
+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",
+ "LOGGING_INSIDE_WEBRTC",
+ ]
+ 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 (enable_android_opensl) {
+ defines += [ "WEBRTC_ANDROID_OPENSLES" ]
+ }
+ }
+}
+
+pkg_config("dbus-glib") {
+ packages = [ "dbus-glib-1" ]
+}
+
+config("common_config") {
+ if (restrict_webrtc_logging) {
+ defines = [ "WEBRTC_RESTRICT_LOGGING" ]
+ }
+
+ if (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 (enable_video) {
+ defines += [ "WEBRTC_MODULE_UTILITY_VIDEO" ]
+ }
+
+ if (!build_with_chromium) {
+ 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 == "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") {
+ deps = [
+ "base:webrtc_base",
+ ]
+}