ninja/mac: Allow more than one ld process at a time, based on available RAM.
Allow one concurrent ld process for every 4 GB of ram. This matches what
ninja/windows does.
R=mark@chromium.org
Review URL: https://codereview.chromium.org/23622005
git-svn-id: http://gyp.googlecode.com/svn/trunk@1706 78cadc50-ecff-11dd-a971-7dbc132099af
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index 8e84c23..4574375 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -1495,6 +1495,14 @@
# Allow 8Gb per link on Linux because Gold is quite memory hungry
return max(1, int(match.group(1)) / (8 * (2 ** 20)))
return 1
+ elif sys.platform == 'darwin':
+ try:
+ avail_bytes = int(subprocess.check_output(['sysctl', '-n', 'hw.memsize']))
+ # A static library debug build of Chromium's unit_tests takes ~2.7GB, so
+ # 4GB per ld process allows for some more bloat.
+ return max(1, avail_bytes / (4 * (2 ** 30))) # total / 4GB
+ except:
+ return 1
else:
# TODO(scottmg): Implement this for other platforms.
return 1