| 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 argparse |
| 10 import glob | 11 import glob |
| 11 import gyp_environment | 12 import gyp_environment |
| 12 import os | 13 import os |
| 13 import re | 14 import re |
| 14 import shlex | 15 import shlex |
| 15 import subprocess | 16 import subprocess |
| 16 import string | 17 import string |
| 17 import sys | 18 import sys |
| 18 import vs_toolchain | 19 import vs_toolchain |
| 19 | 20 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 e.filename = os.path.abspath(supplement) | 118 e.filename = os.path.abspath(supplement) |
| 118 raise | 119 raise |
| 119 variables = file_data.get('variables', []) | 120 variables = file_data.get('variables', []) |
| 120 for v in variables: | 121 for v in variables: |
| 121 supp_items += [(v, str(variables[v]))] | 122 supp_items += [(v, str(variables[v]))] |
| 122 | 123 |
| 123 # GYP defines from the environment. | 124 # GYP defines from the environment. |
| 124 env_items = ProcessGypDefinesItems( | 125 env_items = ProcessGypDefinesItems( |
| 125 shlex.split(os.environ.get('GYP_DEFINES', ''))) | 126 shlex.split(os.environ.get('GYP_DEFINES', ''))) |
| 126 | 127 |
| 127 # GYP defines from the command line. We can't use optparse since we want | 128 # GYP defines from the command line. |
| 128 # to ignore all arguments other than "-D". | 129 parser = argparse.ArgumentParser() |
| 129 cmdline_input_items = [] | 130 parser.add_argument('-D', dest='defines', action='append', default=[]) |
| 130 for i in range(len(sys.argv))[1:]: | 131 cmdline_input_items = parser.parse_known_args()[0].defines |
| 131 if sys.argv[i].startswith('-D'): | |
| 132 if sys.argv[i] == '-D' and i + 1 < len(sys.argv): | |
| 133 cmdline_input_items += [sys.argv[i + 1]] | |
| 134 elif len(sys.argv[i]) > 2: | |
| 135 cmdline_input_items += [sys.argv[i][2:]] | |
| 136 cmdline_items = ProcessGypDefinesItems(cmdline_input_items) | 132 cmdline_items = ProcessGypDefinesItems(cmdline_input_items) |
| 137 | 133 |
| 138 vars_dict = dict(supp_items + env_items + cmdline_items) | 134 vars_dict = dict(supp_items + env_items + cmdline_items) |
| 139 return vars_dict | 135 return vars_dict |
| 140 | 136 |
| 141 | 137 |
| 142 def GetOutputDirectory(): | 138 def GetOutputDirectory(): |
| 143 """Returns the output directory that GYP will use.""" | 139 """Returns the output directory that GYP will use.""" |
| 144 # GYP generator flags from the command line. We can't use optparse since we | 140 |
| 145 # want to ignore all arguments other than "-G". | 141 # Handle command line generator flags. |
| 146 needle = '-Goutput_dir=' | 142 parser = argparse.ArgumentParser() |
| 147 cmdline_input_items = [] | 143 parser.add_argument('-G', dest='genflags', default=[], action='append') |
| 148 for item in sys.argv[1:]: | 144 genflags = parser.parse_known_args()[0].genflags |
| 145 |
| 146 # Handle generator flags from the environment. |
| 147 genflags += shlex.split(os.environ.get('GYP_GENERATOR_FLAGS', '')) |
| 148 |
| 149 needle = 'output_dir=' |
| 150 for item in genflags: |
| 149 if item.startswith(needle): | 151 if item.startswith(needle): |
| 150 return item[len(needle):] | 152 return item[len(needle):] |
| 151 | 153 |
| 152 env_items = shlex.split(os.environ.get('GYP_GENERATOR_FLAGS', '')) | 154 return 'out' |
| 153 needle = 'output_dir=' | |
| 154 for item in env_items: | |
| 155 if item.startswith(needle): | |
| 156 return item[len(needle):] | |
| 157 | |
| 158 return "out" | |
| 159 | 155 |
| 160 | 156 |
| 161 def additional_include_files(supplemental_files, args=[]): | 157 def additional_include_files(supplemental_files, args=[]): |
| 162 """ | 158 """ |
| 163 Returns a list of additional (.gypi) files to include, without duplicating | 159 Returns a list of additional (.gypi) files to include, without duplicating |
| 164 ones that are already specified on the command line. The list of supplemental | 160 ones that are already specified on the command line. The list of supplemental |
| 165 include files is passed in as an argument. | 161 include files is passed in as an argument. |
| 166 """ | 162 """ |
| 167 # Determine the include files specified on the command line. | 163 # Determine the include files specified on the command line. |
| 168 # This doesn't cover all the different option formats you can use, | 164 # This doesn't cover all the different option formats you can use, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 322 |
| 327 if not use_analyzer: | 323 if not use_analyzer: |
| 328 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() | 324 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() |
| 329 if vs2013_runtime_dll_dirs: | 325 if vs2013_runtime_dll_dirs: |
| 330 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs | 326 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs |
| 331 vs_toolchain.CopyVsRuntimeDlls( | 327 vs_toolchain.CopyVsRuntimeDlls( |
| 332 os.path.join(chrome_src, GetOutputDirectory()), | 328 os.path.join(chrome_src, GetOutputDirectory()), |
| 333 (x86_runtime, x64_runtime)) | 329 (x86_runtime, x64_runtime)) |
| 334 | 330 |
| 335 sys.exit(gyp_rc) | 331 sys.exit(gyp_rc) |
| OLD | NEW |