Fix compilation on VS2013
authorScott Graham <scottmg@chromium.org>
Fri, 18 Oct 2013 04:12:11 +0000 (21:12 -0700)
committerScott Graham <scottmg@chromium.org>
Fri, 18 Oct 2013 04:12:11 +0000 (21:12 -0700)
configure.py
platform_helper.py
src/edit_distance.cc
src/hash_map.h
src/metrics.cc

index 9fe3be8..431b03e 100755 (executable)
@@ -125,6 +125,8 @@ if platform.is_msvc():
               '/DNOMINMAX', '/D_CRT_SECURE_NO_WARNINGS',
               '/D_VARIADIC_MAX=10',
               '/DNINJA_PYTHON="%s"' % options.with_python]
+    if platform.msvc_needs_fs():
+        cflags.append('/FS')
     ldflags = ['/DEBUG', '/libpath:$builddir']
     if not options.debug:
         cflags += ['/Ox', '/DNDEBUG', '/GL']
index b7447a1..dac7c02 100644 (file)
@@ -21,8 +21,8 @@ def platforms():
     return ['linux', 'darwin', 'freebsd', 'openbsd', 'solaris', 'sunos5',
             'mingw', 'msvc', 'gnukfreebsd8', 'bitrig']
 
-class Platform( object ):
-    def __init__( self, platform):
+class Platform(object):
+    def __init__(self, platform):
         self._platform = platform
         if not self._platform is None:
             return
@@ -56,6 +56,14 @@ class Platform( object ):
     def is_msvc(self):
         return self._platform == 'msvc'
 
+    def msvc_needs_fs(self):
+        import subprocess
+        popen = subprocess.Popen('cl /nologo /?',
+                                 stdout=subprocess.PIPE,
+                                 stderr=subprocess.PIPE)
+        out, err = popen.communicate()
+        return '/FS ' in out
+
     def is_windows(self):
         return self.is_mingw() or self.is_msvc()
 
index cc4483f..9553c6e 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "edit_distance.h"
 
+#include <algorithm>
 #include <vector>
 
 int EditDistance(const StringPiece& s1,
index c63aa88..77e7586 100644 (file)
@@ -15,6 +15,7 @@
 #ifndef NINJA_MAP_H_
 #define NINJA_MAP_H_
 
+#include <algorithm>
 #include <string.h>
 #include "string_piece.h"
 
index ca4f97a..a7d3c7a 100644 (file)
@@ -24,6 +24,8 @@
 #include <windows.h>
 #endif
 
+#include <algorithm>
+
 #include "util.h"
 
 Metrics* g_metrics = NULL;