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

Side by Side Diff: build/gyp_chromium

Issue 62803003: Run GN as part of runhooks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try Created 7 years, 1 month 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/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 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 gyp_helper 11 import gyp_helper
12 import os 12 import os
13 import shlex 13 import shlex
14 import subprocess 14 import subprocess
15 import sys 15 import sys
16 16
17 script_dir = os.path.dirname(os.path.realpath(__file__)) 17 script_dir = os.path.dirname(os.path.realpath(__file__))
18 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) 18 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
19 19
20 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) 20 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
21 import gyp 21 import gyp
22 22
23 # Assume this file is in a one-level-deep subdirectory of the source root.
24 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
25
23 # Add paths so that pymod_do_main(...) can import files. 26 # Add paths so that pymod_do_main(...) can import files.
24 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers')) 27 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers'))
25 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit')) 28 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit'))
26 sys.path.insert(1, os.path.join(chrome_src, 'chrome', 'tools', 'build')) 29 sys.path.insert(1, os.path.join(chrome_src, 'chrome', 'tools', 'build'))
27 sys.path.insert(1, os.path.join(chrome_src, 'native_client', 'build')) 30 sys.path.insert(1, os.path.join(chrome_src, 'native_client', 'build'))
28 sys.path.insert(1, os.path.join(chrome_src, 'native_client_sdk', 'src', 31 sys.path.insert(1, os.path.join(chrome_src, 'native_client_sdk', 'src',
29 'build_tools')) 32 'build_tools'))
30 sys.path.insert(1, os.path.join(chrome_src, 'remoting', 'tools', 'build')) 33 sys.path.insert(1, os.path.join(chrome_src, 'remoting', 'tools', 'build'))
31 sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit', 34 sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit',
32 'Source', 'build', 'scripts')) 35 'Source', 'build', 'scripts'))
(...skipping 10 matching lines...) Expand all
43 # may not be worth it). 46 # may not be worth it).
44 if sys.platform == 'win32': 47 if sys.platform == 'win32':
45 try: 48 try:
46 sys.path.insert(0, os.path.join(chrome_src, 'third_party', 'psyco_win32')) 49 sys.path.insert(0, os.path.join(chrome_src, 'third_party', 'psyco_win32'))
47 import psyco 50 import psyco
48 except: 51 except:
49 psyco = None 52 psyco = None
50 else: 53 else:
51 psyco = None 54 psyco = None
52 55
56
53 def additional_include_files(args=[]): 57 def additional_include_files(args=[]):
54 """ 58 """
55 Returns a list of additional (.gypi) files to include, without 59 Returns a list of additional (.gypi) files to include, without
56 duplicating ones that are already specified on the command line. 60 duplicating ones that are already specified on the command line.
57 """ 61 """
58 # Determine the include files specified on the command line. 62 # Determine the include files specified on the command line.
59 # This doesn't cover all the different option formats you can use, 63 # This doesn't cover all the different option formats you can use,
60 # but it's mainly intended to avoid duplicating flags on the automatic 64 # but it's mainly intended to avoid duplicating flags on the automatic
61 # makefile regeneration which only uses this format. 65 # makefile regeneration which only uses this format.
62 specified_includes = set() 66 specified_includes = set()
63 for arg in args: 67 for arg in args:
64 if arg.startswith('-I') and len(arg) > 2: 68 if arg.startswith('-I') and len(arg) > 2:
65 specified_includes.add(os.path.realpath(arg[2:])) 69 specified_includes.add(os.path.realpath(arg[2:]))
66 70
67 result = [] 71 result = []
68 def AddInclude(path): 72 def AddInclude(path):
69 if os.path.realpath(path) not in specified_includes: 73 if os.path.realpath(path) not in specified_includes:
70 result.append(path) 74 result.append(path)
71 75
72 # Always include common.gypi. 76 # Always include common.gypi.
73 AddInclude(os.path.join(script_dir, 'common.gypi')) 77 AddInclude(os.path.join(script_dir, 'common.gypi'))
74 78
75 # Optionally add supplemental .gypi files if present. 79 # Optionally add supplemental .gypi files if present.
76 supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) 80 supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi'))
77 for supplement in supplements: 81 for supplement in supplements:
78 AddInclude(supplement) 82 AddInclude(supplement)
79 83
80 return result 84 return result
81 85
86
87 def RunGN():
88 """Runs GN, returning True if it succeeded, printing an error and returning
89 false if not."""
90 # The binaries in platform-specific subdirectories in src/tools/gn/bin.
91 gnpath = SRC_DIR + '/tools/gn/bin/'
92 if sys.platform == 'win32':
93 gnpath += 'win/gn.exe'
94 elif sys.platform.startswith('linux'):
95 gnpath += 'linux/gn'
96 elif sys.platform == 'darwin':
97 gnpath += 'mac/gn'
98 else:
99 print 'Unknown platform for GN: ', sys.platform
100 return False
101
102 print 'Generating gyp files from GN...'
103 print 'platform = ', sys.platform
104 print 'binary = ', gnpath
105
106 # Need to pass both the source root (the bots don't run this command from
107 # within the source tree) as well as set the is_gyp value so the BUILD files
108 # to know they're being run under GYP.
109 args = [gnpath, 'gyp', '-q', '--root=' + chrome_src, '--args=is_gyp=true']
110 return subprocess.call(args) == 0
111
112
82 if __name__ == '__main__': 113 if __name__ == '__main__':
83 args = sys.argv[1:] 114 args = sys.argv[1:]
84 115
85 # Use the Psyco JIT if available. 116 # Use the Psyco JIT if available.
86 if psyco: 117 if psyco:
87 psyco.profile() 118 psyco.profile()
88 print "Enabled Psyco JIT." 119 print "Enabled Psyco JIT."
89 120
121 if not RunGN():
122 sys.exit(1)
123
90 # Fall back on hermetic python if we happen to get run under cygwin. 124 # Fall back on hermetic python if we happen to get run under cygwin.
91 # TODO(bradnelson): take this out once this issue is fixed: 125 # TODO(bradnelson): take this out once this issue is fixed:
92 # http://code.google.com/p/gyp/issues/detail?id=177 126 # http://code.google.com/p/gyp/issues/detail?id=177
93 if sys.platform == 'cygwin': 127 if sys.platform == 'cygwin':
94 python_dir = os.path.join(chrome_src, 'third_party', 'python_26') 128 python_dir = os.path.join(chrome_src, 'third_party', 'python_26')
95 env = os.environ.copy() 129 env = os.environ.copy()
96 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') 130 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '')
97 p = subprocess.Popen( 131 p = subprocess.Popen(
98 [os.path.join(python_dir, 'python.exe')] + sys.argv, 132 [os.path.join(python_dir, 'python.exe')] + sys.argv,
99 env=env, shell=False) 133 env=env, shell=False)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 # to enfore syntax checking. 184 # to enfore syntax checking.
151 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') 185 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK')
152 if syntax_check and int(syntax_check): 186 if syntax_check and int(syntax_check):
153 args.append('--check') 187 args.append('--check')
154 188
155 print 'Updating projects from gyp files...' 189 print 'Updating projects from gyp files...'
156 sys.stdout.flush() 190 sys.stdout.flush()
157 191
158 # Off we go... 192 # Off we go...
159 sys.exit(gyp.main(args)) 193 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