118 lines
3.3 KiB
Python
Executable File
118 lines
3.3 KiB
Python
Executable File
#!/usr/bin/python2
|
|
# Copyright 2013 Google Inc. All rights reserved.
|
|
|
|
import gyp
|
|
import os
|
|
from os import path
|
|
import string
|
|
import subprocess
|
|
import sys
|
|
import argparse
|
|
|
|
toolchain = {}
|
|
starting_dir = os.getcwd()
|
|
|
|
toolset_variables = ['CC', 'CXX', 'AR']
|
|
env_variables = ['CFLAGS', 'CXXFLAGS', 'LDFLAGS']
|
|
|
|
gyp_args = string.split('--format=make --depth=.')
|
|
|
|
parser = argparse.ArgumentParser(description='Process build options.')
|
|
parser_arguments = []
|
|
build_config = '--build=Debug'
|
|
global_include_file = '--include=build/global_config.gypi'
|
|
|
|
print ' Gyp Args: %s' % (gyp_args)
|
|
|
|
def ImportPlatform(name):
|
|
os.chdir('build/platforms')
|
|
sys.path.insert(0, os.getcwd())
|
|
platforms_list = __import__('cdm_platforms')
|
|
platforms = platforms_list.platforms
|
|
target_platform = platforms[name]
|
|
print ' Target Platform: %s' % (target_platform)
|
|
target_folder = target_platform['folder']
|
|
print ' Target Folder: %s' % (target_folder)
|
|
target_file = target_platform['file']
|
|
print ' Target File: %s' % (target_file)
|
|
global target_env
|
|
target_env = target_file
|
|
|
|
os.chdir(target_folder)
|
|
sys.path.insert(0, os.getcwd())
|
|
target = __import__(target_file)
|
|
tooldir = ''
|
|
if 'tooldir' in target.toolchain:
|
|
tooldir = target.toolchain['tooldir']
|
|
print ' tooldir: %s' % (tooldir)
|
|
for i, v in enumerate(toolset_variables):
|
|
if v in target.toolchain:
|
|
os.environ[v] = path.join(tooldir, target.toolchain[v])
|
|
print ' tool: %s' % (os.environ[v])
|
|
if 'tooldir' in target.toolchain:
|
|
tooldir = target.toolchain['tooldir']
|
|
|
|
for i, v in enumerate(env_variables):
|
|
if v in target.toolchain:
|
|
os.environ[v] = target.toolchain[v]
|
|
if hasattr(target, 'gyp_variables'):
|
|
global gyp_args
|
|
gyp_args += target.gyp_variables
|
|
|
|
if hasattr(target, 'export_variables'):
|
|
print '---------------has export variables'
|
|
|
|
for v in target.export_variables:
|
|
first = v.split(':')
|
|
x = first[0]
|
|
y = target.export_variables[x]
|
|
if x=="ADD_PATH":
|
|
os.environ["PATH"] = os.environ["PATH"] + y
|
|
print ' just updated to PATH'
|
|
print os.environ["PATH"]
|
|
else:
|
|
os.environ[x] = y
|
|
print ' just set Env variable %s to %s' % (x, y)
|
|
else:
|
|
print '-------has NO export variables'
|
|
|
|
os.chdir(starting_dir)
|
|
os.environ['CDM_TOP'] = starting_dir
|
|
|
|
#print ' Actual: %s' % (starting_dir)
|
|
|
|
def RunGyp(args):
|
|
print ' Args: %s' % (args)
|
|
global gyp_args
|
|
global build_config
|
|
if parser_arguments.release:
|
|
build_config = '--build=Release'
|
|
gyp_args.append(build_config)
|
|
# Append the global include file last.
|
|
# This allows a platform definition to exist
|
|
# in a gypi file adding the ability for the
|
|
# platform definition to use the features of gyp.
|
|
gyp_args.append(global_include_file)
|
|
gyp.main(gyp_args)
|
|
|
|
def ParseOptions(args):
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("platform", help="The platform configuration you want to build")
|
|
parser.add_argument("-r", "--release", help='build release build', action='store_true')
|
|
global parser_arguments
|
|
parser_arguments = parser.parse_args()
|
|
|
|
def main(args):
|
|
def exitOnFailure(result):
|
|
if not result == 0:
|
|
sys.exit(result)
|
|
|
|
ParseOptions(args)
|
|
ImportPlatform(parser_arguments.platform)
|
|
print ' Running Gyp with: %s' % args
|
|
|
|
RunGyp(args)
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv[1:])
|