Source release v2.1.1-0-738 + third_party libs
Change-Id: I76e298f8092951d4214c776d6bbcad6b763eb5b2
This commit is contained in:
119
build.py
Executable file
119
build.py
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/python2
|
||||
# Copyright 2013 Google Inc. All Rights Reserved.
|
||||
"""Generates build files and builds the CDM source release."""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import gyp
|
||||
|
||||
cdm_top = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('platform',
|
||||
help='The platform configuration to use (x86-64, ...). '
|
||||
'Should be one of the folder names inside platforms/')
|
||||
parser.add_argument('-r', '--release',
|
||||
dest='build_config', default='Debug',
|
||||
action='store_const', const='Release',
|
||||
help='Builds a release build (equivalent to -c Release)')
|
||||
parser.add_argument('-c', '--config',
|
||||
dest='build_config', default='Debug',
|
||||
help='Select a build config (Debug, Release)')
|
||||
parser.add_argument('-g', '--generator', default='make',
|
||||
help='Which build system to use (make, ninja, ...)')
|
||||
|
||||
|
||||
def VerboseSubprocess(args):
|
||||
print ' Running: %s' % args
|
||||
return subprocess.call(args)
|
||||
|
||||
|
||||
def RunMake(unused_output_path, build_config):
|
||||
os.environ['BUILDTYPE'] = build_config
|
||||
return VerboseSubprocess(['make', '-C', cdm_top])
|
||||
|
||||
|
||||
def RunNinja(output_path, build_config):
|
||||
build_path = os.path.join(output_path, build_config)
|
||||
return VerboseSubprocess(['ninja', '-C', build_path])
|
||||
|
||||
|
||||
def RunUnknown(unused_output_path, unused_build_config):
|
||||
print 'Cannot automatically build with this generator.'
|
||||
print 'Please start the build manually.'
|
||||
return 0
|
||||
|
||||
|
||||
def GetBuilder(generator):
|
||||
return {
|
||||
'make': RunMake,
|
||||
'ninja': RunNinja,
|
||||
}.get(generator, RunUnknown)
|
||||
|
||||
|
||||
def ImportPlatform(name, gyp_args):
|
||||
"""Handles platform-specific setup for the named platform.
|
||||
|
||||
Computes platform-specific paths, sets gyp arguments for platform-specific
|
||||
gypis and output paths, imports a platform-specific module, and exports
|
||||
platform-specific environment variables.
|
||||
|
||||
Args:
|
||||
name: The name of the platform.
|
||||
gyp_args: An array of gyp arguments to which this function will append.
|
||||
|
||||
Returns:
|
||||
The path to the root of the build output.
|
||||
"""
|
||||
|
||||
print ' Target Platform: %s' % name
|
||||
|
||||
platforms_path = os.path.join(cdm_top, 'platforms')
|
||||
target_path = os.path.join(platforms_path, name)
|
||||
platform_gypi_path = os.path.join(target_path, name + '.gypi')
|
||||
global_gypi_path = os.path.join(platforms_path, 'global_config.gypi')
|
||||
output_path = os.path.join(cdm_top, 'out', name)
|
||||
|
||||
gyp_args.append('--include=%s' % platform_gypi_path)
|
||||
gyp_args.append('--include=%s' % global_gypi_path)
|
||||
gyp_args.append('-Goutput_dir=%s' % output_path)
|
||||
|
||||
sys.path.insert(0, target_path)
|
||||
target = __import__(name)
|
||||
|
||||
if hasattr(target, 'export_variables'):
|
||||
for k, v in target.export_variables.iteritems():
|
||||
os.environ[k] = v
|
||||
print ' set %s to %s' % (k, v)
|
||||
|
||||
return output_path
|
||||
|
||||
|
||||
def main(args):
|
||||
options = parser.parse_args(args)
|
||||
|
||||
gyp_args = [
|
||||
'--format=%s' % options.generator,
|
||||
'--depth=%s' % cdm_top,
|
||||
'%s/cdm/cdm_api_external.gyp' % cdm_top,
|
||||
]
|
||||
|
||||
output_path = ImportPlatform(options.platform, gyp_args)
|
||||
|
||||
print ' Running: %s' % (['gyp'] + gyp_args)
|
||||
retval = gyp.main(gyp_args)
|
||||
if retval != 0:
|
||||
return retval
|
||||
|
||||
# The gyp argument --build=xyz only works on newer versions of gyp and
|
||||
# ignores the generator flag output_dir (as of 2014-05-28 with ninja).
|
||||
# So instead of using --build, we simply invoke the build system ourselves.
|
||||
builder = GetBuilder(options.generator)
|
||||
return builder(output_path, options.build_config)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1:])
|
||||
Reference in New Issue
Block a user