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

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 1365163002: Make the ninja generator handle symlinked paths correctly. (Closed) Base URL: https://chromium.googlesource.com/external/gyp@master
Patch Set: Removed unnecessary import. Created 5 years, 3 months 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
« no previous file with comments | « pylib/gyp/common.py ('k') | test/symlinks/gyptest-symlinks.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import collections 5 import collections
6 import copy 6 import copy
7 import hashlib 7 import hashlib
8 import json 8 import json
9 import multiprocessing 9 import multiprocessing
10 import os.path 10 import os.path
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 1665
1666 def CommandWithWrapper(cmd, wrappers, prog): 1666 def CommandWithWrapper(cmd, wrappers, prog):
1667 wrapper = wrappers.get(cmd, '') 1667 wrapper = wrappers.get(cmd, '')
1668 if wrapper: 1668 if wrapper:
1669 return wrapper + ' ' + prog 1669 return wrapper + ' ' + prog
1670 return prog 1670 return prog
1671 1671
1672 1672
1673 def GetDefaultConcurrentLinks(): 1673 def GetDefaultConcurrentLinks():
1674 """Returns a best-guess for a number of concurrent links.""" 1674 """Returns a best-guess for a number of concurrent links."""
1675 pool_size = int(os.getenv('GYP_LINK_CONCURRENCY', 0)) 1675 pool_size = int(os.environ.get('GYP_LINK_CONCURRENCY', 0))
1676 if pool_size: 1676 if pool_size:
1677 return pool_size 1677 return pool_size
1678 1678
1679 if sys.platform in ('win32', 'cygwin'): 1679 if sys.platform in ('win32', 'cygwin'):
1680 import ctypes 1680 import ctypes
1681 1681
1682 class MEMORYSTATUSEX(ctypes.Structure): 1682 class MEMORYSTATUSEX(ctypes.Structure):
1683 _fields_ = [ 1683 _fields_ = [
1684 ("dwLength", ctypes.c_ulong), 1684 ("dwLength", ctypes.c_ulong),
1685 ("dwMemoryLoad", ctypes.c_ulong), 1685 ("dwMemoryLoad", ctypes.c_ulong),
1686 ("ullTotalPhys", ctypes.c_ulonglong), 1686 ("ullTotalPhys", ctypes.c_ulonglong),
1687 ("ullAvailPhys", ctypes.c_ulonglong), 1687 ("ullAvailPhys", ctypes.c_ulonglong),
1688 ("ullTotalPageFile", ctypes.c_ulonglong), 1688 ("ullTotalPageFile", ctypes.c_ulonglong),
1689 ("ullAvailPageFile", ctypes.c_ulonglong), 1689 ("ullAvailPageFile", ctypes.c_ulonglong),
1690 ("ullTotalVirtual", ctypes.c_ulonglong), 1690 ("ullTotalVirtual", ctypes.c_ulonglong),
1691 ("ullAvailVirtual", ctypes.c_ulonglong), 1691 ("ullAvailVirtual", ctypes.c_ulonglong),
1692 ("sullAvailExtendedVirtual", ctypes.c_ulonglong), 1692 ("sullAvailExtendedVirtual", ctypes.c_ulonglong),
1693 ] 1693 ]
1694 1694
1695 stat = MEMORYSTATUSEX() 1695 stat = MEMORYSTATUSEX()
1696 stat.dwLength = ctypes.sizeof(stat) 1696 stat.dwLength = ctypes.sizeof(stat)
1697 ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) 1697 ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
1698 1698
1699 # VS 2015 uses 20% more working set than VS 2013 and can consume all RAM 1699 # VS 2015 uses 20% more working set than VS 2013 and can consume all RAM
1700 # on a 64 GB machine. 1700 # on a 64 GB machine.
1701 mem_limit = max(1, stat.ullTotalPhys / (5 * (2 ** 30))) # total / 5GB 1701 mem_limit = max(1, stat.ullTotalPhys / (5 * (2 ** 30))) # total / 5GB
1702 hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32))) 1702 hard_cap = max(1, int(os.environ.get('GYP_LINK_CONCURRENCY_MAX', 2**32)))
1703 return min(mem_limit, hard_cap) 1703 return min(mem_limit, hard_cap)
1704 elif sys.platform.startswith('linux'): 1704 elif sys.platform.startswith('linux'):
1705 if os.path.exists("/proc/meminfo"): 1705 if os.path.exists("/proc/meminfo"):
1706 with open("/proc/meminfo") as meminfo: 1706 with open("/proc/meminfo") as meminfo:
1707 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') 1707 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB')
1708 for line in meminfo: 1708 for line in meminfo:
1709 match = memtotal_re.match(line) 1709 match = memtotal_re.match(line)
1710 if not match: 1710 if not match:
1711 continue 1711 continue
1712 # Allow 8Gb per link on Linux because Gold is quite memory hungry 1712 # Allow 8Gb per link on Linux because Gold is quite memory hungry
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 2270
2271 this_make_global_settings = data[build_file].get('make_global_settings', []) 2271 this_make_global_settings = data[build_file].get('make_global_settings', [])
2272 assert make_global_settings == this_make_global_settings, ( 2272 assert make_global_settings == this_make_global_settings, (
2273 "make_global_settings needs to be the same for all targets. %s vs. %s" % 2273 "make_global_settings needs to be the same for all targets. %s vs. %s" %
2274 (this_make_global_settings, make_global_settings)) 2274 (this_make_global_settings, make_global_settings))
2275 2275
2276 spec = target_dicts[qualified_target] 2276 spec = target_dicts[qualified_target]
2277 if flavor == 'mac': 2277 if flavor == 'mac':
2278 gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec) 2278 gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec)
2279 2279
2280 build_file = gyp.common.RelativePath(build_file, options.toplevel_dir) 2280 # If build_file is a symlink, we must not follow it because there's a chance
2281 # it could point to a path above toplevel_dir, and we cannot correctly deal
2282 # with that case at the moment.
2283 build_file = gyp.common.RelativePath(build_file, options.toplevel_dir,
2284 False)
2281 2285
2282 qualified_target_for_hash = gyp.common.QualifiedTarget(build_file, name, 2286 qualified_target_for_hash = gyp.common.QualifiedTarget(build_file, name,
2283 toolset) 2287 toolset)
2284 hash_for_rules = hashlib.md5(qualified_target_for_hash).hexdigest() 2288 hash_for_rules = hashlib.md5(qualified_target_for_hash).hexdigest()
2285 2289
2286 base_path = os.path.dirname(build_file) 2290 base_path = os.path.dirname(build_file)
2287 obj = 'obj' 2291 obj = 'obj'
2288 if toolset != 'target': 2292 if toolset != 'target':
2289 obj += '.' + toolset 2293 obj += '.' + toolset
2290 output_file = os.path.join(obj, base_path, name + '.ninja') 2294 output_file = os.path.join(obj, base_path, name + '.ninja')
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 arglists.append( 2388 arglists.append(
2385 (target_list, target_dicts, data, params, config_name)) 2389 (target_list, target_dicts, data, params, config_name))
2386 pool.map(CallGenerateOutputForConfig, arglists) 2390 pool.map(CallGenerateOutputForConfig, arglists)
2387 except KeyboardInterrupt, e: 2391 except KeyboardInterrupt, e:
2388 pool.terminate() 2392 pool.terminate()
2389 raise e 2393 raise e
2390 else: 2394 else:
2391 for config_name in config_names: 2395 for config_name in config_names:
2392 GenerateOutputForConfig(target_list, target_dicts, data, params, 2396 GenerateOutputForConfig(target_list, target_dicts, data, params,
2393 config_name) 2397 config_name)
OLDNEW
« no previous file with comments | « pylib/gyp/common.py ('k') | test/symlinks/gyptest-symlinks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698