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 argparse |
(...skipping 14 matching lines...) Expand all Loading... |
25 import gyp | 25 import gyp |
26 | 26 |
27 # Assume this file is in a one-level-deep subdirectory of the source root. | 27 # Assume this file is in a one-level-deep subdirectory of the source root. |
28 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 28 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
29 | 29 |
30 # Add paths so that pymod_do_main(...) can import files. | 30 # Add paths so that pymod_do_main(...) can import files. |
31 sys.path.insert(1, os.path.join(chrome_src, 'android_webview', 'tools')) | 31 sys.path.insert(1, os.path.join(chrome_src, 'android_webview', 'tools')) |
32 sys.path.insert(1, os.path.join(chrome_src, 'build', 'android', 'gyp')) | 32 sys.path.insert(1, os.path.join(chrome_src, 'build', 'android', 'gyp')) |
33 sys.path.insert(1, os.path.join(chrome_src, 'chrome', 'tools', 'build')) | 33 sys.path.insert(1, os.path.join(chrome_src, 'chrome', 'tools', 'build')) |
34 sys.path.insert(1, os.path.join(chrome_src, 'chromecast', 'tools', 'build')) | 34 sys.path.insert(1, os.path.join(chrome_src, 'chromecast', 'tools', 'build')) |
| 35 sys.path.insert(1, os.path.join(chrome_src, 'ios', 'chrome', 'tools', 'build')) |
35 sys.path.insert(1, os.path.join(chrome_src, 'native_client', 'build')) | 36 sys.path.insert(1, os.path.join(chrome_src, 'native_client', 'build')) |
36 sys.path.insert(1, os.path.join(chrome_src, 'native_client_sdk', 'src', | 37 sys.path.insert(1, os.path.join(chrome_src, 'native_client_sdk', 'src', |
37 'build_tools')) | 38 'build_tools')) |
38 sys.path.insert(1, os.path.join(chrome_src, 'remoting', 'tools', 'build')) | 39 sys.path.insert(1, os.path.join(chrome_src, 'remoting', 'tools', 'build')) |
39 sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'liblouis')) | 40 sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'liblouis')) |
40 sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit', | 41 sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit', |
41 'Source', 'build', 'scripts')) | 42 'Source', 'build', 'scripts')) |
42 sys.path.insert(1, os.path.join(chrome_src, 'tools')) | 43 sys.path.insert(1, os.path.join(chrome_src, 'tools')) |
43 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers')) | 44 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers')) |
44 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit')) | 45 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit')) |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 # Fall back on hermetic python if we happen to get run under cygwin. | 221 # Fall back on hermetic python if we happen to get run under cygwin. |
221 # TODO(bradnelson): take this out once this issue is fixed: | 222 # TODO(bradnelson): take this out once this issue is fixed: |
222 # http://code.google.com/p/gyp/issues/detail?id=177 | 223 # http://code.google.com/p/gyp/issues/detail?id=177 |
223 if sys.platform == 'cygwin': | 224 if sys.platform == 'cygwin': |
224 import find_depot_tools | 225 import find_depot_tools |
225 depot_tools_path = find_depot_tools.add_depot_tools_to_path() | 226 depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
226 python_dir = sorted(glob.glob(os.path.join(depot_tools_path, | 227 python_dir = sorted(glob.glob(os.path.join(depot_tools_path, |
227 'python2*_bin')))[-1] | 228 'python2*_bin')))[-1] |
228 env = os.environ.copy() | 229 env = os.environ.copy() |
229 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') | 230 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '') |
230 p = subprocess.Popen( | 231 cmd = [os.path.join(python_dir, 'python.exe')] + sys.argv |
231 [os.path.join(python_dir, 'python.exe')] + sys.argv, | 232 sys.exit(subprocess.call(cmd, env=env)) |
232 env=env, shell=False) | |
233 p.communicate() | |
234 sys.exit(p.returncode) | |
235 | 233 |
236 # This could give false positives since it doesn't actually do real option | 234 # This could give false positives since it doesn't actually do real option |
237 # parsing. Oh well. | 235 # parsing. Oh well. |
238 gyp_file_specified = False | 236 gyp_file_specified = any(arg.endswith('.gyp') for arg in args) |
239 for arg in args: | |
240 if arg.endswith('.gyp'): | |
241 gyp_file_specified = True | |
242 break | |
243 | 237 |
244 gyp_environment.SetEnvironment() | 238 gyp_environment.SetEnvironment() |
245 | 239 |
246 # If we didn't get a file, check an env var, and then fall back to | 240 # If we didn't get a file, check an env var, and then fall back to |
247 # assuming 'all.gyp' from the same directory as the script. | 241 # assuming 'all.gyp' from the same directory as the script. |
248 if not gyp_file_specified: | 242 if not gyp_file_specified: |
249 gyp_file = os.environ.get('CHROMIUM_GYP_FILE') | 243 gyp_file = os.environ.get('CHROMIUM_GYP_FILE') |
250 if gyp_file: | 244 if gyp_file: |
251 # Note that CHROMIUM_GYP_FILE values can't have backslashes as | 245 # Note that CHROMIUM_GYP_FILE values can't have backslashes as |
252 # path separators even on Windows due to the use of shlex.split(). | 246 # path separators even on Windows due to the use of shlex.split(). |
253 args.extend(shlex.split(gyp_file)) | 247 args.extend(shlex.split(gyp_file)) |
254 else: | 248 else: |
255 args.append(os.path.join(script_dir, 'all.gyp')) | 249 args.append(os.path.join(script_dir, 'all.gyp')) |
256 | 250 |
257 supplemental_includes = GetSupplementalFiles() | 251 supplemental_includes = GetSupplementalFiles() |
258 gyp_vars_dict = GetGypVars(supplemental_includes) | 252 gyp_vars_dict = GetGypVars(supplemental_includes) |
259 # There shouldn't be a circular dependency relationship between .gyp files, | 253 # There shouldn't be a circular dependency relationship between .gyp files, |
260 # but in Chromium's .gyp files, on non-Mac platforms, circular relationships | 254 # but in Chromium's .gyp files, on non-Mac platforms, circular relationships |
261 # currently exist. The check for circular dependencies is currently | 255 # currently exist. The check for circular dependencies is currently |
262 # bypassed on other platforms, but is left enabled on iOS, where a violation | 256 # bypassed on other platforms, but is left enabled on iOS, where a violation |
263 # of the rule causes Xcode to misbehave badly. | 257 # of the rule causes Xcode to misbehave badly. |
264 # TODO(mark): Find and kill remaining circular dependencies, and remove this | 258 # TODO(mark): Find and kill remaining circular dependencies, and remove this |
265 # option. http://crbug.com/35878. | 259 # option. http://crbug.com/35878. |
266 # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the | 260 # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the |
267 # list. | 261 # list. |
268 if gyp_vars_dict.get('OS') != 'ios': | 262 if gyp_vars_dict.get('OS') != 'ios': |
269 args.append('--no-circular-check') | 263 args.append('--no-circular-check') |
270 | 264 |
| 265 # libtool on Mac warns about duplicate basenames in static libraries, so |
| 266 # they're disallowed in general by gyp. We are lax on this point, so disable |
| 267 # this check other than on Mac. GN does not use static libraries as heavily, |
| 268 # so over time this restriction will mostly go away anyway, even on Mac. |
| 269 # https://code.google.com/p/gyp/issues/detail?id=384 |
| 270 if sys.platform != 'darwin': |
| 271 args.append('--no-duplicate-basename-check') |
| 272 |
271 # We explicitly don't support the make gyp generator (crbug.com/348686). Be | 273 # We explicitly don't support the make gyp generator (crbug.com/348686). Be |
272 # nice and fail here, rather than choking in gyp. | 274 # nice and fail here, rather than choking in gyp. |
273 if re.search(r'(^|,|\s)make($|,|\s)', os.environ.get('GYP_GENERATORS', '')): | 275 if re.search(r'(^|,|\s)make($|,|\s)', os.environ.get('GYP_GENERATORS', '')): |
274 print 'Error: make gyp generator not supported (check GYP_GENERATORS).' | 276 print 'Error: make gyp generator not supported (check GYP_GENERATORS).' |
275 sys.exit(1) | 277 sys.exit(1) |
276 | 278 |
277 # We explicitly don't support the native msvs gyp generator. Be nice and | 279 # We explicitly don't support the native msvs gyp generator. Be nice and |
278 # fail here, rather than generating broken projects. | 280 # fail here, rather than generating broken projects. |
279 if re.search(r'(^|,|\s)msvs($|,|\s)', os.environ.get('GYP_GENERATORS', '')): | 281 if re.search(r'(^|,|\s)msvs($|,|\s)', os.environ.get('GYP_GENERATORS', '')): |
280 print 'Error: msvs gyp generator not supported (check GYP_GENERATORS).' | 282 print 'Error: msvs gyp generator not supported (check GYP_GENERATORS).' |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 324 |
323 if not use_analyzer: | 325 if not use_analyzer: |
324 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() | 326 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() |
325 if vs2013_runtime_dll_dirs: | 327 if vs2013_runtime_dll_dirs: |
326 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs | 328 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs |
327 vs_toolchain.CopyVsRuntimeDlls( | 329 vs_toolchain.CopyVsRuntimeDlls( |
328 os.path.join(chrome_src, GetOutputDirectory()), | 330 os.path.join(chrome_src, GetOutputDirectory()), |
329 (x86_runtime, x64_runtime)) | 331 (x86_runtime, x64_runtime)) |
330 | 332 |
331 sys.exit(gyp_rc) | 333 sys.exit(gyp_rc) |
OLD | NEW |