Proof-of-concept proposal for a standalone webrtc build without using gyp_chromium etc. This adds the necessary scripts and gyp files. The idea is to assume that we are building within Chromium; in that case common.gypi (which every gyp file includes) provides the necessary logic to build webrtc.

In a standalone build, gyp_webrtc would be called, which includes common_standalone.gypi. This file specifies everything that running gyp_chromium would normally provide (cflags etc). Here we can customize things for our build that Chromium might not have, and also do away with a lot of the complexity which we don't need.

Most of the remaining work would be in common_standalone.gypi to provide full build settings. Much of this could come from Chromium's common.gypi.

Some of the inspiration for this is from NaCl.

(This doesn't impact the current build, just provides the option to run gyp_webrtc instead of gyp_chromium).
Review URL: http://webrtc-codereview.appspot.com/22021

git-svn-id: http://webrtc.googlecode.com/svn/trunk@60 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
ajm@google.com 2011-06-08 23:09:32 +00:00
parent fea5f7e30e
commit d5d596eab9
5 changed files with 316 additions and 59 deletions

74
build/common.gypi Normal file
View File

@ -0,0 +1,74 @@
# Copyright (c) 2011 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.
# This file contains common settings for building WebRTC components.
{
'variables': {
# TODO(ajm): use webrtc_standalone to match NaCl?
'build_with_chromium%': 1, # 1 to build webrtc with chromium
# Selects fixed-point code where possible.
# TODO(ajm): we'd like to set this based on the target OS/architecture.
'prefer_fixed_point%': 0,
'conditions': [
['OS=="win"', {
# TODO(ajm, perkj): does this need to be here?
# Path needed to build Direct Show base classes on Windows.
# The code is included in the Windows SDK.
'direct_show_base_classes':
'C:/Program Files/Microsoft SDKs/Windows/v7.1/Samples/multimedia/directshow/baseclasses/',
}],
], # conditions
},
'target_defaults': {
'include_dirs': [
'..', # common_types.h, typedefs.h
],
'conditions': [
['OS=="linux"', {
'defines': [
'WEBRTC_TARGET_PC',
'WEBRTC_LINUX',
'WEBRTC_THREAD_RR',
# TODO(ajm): can we select this automatically?
# Define this if the Linux system does not support CLOCK_MONOTONIC.
#'WEBRTC_CLOCK_TYPE_REALTIME',
],
}],
['OS=="mac"', {
# TODO(ajm): what about PowerPC?
# Setup for Intel
'defines': [
'WEBRTC_TARGET_MAC_INTEL',
'WEBRTC_MAC_INTEL',
'WEBRTC_MAC',
'WEBRTC_THREAD_RR',
'WEBRTC_CLOCK_TYPE_REALTIME',
],
}],
['OS=="win"', {
'defines': [
'WEBRTC_TARGET_PC',
],
}],
['build_with_chromium==1', {
'defines': [
'WEBRTC_VIDEO_EXTERNAL_CAPTURE_AND_RENDER',
],
}],
], # conditions
}, # target_defaults
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:

View File

@ -0,0 +1,97 @@
# Copyright (c) 2011 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.
# This is included when gyp_webrtc is run, and provides the settings
# necessary for a standalone WebRTC build.
{
'variables': {
# .gyp files or targets should set webrtc_code to 1 if they build
# WebRTC-specific code, as opposed to external code. This variable is
# used to control such things as the set of warnings to enable, and
# whether warnings are treated as errors.
'webrtc_code%': 0,
'variables': {
# Compute the architecture that we're building on.
'conditions': [
['OS=="win" or OS=="mac"', {
'host_arch%': 'ia32',
}, {
# This handles the Unix platforms for which there is some support.
# Anything else gets passed through, which probably won't work very
# well; such hosts should pass an explicit target_arch to gyp.
'host_arch%':
'<!(uname -m | sed -e "s/i.86/ia32/;s/x86_64/x64/;s/amd64/x64/;s/arm.*/arm/;s/i86pc/ia32/")',
}],
# A flag for POSIX platforms
['OS=="win"', {
'os_posix%': 0,
}, {
'os_posix%': 1,
}],
], # conditions
# Workaround for libjpeg_turbo pulled from Chromium.
'chromeos%': 0,
},
# Copy conditionally-set variables out one scope.
'host_arch%': '<(host_arch)',
'chromeos%': '<(chromeos)',
'os_posix%': '<(os_posix)',
# Workaround for GTest pulled from Chromium.
# TODO(ajm): would be nice to support Clang though...
#
# Set this to true when building with Clang.
# See http://code.google.com/p/chromium/wiki/Clang for details.
# TODO: eventually clang should behave identically to gcc, and this
# won't be necessary.
'clang%': 0,
# Default architecture we're building for is the architecture we're
# building on.
'target_arch%': '<(host_arch)',
'library%': 'static_library',
},
'target_defaults': {
'include_dirs': [
'..', # common_types.h, typedefs.h
],
'conditions': [
['OS=="linux"', {
'cflags': [
'-Wall',
'-Wextra',
# TODO(ajm): enable when possible.
#'-Werror',
],
}],
], # conditions
}, # target_defaults
'conditions': [
['webrtc_code==0', {
# This section must follow the other conditon sections above because
# external_code.gypi expects to be merged into those settings.
'includes': [
'external_code.gypi',
],
}],
], # conditions
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:

50
build/external_code.gypi Normal file
View File

@ -0,0 +1,50 @@
# Copyright (c) 2011 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.
# This is included for external code which may require different warning
# settings than the internal WebRTC code.
# TODO(ajm): remove these when possible.
{
'conditions': [
['OS=="linux"', {
'target_defaults': {
'cflags!': [
'-Wall',
'-Wextra',
'-Werror',
],
},
}],
['OS=="win"', {
'target_defaults': {
'defines': [
'_CRT_SECURE_NO_DEPRECATE',
'_CRT_NONSTDC_NO_WARNINGS',
'_CRT_NONSTDC_NO_DEPRECATE',
'_SCL_SECURE_NO_DEPRECATE',
],
'msvs_disabled_warnings': [4800],
'msvs_settings': {
'VCCLCompilerTool': {
'WarnAsError': 'false',
'Detect64BitPortabilityProblems': 'false',
},
},
},
}],
['OS=="mac"', {
'target_defaults': {
'xcode_settings': {
'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',
'WARNING_CFLAGS!': ['-Wall'],
},
},
}],
],
}

91
build/gyp_webrtc Executable file
View File

@ -0,0 +1,91 @@
#!/usr/bin/env python
# Copyright (c) 2011 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.
# This is a gyp wrapper for WebRTC that adds some support for how gyp
# is invoked beyond what can be done in the gclient hooks.
import glob
import os
import shlex
import sys
script_dir = os.path.dirname(__file__)
webrtc_src = os.path.abspath(os.path.join(script_dir, os.pardir))
sys.path.append(os.path.join(webrtc_src, '../', 'tools', 'gyp', 'pylib'))
import gyp
def additional_include_files(args=[]):
"""
Returns a list of additional (.gypi) files to include, without
duplicating ones that are already specified on the command line.
"""
# Determine the include files specified on the command line.
# This doesn't cover all the different option formats you can use,
# but it's mainly intended to avoid duplicating flags on the automatic
# makefile regeneration which only uses this format.
specified_includes = set()
for arg in args:
if arg.startswith('-I') and len(arg) > 2:
specified_includes.add(os.path.realpath(arg[2:]))
result = []
def AddInclude(path):
if os.path.realpath(path) not in specified_includes:
result.append(path)
# Always include common.gypi & features_override.gypi
AddInclude(os.path.join(script_dir, 'common_standalone.gypi'))
#AddInclude(os.path.join(script_dir, 'features_override.gypi'))
# Optionally add supplemental .gypi files if present.
supplements = glob.glob(os.path.join(webrtc_src, '*', 'supplement.gypi'))
for supplement in supplements:
AddInclude(supplement)
return result
if __name__ == '__main__':
args = sys.argv[1:]
# This could give false positives since it doesn't actually do real option
# parsing. Oh well.
gyp_file_specified = False
for arg in args:
if arg.endswith('.gyp'):
gyp_file_specified = True
break
# If we didn't get a file, check an env var, and then fall back to
# assuming 'all.gyp' from the same directory as the script.
if not gyp_file_specified:
gyp_file = os.environ.get('WEBRTC_GYP_FILE')
if gyp_file:
# Note that CHROMIUM_GYP_FILE values can't have backslashes as
# path separators even on Windows due to the use of shlex.split().
args.extend(shlex.split(gyp_file))
else:
# TODO(ajm): move webrtc.gyp to script_dir?
args.append(os.path.join(webrtc_src, 'webrtc.gyp'))
args.extend(['-I' + i for i in additional_include_files(args)])
# Pick depth explicitly.
args += ['--depth', '.']
#Building WebRTC as standalone (not as part of Chrome)
#args += ['-D', 'webrtc_standalone=1']
args += ['-D', 'build_with_chromium=0']
print 'Updating projects from gyp files...'
sys.stdout.flush()
# Off we go...
sys.exit(gyp.main(args))

View File

@ -6,67 +6,12 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# This file contains common settings for building WebRTC components.
# Placeholder until all gyp files point to build/common.gypi instead.
{
'variables': {
'build_with_chromium%': 0, # 1 to build webrtc with chromium
'inside_chromium_build%': 0,
# Selects fixed-point code where possible.
# TODO(ajm): we'd like to set this based on the target OS/architecture.
'prefer_fixed_point%': 0,
'conditions': [
['inside_chromium_build==1', {
'build_with_chromium': 1,
}],
['OS=="win"', {
# Path needed to build Direct Show base classes on Windows. The code is included in Windows SDK.
'direct_show_base_classes':'C:/Program Files/Microsoft SDKs/Windows/v7.1/Samples/multimedia/directshow/baseclasses/',
}],
], # conditions
},
'target_defaults': {
'include_dirs': [
'.', # For common_typs.h and typedefs.h
],
'conditions': [
['OS=="linux"', {
'defines': [
'WEBRTC_TARGET_PC',
'WEBRTC_LINUX',
'WEBRTC_THREAD_RR',
# INTEL_OPT is for iLBC floating point code optimized for Intel processors
# supporting SSE3. The compiler will be automatically switched to Intel
# compiler icc in the iLBC folder for iLBC floating point library build.
#'INTEL_OPT',
# Define WEBRTC_CLOCK_TYPE_REALTIME if the Linux system does not support CLOCK_MONOTONIC
#'WEBRTC_CLOCK_TYPE_REALTIME',
],
}],
['OS=="mac"', {
# Setup for Intel
'defines': [
'WEBRTC_TARGET_MAC_INTEL',
'WEBRTC_MAC_INTEL',
'WEBRTC_MAC',
'WEBRTC_THREAD_RR',
'WEBRTC_CLOCK_TYPE_REALTIME',
],
}],
['OS=="win"', {
'defines': [
'WEBRTC_TARGET_PC',
],
}],
['build_with_chromium==1', {
'defines': [
'WEBRTC_VIDEO_EXTERNAL_CAPTURE_AND_RENDER',
],
}],
], # conditions
}, # target-defaults
'includes': [
'build/common.gypi',
],
}
# Local Variables: