Merge pull request #927 from nico/colorgcc
authorNico Weber <nicolasweber@gmx.de>
Mon, 9 Mar 2015 17:34:08 +0000 (10:34 -0700)
committerNico Weber <nicolasweber@gmx.de>
Mon, 9 Mar 2015 17:34:08 +0000 (10:34 -0700)
Make diagnostics colored with new gccs (4.9+) too.

configure.py

index cb08c17..661662f 100755 (executable)
@@ -318,9 +318,12 @@ else:
     else:
         cflags += ['-O2', '-DNDEBUG']
     try:
-        proc = subprocess.Popen([CXX, '--version'], stdout=subprocess.PIPE)
-        if 'clang' in proc.communicate()[0].decode('utf-8'):
-            cflags += ['-fcolor-diagnostics']
+        proc = subprocess.Popen(
+            [CXX, '-fdiagnostics-color', '-c', '-x', 'c++', '/dev/null'],
+            stdout=open(os.devnull, 'wb'), stderr=subprocess.STDOUT)
+        proc.wait()
+        if proc.returncode == 0:
+            cflags += ['-fdiagnostics-color']
     except:
         pass
     if platform.is_mingw():