Implement GetDefaultConcurrentLinks() for Linux Builds.

This method is used to determine the size of the Ninja pool
which is used for links during the build. It is currently size 1 for Linux, because this method is not implemented.
After this patch it will be <total_memory> / 8Gb.

BUG=
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/23242012

git-svn-id: http://gyp.googlecode.com/svn/trunk@1701 78cadc50-ecff-11dd-a971-7dbc132099af
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index 25f5780..58ea28b 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -1483,6 +1483,16 @@
     ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
 
     return max(1, stat.ullTotalPhys / (4 * (2 ** 30)))  # total / 4GB
+  elif sys.platform.startswith('linux'):
+    with open("/proc/meminfo") as meminfo:
+      memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB')
+      for line in meminfo:
+        match = memtotal_re.match(line)
+        if not match:
+          continue
+        # Allow 8Gb per link on Linux because Gold is quite memory hungry
+        return max(1, int(match.group(1)) / (8 * (2 ** 20)))
+    return 1
   else:
     # TODO(scottmg): Implement this for other platforms.
     return 1