2009-09-16 03:52:14 +04:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2009-09-16 23:44:02 +04:00
|
|
|
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2009-09-16 03:52:14 +04:00
|
|
|
# This script is wrapper for Chromium that adds some support for how GYP
|
2009-09-16 23:44:02 +04:00
|
|
|
# is invoked by Chromium beyond what can be done in the gclient hooks.
|
2009-09-16 03:52:14 +04:00
|
|
|
|
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
import shlex
|
|
|
|
import sys
|
|
|
|
|
2009-09-17 02:37:47 +04:00
|
|
|
script_dir = os.path.dirname(__file__)
|
|
|
|
chrome_src = os.path.normpath(os.path.join(script_dir, os.pardir))
|
2009-09-16 23:44:02 +04:00
|
|
|
|
2009-09-17 02:37:47 +04:00
|
|
|
sys.path.append(os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
|
|
|
|
import gyp
|
2009-09-16 03:52:14 +04:00
|
|
|
|
2009-09-23 07:49:50 +04:00
|
|
|
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)
|
|
|
|
|
2009-10-06 00:48:38 +04:00
|
|
|
# Always include common.gypi & features_override.gypi
|
2009-09-23 07:49:50 +04:00
|
|
|
AddInclude(os.path.join(script_dir, 'common.gypi'))
|
2009-10-06 00:48:38 +04:00
|
|
|
AddInclude(os.path.join(script_dir, 'features_override.gypi'))
|
2009-09-23 07:49:50 +04:00
|
|
|
|
|
|
|
# Optionally add supplemental .gypi files if present.
|
|
|
|
supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi'))
|
|
|
|
for supplement in supplements:
|
|
|
|
AddInclude(supplement)
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
2009-09-16 03:52:14 +04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
args = sys.argv[1:]
|
|
|
|
|
2009-09-17 03:16:05 +04:00
|
|
|
# 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
|
|
|
|
|
2009-09-16 03:52:14 +04:00
|
|
|
# If we didn't get a file, check an env var, and then fall back to
|
2009-09-17 02:37:47 +04:00
|
|
|
# assuming 'all.gyp' from the same directory as the script.
|
2009-09-17 03:16:05 +04:00
|
|
|
if not gyp_file_specified:
|
|
|
|
gyp_file = os.environ.get('CHROMIUM_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:
|
|
|
|
args.append(os.path.join(script_dir, 'all.gyp'))
|
|
|
|
|
2009-09-23 07:49:50 +04:00
|
|
|
args.extend(['-I' + i for i in additional_include_files(args)])
|
2009-09-16 03:52:14 +04:00
|
|
|
|
2009-09-17 02:37:47 +04:00
|
|
|
print 'Updating projects from gyp files...'
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
2009-09-16 03:52:14 +04:00
|
|
|
# Off we go...
|
|
|
|
sys.exit(gyp.main(args))
|