| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 # GYP defines from the command line. We can't use optparse since we want | 120 # GYP defines from the command line. We can't use optparse since we want |
| 121 # to ignore all arguments other than "-D". | 121 # to ignore all arguments other than "-D". |
| 122 cmdline_input_items = [] | 122 cmdline_input_items = [] |
| 123 for i in range(len(sys.argv))[1:]: | 123 for i in range(len(sys.argv))[1:]: |
| 124 if sys.argv[i] == '-D' and i + 1 < len(sys.argv): | 124 if sys.argv[i] == '-D' and i + 1 < len(sys.argv): |
| 125 cmdline_input_items += [sys.argv[i + 1]] | 125 cmdline_input_items += [sys.argv[i + 1]] |
| 126 cmdline_items = ProcessGypDefinesItems(cmdline_input_items) | 126 cmdline_items = ProcessGypDefinesItems(cmdline_input_items) |
| 127 | 127 |
| 128 return dict(supp_items + env_items + cmdline_items) | 128 return dict(supp_items + env_items + cmdline_items) |
| 129 | 129 |
| 130 def GetOutputDirectory(): |
| 131 """Returns the output directory that GYP will use.""" |
| 132 # GYP generator flags from the command line. We can't use optparse since we |
| 133 # want to ignore all arguments other than "-G". |
| 134 needle = '-Goutput_dir=' |
| 135 cmdline_input_items = [] |
| 136 for item in sys.argv[1:]: |
| 137 if item.startswith(needle): |
| 138 return item[len(needle):] |
| 139 |
| 140 env_items = shlex.split(os.environ.get('GYP_GENERATOR_FLAGS', '')) |
| 141 needle = 'output_dir=' |
| 142 for item in env_items: |
| 143 if item.startswith(needle): |
| 144 return item[len(needle):] |
| 145 |
| 146 return "out" |
| 130 | 147 |
| 131 def GetArgsStringForGN(supplemental_files): | 148 def GetArgsStringForGN(supplemental_files): |
| 132 """Returns the args to pass to GN. | 149 """Returns the args to pass to GN. |
| 133 Based on a subset of the GYP variables that have been rewritten a bit.""" | 150 Based on a subset of the GYP variables that have been rewritten a bit.""" |
| 134 | 151 |
| 135 # Find the .gyp directory in the user's home directory. | 152 # Find the .gyp directory in the user's home directory. |
| 136 home_dot_gyp = os.environ.get('GYP_CONFIG_DIR', None) | 153 home_dot_gyp = os.environ.get('GYP_CONFIG_DIR', None) |
| 137 if home_dot_gyp: | 154 if home_dot_gyp: |
| 138 home_dot_gyp = os.path.expanduser(home_dot_gyp) | 155 home_dot_gyp = os.path.expanduser(home_dot_gyp) |
| 139 if not home_dot_gyp: | 156 if not home_dot_gyp: |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 gyp_msvs_version = os.environ.get('GYP_MSVS_VERSION', '') | 234 gyp_msvs_version = os.environ.get('GYP_MSVS_VERSION', '') |
| 218 if gyp_msvs_version: | 235 if gyp_msvs_version: |
| 219 gn_args += ' visual_studio_version=' + EscapeStringForGN(gyp_msvs_version) | 236 gn_args += ' visual_studio_version=' + EscapeStringForGN(gyp_msvs_version) |
| 220 gyp_msvs_override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH', '') | 237 gyp_msvs_override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH', '') |
| 221 if gyp_msvs_override_path: | 238 if gyp_msvs_override_path: |
| 222 gn_args += ' visual_studio_path=' + \ | 239 gn_args += ' visual_studio_path=' + \ |
| 223 EscapeStringForGN(gyp_msvs_override_path) | 240 EscapeStringForGN(gyp_msvs_override_path) |
| 224 | 241 |
| 225 # Set the GYP flag so BUILD files know they're being invoked in GYP mode. | 242 # Set the GYP flag so BUILD files know they're being invoked in GYP mode. |
| 226 gn_args += ' is_gyp=true' | 243 gn_args += ' is_gyp=true' |
| 244 |
| 245 gyp_outdir = GetOutputDirectory() |
| 246 gn_args += ' gyp_output_dir=\"%s\"' % gyp_outdir |
| 247 |
| 227 return gn_args.strip() | 248 return gn_args.strip() |
| 228 | 249 |
| 229 | 250 |
| 230 def additional_include_files(supplemental_files, args=[]): | 251 def additional_include_files(supplemental_files, args=[]): |
| 231 """ | 252 """ |
| 232 Returns a list of additional (.gypi) files to include, without duplicating | 253 Returns a list of additional (.gypi) files to include, without duplicating |
| 233 ones that are already specified on the command line. The list of supplemental | 254 ones that are already specified on the command line. The list of supplemental |
| 234 include files is passed in as an argument. | 255 include files is passed in as an argument. |
| 235 """ | 256 """ |
| 236 # Determine the include files specified on the command line. | 257 # Determine the include files specified on the command line. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 print 'Unknown platform for GN: ', sys.platform | 298 print 'Unknown platform for GN: ', sys.platform |
| 278 return False | 299 return False |
| 279 | 300 |
| 280 print 'Generating gyp files from GN...' | 301 print 'Generating gyp files from GN...' |
| 281 | 302 |
| 282 # Need to pass both the source root (the bots don't run this command from | 303 # Need to pass both the source root (the bots don't run this command from |
| 283 # within the source tree) as well as set the is_gyp value so the BUILD files | 304 # within the source tree) as well as set the is_gyp value so the BUILD files |
| 284 # to know they're being run under GYP. | 305 # to know they're being run under GYP. |
| 285 args = [gnpath, 'gyp', '-q', | 306 args = [gnpath, 'gyp', '-q', |
| 286 '--root=' + chrome_src, | 307 '--root=' + chrome_src, |
| 287 '--args=' + GetArgsStringForGN(supplemental_includes)] | 308 '--args=' + GetArgsStringForGN(supplemental_includes), |
| 309 '--output=//' + GetOutputDirectory() + '/gn_build/'] |
| 288 return subprocess.call(args) == 0 | 310 return subprocess.call(args) == 0 |
| 289 | 311 |
| 290 | 312 |
| 291 if __name__ == '__main__': | 313 if __name__ == '__main__': |
| 292 args = sys.argv[1:] | 314 args = sys.argv[1:] |
| 293 | 315 |
| 294 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): | 316 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): |
| 295 print 'Skipping gyp_chromium due to GYP_CHROMIUM_NO_ACTION env var.' | 317 print 'Skipping gyp_chromium due to GYP_CHROMIUM_NO_ACTION env var.' |
| 296 sys.exit(0) | 318 sys.exit(0) |
| 297 | 319 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') | 412 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK') |
| 391 if syntax_check and int(syntax_check): | 413 if syntax_check and int(syntax_check): |
| 392 args.append('--check') | 414 args.append('--check') |
| 393 | 415 |
| 394 supplemental_includes = GetSupplementalFiles() | 416 supplemental_includes = GetSupplementalFiles() |
| 395 if not RunGN(supplemental_includes): | 417 if not RunGN(supplemental_includes): |
| 396 sys.exit(1) | 418 sys.exit(1) |
| 397 args.extend( | 419 args.extend( |
| 398 ['-I' + i for i in additional_include_files(supplemental_includes, args)]) | 420 ['-I' + i for i in additional_include_files(supplemental_includes, args)]) |
| 399 | 421 |
| 422 args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()]) |
| 423 |
| 400 print 'Updating projects from gyp files...' | 424 print 'Updating projects from gyp files...' |
| 401 sys.stdout.flush() | 425 sys.stdout.flush() |
| 402 | 426 |
| 403 # Off we go... | 427 # Off we go... |
| 404 sys.exit(gyp.main(args)) | 428 sys.exit(gyp.main(args)) |
| OLD | NEW |