Bug 1336429 - Add webrtc gn build config. draft
authorChris Manchester <cmanchester@mozilla.com>
Tue, 21 Nov 2017 12:32:59 -0800
changeset 701559 174b9e46cce67948aa447ebab55dc6f8f7c6071c
parent 701558 0b099b37a56920592b20d5d22bd6179ccb04770f
child 741196 efa4047a0ab9e65cedf78c0957b31b20c7febe03
push id90194
push userbmo:cmanchester@mozilla.com
push dateTue, 21 Nov 2017 20:33:08 +0000
bugs1336429
milestone59.0a1
Bug 1336429 - Add webrtc gn build config. MozReview-Commit-ID: FIPjkDWwAQx
build/gn.mozbuild
media/webrtc/moz.build
media/webrtc/trunk/gtest/moz.build
media/webrtc/trunk/moz.build
media/webrtc/trunk/webrtc/BUILD.gn
new file mode 100644
--- /dev/null
+++ b/build/gn.mozbuild
@@ -0,0 +1,37 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+gn_vars = {}
+
+if CONFIG['MOZ_DEBUG']:
+   gn_vars['is_debug'] = True
+else:
+   gn_vars['is_debug'] = False
+
+os = CONFIG['OS_TARGET']
+
+flavors = {
+    'WINNT': 'win',
+    'Android': 'android',
+    'Linux': 'linux',
+    'Darwin': 'mac' if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa' else 'ios',
+    'SunOS': 'solaris',
+    'GNU/kFreeBSD': 'freebsd',
+    'DragonFly': 'dragonfly',
+    'FreeBSD': 'freebsd',
+    'NetBSD': 'netbsd',
+    'OpenBSD': 'openbsd',
+}
+gn_vars['target_os'] = flavors.get(os)
+
+arches = {
+    'x86_64': 'x64',
+    'x86': 'ia32',
+    'aarch64': 'arm64',
+}
+
+gn_vars['host_cpu'] = arches.get(CONFIG['HOST_CPU_ARCH'], CONFIG['HOST_CPU_ARCH'])
+gn_vars['target_cpu'] = arches.get(CONFIG['CPU_ARCH'], CONFIG['CPU_ARCH'])
--- a/media/webrtc/moz.build
+++ b/media/webrtc/moz.build
@@ -6,16 +6,17 @@
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "WebRTC")
 
 with Files("signaling/**"):
     BUG_COMPONENT = ("Core", "WebRTC: Signaling")
 
 include('/build/gyp.mozbuild')
