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

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: Added 'chdir=outdir' per Nico's suggestion on the last CL. Created 5 years, 2 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
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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 cflags_c = config.get('cflags_c', []) 914 cflags_c = config.get('cflags_c', [])
915 cflags_cc = config.get('cflags_cc', []) 915 cflags_cc = config.get('cflags_cc', [])
916 916
917 # Respect environment variables related to build, but target-specific 917 # Respect environment variables related to build, but target-specific
918 # flags can still override them. 918 # flags can still override them.
919 if self.toolset == 'target': 919 if self.toolset == 'target':
920 cflags_c = (os.environ.get('CPPFLAGS', '').split() + 920 cflags_c = (os.environ.get('CPPFLAGS', '').split() +
921 os.environ.get('CFLAGS', '').split() + cflags_c) 921 os.environ.get('CFLAGS', '').split() + cflags_c)
922 cflags_cc = (os.environ.get('CPPFLAGS', '').split() + 922 cflags_cc = (os.environ.get('CPPFLAGS', '').split() +
923 os.environ.get('CXXFLAGS', '').split() + cflags_cc) 923 os.environ.get('CXXFLAGS', '').split() + cflags_cc)
924 elif self.toolset == 'host':
scottmg 2015/09/24 21:30:51 why is this is in this CL?
lindleyf 2015/09/24 21:47:14 I could move that to a different CL if you prefer.
scottmg 2015/09/24 21:59:09 yes, if it's unrelated, it should be a separate ch
lindleyf 2015/09/24 22:10:26 Okay, reverted. I'll do this separately.
925 cflags_c = (os.environ.get('CPPFLAGS_host', '').split() +
926 os.environ.get('CFLAGS_host', '').split() + cflags_c)
927 cflags_cc = (os.environ.get('CPPFLAGS_host', '').split() +
928 os.environ.get('CXXFLAGS_host', '').split() + cflags_cc)
924 929
925 defines = config.get('defines', []) + extra_defines 930 defines = config.get('defines', []) + extra_defines
926 self.WriteVariableList(ninja_file, 'defines', 931 self.WriteVariableList(ninja_file, 'defines',
927 [Define(d, self.flavor) for d in defines]) 932 [Define(d, self.flavor) for d in defines])
928 if self.flavor == 'win': 933 if self.flavor == 'win':
929 self.WriteVariableList(ninja_file, 'asmflags', 934 self.WriteVariableList(ninja_file, 'asmflags',
930 map(self.ExpandSpecial, asmflags)) 935 map(self.ExpandSpecial, asmflags))
931 self.WriteVariableList(ninja_file, 'rcflags', 936 self.WriteVariableList(ninja_file, 'rcflags',
932 [QuoteShellArgument(self.ExpandSpecial(f), self.flavor) 937 [QuoteShellArgument(self.ExpandSpecial(f), self.flavor)
933 for f in self.msvs_settings.GetRcflags(config_name, 938 for f in self.msvs_settings.GetRcflags(config_name,
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 1670
1666 def CommandWithWrapper(cmd, wrappers, prog): 1671 def CommandWithWrapper(cmd, wrappers, prog):
1667 wrapper = wrappers.get(cmd, '') 1672 wrapper = wrappers.get(cmd, '')
1668 if wrapper: 1673 if wrapper:
1669 return wrapper + ' ' + prog 1674 return wrapper + ' ' + prog
1670 return prog 1675 return prog
1671 1676
1672 1677
1673 def GetDefaultConcurrentLinks(): 1678 def GetDefaultConcurrentLinks():
1674 """Returns a best-guess for a number of concurrent links.""" 1679 """Returns a best-guess for a number of concurrent links."""
1675 pool_size = int(os.getenv('GYP_LINK_CONCURRENCY', 0)) 1680 pool_size = int(os.environ.get('GYP_LINK_CONCURRENCY', 0))
1676 if pool_size: 1681 if pool_size:
1677 return pool_size 1682 return pool_size
1678 1683
1679 if sys.platform in ('win32', 'cygwin'): 1684 if sys.platform in ('win32', 'cygwin'):
1680 import ctypes 1685 import ctypes
1681 1686
1682 class MEMORYSTATUSEX(ctypes.Structure): 1687 class MEMORYSTATUSEX(ctypes.Structure):
1683 _fields_ = [ 1688 _fields_ = [
1684 ("dwLength", ctypes.c_ulong), 1689 ("dwLength", ctypes.c_ulong),
1685 ("dwMemoryLoad", ctypes.c_ulong), 1690 ("dwMemoryLoad", ctypes.c_ulong),
1686 ("ullTotalPhys", ctypes.c_ulonglong), 1691 ("ullTotalPhys", ctypes.c_ulonglong),
1687 ("ullAvailPhys", ctypes.c_ulonglong), 1692 ("ullAvailPhys", ctypes.c_ulonglong),
1688 ("ullTotalPageFile", ctypes.c_ulonglong), 1693 ("ullTotalPageFile", ctypes.c_ulonglong),
1689 ("ullAvailPageFile", ctypes.c_ulonglong), 1694 ("ullAvailPageFile", ctypes.c_ulonglong),
1690 ("ullTotalVirtual", ctypes.c_ulonglong), 1695 ("ullTotalVirtual", ctypes.c_ulonglong),
1691 ("ullAvailVirtual", ctypes.c_ulonglong), 1696 ("ullAvailVirtual", ctypes.c_ulonglong),
1692 ("sullAvailExtendedVirtual", ctypes.c_ulonglong), 1697 ("sullAvailExtendedVirtual", ctypes.c_ulonglong),
1693 ] 1698 ]
1694 1699
1695 stat = MEMORYSTATUSEX() 1700 stat = MEMORYSTATUSEX()
1696 stat.dwLength = ctypes.sizeof(stat) 1701 stat.dwLength = ctypes.sizeof(stat)
1697 ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) 1702 ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
1698 1703
1699 # VS 2015 uses 20% more working set than VS 2013 and can consume all RAM 1704 # VS 2015 uses 20% more working set than VS 2013 and can consume all RAM
1700 # on a 64 GB machine. 1705 # on a 64 GB machine.
1701 mem_limit = max(1, stat.ullTotalPhys / (5 * (2 ** 30))) # total / 5GB 1706 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))) 1707 hard_cap = max(1, int(os.environ.get('GYP_LINK_CONCURRENCY_MAX', 2**32)))
1703 return min(mem_limit, hard_cap) 1708 return min(mem_limit, hard_cap)
1704 elif sys.platform.startswith('linux'): 1709 elif sys.platform.startswith('linux'):
1705 if os.path.exists("/proc/meminfo"): 1710 if os.path.exists("/proc/meminfo"):
1706 with open("/proc/meminfo") as meminfo: 1711 with open("/proc/meminfo") as meminfo:
1707 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') 1712 memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB')
1708 for line in meminfo: 1713 for line in meminfo:
1709 match = memtotal_re.match(line) 1714 match = memtotal_re.match(line)
1710 if not match: 1715 if not match:
1711 continue 1716 continue
1712 # Allow 8Gb per link on Linux because Gold is quite memory hungry 1717 # 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 2275
2271 this_make_global_settings = data[build_file].get('make_global_settings', []) 2276 this_make_global_settings = data[build_file].get('make_global_settings', [])
2272 assert make_global_settings == this_make_global_settings, ( 2277 assert make_global_settings == this_make_global_settings, (
2273 "make_global_settings needs to be the same for all targets. %s vs. %s" % 2278 "make_global_settings needs to be the same for all targets. %s vs. %s" %
2274 (this_make_global_settings, make_global_settings)) 2279 (this_make_global_settings, make_global_settings))
2275 2280
2276 spec = target_dicts[qualified_target] 2281 spec = target_dicts[qualified_target]
2277 if flavor == 'mac': 2282 if flavor == 'mac':
2278 gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec) 2283 gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec)
2279 2284
2280 build_file = gyp.common.RelativePath(build_file, options.toplevel_dir) 2285 build_file = gyp.common.RelativePath(build_file, options.toplevel_dir,
2286 False)
2281 2287
2282 qualified_target_for_hash = gyp.common.QualifiedTarget(build_file, name, 2288 qualified_target_for_hash = gyp.common.QualifiedTarget(build_file, name,
2283 toolset) 2289 toolset)
2284 hash_for_rules = hashlib.md5(qualified_target_for_hash).hexdigest() 2290 hash_for_rules = hashlib.md5(qualified_target_for_hash).hexdigest()
2285 2291
2286 base_path = os.path.dirname(build_file) 2292 base_path = os.path.dirname(build_file)
2287 obj = 'obj' 2293 obj = 'obj'
2288 if toolset != 'target': 2294 if toolset != 'target':
2289 obj += '.' + toolset 2295 obj += '.' + toolset
2290 output_file = os.path.join(obj, base_path, name + '.ninja') 2296 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( 2390 arglists.append(
2385 (target_list, target_dicts, data, params, config_name)) 2391 (target_list, target_dicts, data, params, config_name))
2386 pool.map(CallGenerateOutputForConfig, arglists) 2392 pool.map(CallGenerateOutputForConfig, arglists)
2387 except KeyboardInterrupt, e: 2393 except KeyboardInterrupt, e:
2388 pool.terminate() 2394 pool.terminate()
2389 raise e 2395 raise e
2390 else: 2396 else:
2391 for config_name in config_names: 2397 for config_name in config_names:
2392 GenerateOutputForConfig(target_list, target_dicts, data, params, 2398 GenerateOutputForConfig(target_list, target_dicts, data, params,
2393 config_name) 2399 config_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698