Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 | 71 |
| 72 # Always include common.gypi. | 72 # Always include common.gypi. |
| 73 AddInclude(os.path.join(script_dir, 'common.gypi')) | 73 AddInclude(os.path.join(script_dir, 'common.gypi')) |
| 74 | 74 |
| 75 # Optionally add supplemental .gypi files if present. | 75 # Optionally add supplemental .gypi files if present. |
| 76 supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) | 76 supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) |
| 77 for supplement in supplements: | 77 for supplement in supplements: |
| 78 AddInclude(supplement) | 78 AddInclude(supplement) |
| 79 | 79 |
| 80 return result | 80 return result |
| 81 | 81 |
|
M-A Ruel
2013/11/14 23:23:36
2 lines between file level symbols
| |
| 82 def RunGN(): | |
| 83 """Runs GN, returning True if it succeeded, printing an error and returning | |
| 84 false if not.""" | |
| 85 # The binaries in platform-specific subdirectories in src/tools/gn/bin. | |
| 86 # We assume this file is in one subdirectory of the source root. | |
| 87 source_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
|
M-A Ruel
2013/11/14 23:23:36
It's highly preferable to create a global variable
| |
| 88 gnpath = source_root + '/tools/gn/bin/' | |
| 89 if sys.platform == 'win32': | |
| 90 gnpath += 'win/gn.exe' | |
| 91 elif sys.platform.startswith('linux'): | |
| 92 gnpath += 'linux/gn' | |
| 93 elif sys.platform == 'darwin': | |
| 94 gnpath += 'mac/gn' | |
| 95 else: | |
| 96 print 'Unknown platform for GN: ', sys.platform | |
| 97 return False | |
| 98 | |
| 99 print 'Generating gyp files from GN...' | |
| 100 | |
| 101 # Need to pass both the source root (the bots don't run this command from | |
| 102 # within the source tree) as well as set the is_gyp value so the BUILD files | |
| 103 # to know they're being run under GYP. | |
| 104 args = [gnpath, 'gyp', '-q', '--root=' + chrome_src, '--args=is_gyp=true'] | |
| 105 return subprocess.call(args) == 0 | |
| 106 | |
|
M-A Ruel
2013/11/14 23:23:36
2 lines
| |
| 82 if __name__ == '__main__': | 107 if __name__ == '__main__': |
| 83 args = sys.argv[1:] | 108 args = sys.argv[1:] |
| 84 | 109 |
| 85 # Use the Psyco JIT if available. | 110 # Use the Psyco JIT if available. |
| 86 if psyco: | 111 if psyco: |
| 87 psyco.profile() | 112 psyco.profile() |
| 88 print "Enabled Psyco JIT." | 113 print "Enabled Psyco JIT." |
| 89 | 114 |
| 115 if not RunGN(): | |
| 116 sys.exit(1) | |
| 117 | |
| 90 # Fall back on hermetic python if we happen to get run under cygwin. | 118 # Fall back on hermetic python if we happen to get run under cygwin. |
| 91 # TODO(bradnelson): take this out once this issue is fixed: | 119 # TODO(bradnelson): take this out once this issue is fixed: |
| 92 # http://code.google.com/p/gyp/issues/detail?id=177 | 120 # http://code.google.com/p/gyp/issues/detail?id=177 |
| 93 if sys.platform == 'cygwin': | 121 if sys.platform == 'cygwin': |
| 94 python_dir = os.path.join(chrome_src, 'third_party', 'python_26') | 122 python_dir = os.path.join(chrome_src, 'third_party', 'python_26') |
| 95 env = os.environ.copy() | 123 env = os.environ.copy() |
| 96 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') | 124 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') |
| 97 p = subprocess.Popen( | 125 p = subprocess.Popen( |
| 98 [os.path.join(python_dir, 'python.exe')] + sys.argv, | 126 [os.path.join(python_dir, 'python.exe')] + sys.argv, |
| 99 env=env, shell=False) | 127 env=env, shell=False) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 # to enfore syntax checking. | 178 # to enfore syntax checking. |
| 151 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') | 179 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') |
| 152 if syntax_check and int(syntax_check): | 180 if syntax_check and int(syntax_check): |
| 153 args.append('--check') | 181 args.append('--check') |
| 154 | 182 |
| 155 print 'Updating projects from gyp files...' | 183 print 'Updating projects from gyp files...' |
| 156 sys.stdout.flush() | 184 sys.stdout.flush() |
| 157 | 185 |
| 158 # Off we go... | 186 # Off we go... |
| 159 sys.exit(gyp.main(args)) | 187 sys.exit(gyp.main(args)) |
| OLD | NEW |