+include('/build/gn.mozbuild')
 
 webrtc_non_unified_sources = [
     'trunk/webrtc/common_audio/vad/vad_core.c',                                  # Because of name clash in the kInitCheck variable
     'trunk/webrtc/common_audio/vad/webrtc_vad.c',                                # Because of name clash in the kInitCheck variable
     'trunk/webrtc/modules/audio_coding/acm2/codec_manager.cc',                   # Because of duplicate IsCodecRED/etc
     'trunk/webrtc/modules/audio_coding/codecs/g722/g722_decode.c',               # Because of name clash in the saturate function
     'trunk/webrtc/modules/audio_coding/codecs/g722/g722_encode.c',               # Because of name clash in the saturate function
     'trunk/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c',   # Because of name clash in the kDampFilter variable
@@ -51,34 +52,39 @@ webrtc_non_unified_sources = [
     'trunk/webrtc/modules/rtp_rtcp/source/ulpfec_generator.cc',                  # Because of identically named constant kRedForFecHeaderLength in an anonymous namespace
     'trunk/webrtc/modules/video_capture/windows/BaseFilter.cpp',                 # Because it locally defines NS_IF_ADDREF/RELEASE
     'trunk/webrtc/modules/video_capture/windows/device_info_ds.cc',              # Because of the MEDIASUBTYPE_HDYC variable
     'trunk/webrtc/modules/video_capture/windows/help_functions_ds.cc',           # Because of initguid.h
     'trunk/webrtc/modules/video_capture/windows/sink_filter_ds.cc',              # Because of the MEDIASUBTYPE_HDYC variable and initguid.h
     'trunk/webrtc/video/overuse_frame_detector.cc',                              # Because of name clash with call_stats.cc on kWeightFactor
 ]
 
-GYP_DIRS += ['trunk']
-
 # Set gyp vars that webrtc needs when building under various analysis tools.
 # Primarily this prevents webrtc from setting NVALGRIND and breaking builds.
 gyp_vars_copy = gyp_vars.copy()
 if CONFIG['MOZ_VALGRIND']:
     gyp_vars_copy.update(build_for_tool="memcheck")
 elif CONFIG['MOZ_ASAN']:
     gyp_vars_copy.update(build_for_tool="asan")
 elif CONFIG['MOZ_TSAN']:
     gyp_vars_copy.update(build_for_tool="tsan")
 
-GYP_DIRS['trunk'].input = 'trunk/peerconnection.gyp'
-GYP_DIRS['trunk'].variables = gyp_vars_copy
+GN_DIRS += ['trunk']
+
+gn_vars_copy = gn_vars.copy()
+
+GN_DIRS['trunk'].variables = gn_vars_copy
+GN_DIRS['trunk'].mozilla_flags = [
+    "-fobjc-arc"
+]
+
 # We allow warnings for third-party code that can be updated from upstream.
-GYP_DIRS['trunk'].sandbox_vars['COMPILE_FLAGS'] = {'WARNINGS_AS_ERRORS': []}
-GYP_DIRS['trunk'].sandbox_vars['FINAL_LIBRARY'] = 'webrtc'
-GYP_DIRS['trunk'].non_unified_sources += webrtc_non_unified_sources
+GN_DIRS['trunk'].sandbox_vars['COMPILE_FLAGS'] = {'WARNINGS_AS_ERRORS': []}
+GN_DIRS['trunk'].sandbox_vars['FINAL_LIBRARY'] = 'webrtc'
+GN_DIRS['trunk'].non_unified_sources += webrtc_non_unified_sources
 
 if CONFIG['MOZ_WEBRTC_SIGNALING']:
     DIRS += [
         'signaling/src/common',
         'signaling/src/jsep',
         'signaling/src/media-conduit',
         'signaling/src/mediapipeline',
         'signaling/src/peerconnection',
--- a/media/webrtc/trunk/gtest/moz.build
+++ b/media/webrtc/trunk/gtest/moz.build
@@ -30,22 +30,22 @@ LOCAL_INCLUDES += [
 ]
 
 USE_LIBS += [
     '/media/webrtc/trunk/third_party/gflags/gflags_gflags/gflags',
     '/testing/gtest/gtest',
     'media_libopus',
     'speex',
     'webrtc',
-    'webrtc_common',
-    'webrtc_i420',
-    'webrtc_lib',
-    'webrtc_utility',
-    'webrtc_vp8',
-    'webrtc_vp9',
+    'webrtc_common_gn',
+    'webrtc_gn',
+    'webrtc_i420_gn',
+    # 'webrtc_utility',
+    'webrtc_vp8_gn',
+    'webrtc_vp9_gn',
     'yuv',
 ]
 
 if CONFIG['MOZ_SYSTEM_JPEG']:
     OS_LIBS += CONFIG['MOZ_JPEG_LIBS']
 else:
     USE_LIBS += ['media_libjpeg']
 
new file mode 100644
--- a/media/webrtc/trunk/webrtc/BUILD.gn
+++ b/media/webrtc/trunk/webrtc/BUILD.gn
@@ -239,17 +239,17 @@ if (!build_with_chromium) {
       "call.h",
       "config.h",
     ]
 
     defines = []
 
     deps = [
       ":webrtc_common",
-      "api",
+#      "api",
       "api:transport_api",
       "audio",
       "base",
       "call",
       "common_audio",
       "common_video",
       "logging",
       "media",