Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: build/gyp_chromium

Issue 214058: Create a separate function that returns the list of additional... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 def additional_include_files(args=[]):
22 """
23 Returns a list of additional (.gypi) files to include, without
24 duplicating ones that are already specified on the command line.
25 """
26 # Determine the include files specified on the command line.
27 # This doesn't cover all the different option formats you can use,
28 # but it's mainly intended to avoid duplicating flags on the automatic
29 # makefile regeneration which only uses this format.
30 specified_includes = set()
31 for arg in args:
32 if arg.startswith('-I') and len(arg) > 2:
33 specified_includes.add(os.path.realpath(arg[2:]))
34
35 result = []
36 def AddInclude(path):
37 if os.path.realpath(path) not in specified_includes:
38 result.append(path)
39
40 # Always include common.gypi
41 AddInclude(os.path.join(script_dir, 'common.gypi'))
42
43 # Optionally add supplemental .gypi files if present.
44 supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi'))
45 for supplement in supplements:
46 AddInclude(supplement)
47
48 return result
49
21 if __name__ == '__main__': 50 if __name__ == '__main__':
22 args = sys.argv[1:] 51 args = sys.argv[1:]
23 52
24 # This could give false positives since it doesn't actually do real option 53 # This could give false positives since it doesn't actually do real option
25 # parsing. Oh well. 54 # parsing. Oh well.
26 gyp_file_specified = False 55 gyp_file_specified = False
27 for arg in args: 56 for arg in args:
28 if arg.endswith('.gyp'): 57 if arg.endswith('.gyp'):
29 gyp_file_specified = True 58 gyp_file_specified = True
30 break 59 break
31 60
32 # If we didn't get a file, check an env var, and then fall back to 61 # If we didn't get a file, check an env var, and then fall back to
33 # assuming 'all.gyp' from the same directory as the script. 62 # assuming 'all.gyp' from the same directory as the script.
34 if not gyp_file_specified: 63 if not gyp_file_specified:
35 gyp_file = os.environ.get('CHROMIUM_GYP_FILE') 64 gyp_file = os.environ.get('CHROMIUM_GYP_FILE')
36 if gyp_file: 65 if gyp_file:
37 # Note that CHROMIUM_GYP_FILE values can't have backslashes as 66 # Note that CHROMIUM_GYP_FILE values can't have backslashes as
38 # path separators even on Windows due to the use of shlex.split(). 67 # path separators even on Windows due to the use of shlex.split().
39 args.extend(shlex.split(gyp_file)) 68 args.extend(shlex.split(gyp_file))
40 else: 69 else:
41 args.append(os.path.join(script_dir, 'all.gyp')) 70 args.append(os.path.join(script_dir, 'all.gyp'))
42 71
43 # Avoid duplicating an include that's already in the command line. This 72 args.extend(['-I' + i for i in additional_include_files(args)])
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)
55
56 # Always include common.gypi
57 AddInclude(os.path.join(script_dir, 'common.gypi'))
58
59 # Optionally add supplemental .gypi files if present.
60 supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi'))
61 for supplement in supplements:
62 AddInclude(supplement)
63 73
64 print 'Updating projects from gyp files...' 74 print 'Updating projects from gyp files...'
65 sys.stdout.flush() 75 sys.stdout.flush()
66 76
67 # Off we go... 77 # Off we go...
68 sys.exit(gyp.main(args)) 78 sys.exit(gyp.main(args))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698