| OLD | NEW | 
|   1 #!/usr/bin/python |   1 #!/usr/bin/python | 
|   2  |   2  | 
|   3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |   3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 
|   4 # Use of this source code is governed by a BSD-style license that can be |   4 # Use of this source code is governed by a BSD-style license that can be | 
|   5 # found in the LICENSE file. |   5 # found in the LICENSE file. | 
|   6  |   6  | 
|   7 # This script is wrapper for Chromium that adds some support for how GYP |   7 # This script is wrapper for Chromium that adds some support for how GYP | 
|   8 # is invoked by Chromium beyond what can be done in the gclient hooks. |   8 # is invoked by Chromium beyond what can be done in the gclient hooks. | 
|   9  |   9  | 
|  10 import glob |  10 import glob | 
|  11 import os |  11 import os | 
|  12 import shlex |  12 import shlex | 
|  13 import sys |  13 import sys | 
|  14  |  14  | 
|  15 script_dir = os.path.dirname(__file__) |  15 script_dir = os.path.dirname(__file__) | 
|  16 chrome_src = os.path.normpath(os.path.join(script_dir, os.pardir)) |  16 chrome_src = os.path.normpath(os.path.join(script_dir, os.pardir)) | 
|  17  |  17  | 
|  18 sys.path.append(os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) |  18 sys.path.append(os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) | 
|  19 import gyp |  19 import gyp | 
|  20  |  20  | 
|  21 if __name__ == '__main__': |  21 if __name__ == '__main__': | 
|  22   args = sys.argv[1:] |  22   args = sys.argv[1:] | 
|  23  |  23  | 
 |  24   # This could give false positives since it doesn't actually do real option | 
 |  25   # parsing.  Oh well. | 
 |  26   gyp_file_specified = False | 
 |  27   for arg in args: | 
 |  28     if arg.endswith('.gyp'): | 
 |  29       gyp_file_specified = True | 
 |  30       break | 
 |  31  | 
|  24   # If we didn't get a file, check an env var, and then fall back to |  32   # If we didn't get a file, check an env var, and then fall back to | 
|  25   # assuming 'all.gyp' from the same directory as the script. |  33   # assuming 'all.gyp' from the same directory as the script. | 
|  26   gyp_file = os.environ.get('CHROMIUM_GYP_FILE') |  34   if not gyp_file_specified: | 
|  27   if gyp_file: |  35     gyp_file = os.environ.get('CHROMIUM_GYP_FILE') | 
|  28     # Note that CHROMIUM_GYP_FILE values can't have backslashes as |  36     if gyp_file: | 
|  29     # path separators even on Windows due to the use of shlex.split(). |  37       # Note that CHROMIUM_GYP_FILE values can't have backslashes as | 
|  30     args.extend(shlex.split(gyp_file)) |  38       # path separators even on Windows due to the use of shlex.split(). | 
|  31   else: |  39       args.extend(shlex.split(gyp_file)) | 
|  32     args.append(os.path.join(script_dir, 'all.gyp')) |  40     else: | 
 |  41       args.append(os.path.join(script_dir, 'all.gyp')) | 
 |  42  | 
 |  43   # Avoid duplicating an include that's already in the command line.  This | 
 |  44   # doesn't cover all the different option formats you can use, but it's mainly | 
 |  45   # intended to avoid duplicating flags on the automatic makefile regeneration | 
 |  46   # which only uses this format. | 
 |  47   specified_includes = set() | 
 |  48   for arg in args: | 
 |  49     if arg.startswith('-I') and len(arg) > 2: | 
 |  50       specified_includes.add(os.path.realpath(arg[2:])) | 
 |  51  | 
 |  52   def AddInclude(path): | 
 |  53     if os.path.realpath(path) not in specified_includes: | 
 |  54       args.append('-I' + path) | 
|  33  |  55  | 
|  34   # Always include common.gypi |  56   # Always include common.gypi | 
|  35   args += ['-I', os.path.join(script_dir, 'common.gypi')] |  57   AddInclude(os.path.join(script_dir, 'common.gypi')) | 
|  36  |  58  | 
|  37   # Optionally add supplemental .gypi files if present. |  59   # Optionally add supplemental .gypi files if present. | 
|  38   supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) |  60   supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) | 
|  39   for supplement in supplements: |  61   for supplement in supplements: | 
|  40     args += ['-I', supplement] |  62     AddInclude(supplement) | 
|  41  |  63  | 
|  42   print 'Updating projects from gyp files...' |  64   print 'Updating projects from gyp files...' | 
|  43   sys.stdout.flush() |  65   sys.stdout.flush() | 
|  44  |  66  | 
|  45   # Off we go... |  67   # Off we go... | 
|  46   sys.exit(gyp.main(args)) |  68   sys.exit(gyp.main(args)) | 
| OLD | NEW |