Bug 1393119 - Add webrtc gn build config. draft
authorChris Manchester <cmanchester@mozilla.com>
Wed, 29 Nov 2017 11:18:44 -0800
changeset 713619 b1e2333d259caa412c67f41a9ae9ceef9ecd05c9
parent 713607 cd50ddedbd7c4b4d976b4c290dcc1b1e20cdf66c
child 744387 4d263ce54c0c16b3bc5a92fc4e629a5ffcb200ab
push id93702
push userbmo:cmanchester@mozilla.com
push dateWed, 20 Dec 2017 19:44:05 +0000
bugs1393119
milestone59.0a1
Bug 1393119 - 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
new file mode 100644
--- /dev/null
+++ b/build/gn.mozbuild
@@ -0,0 +1,36 @@
+# -*- 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',
+    '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,40 @@ 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",
+    "-mfpu=neon",
+]
+
 # 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,21 @@ 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_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