Make diagnostics colored with new gccs (4.9+) too.
authorNico Weber <thakis@chromium.org>
Mon, 9 Mar 2015 17:24:41 +0000 (10:24 -0700)
committerNico Weber <thakis@chromium.org>
Mon, 9 Mar 2015 17:24:41 +0000 (10:24 -0700)
Both clang and gcc understand -fdiagnostics-color, so use that flag name.
(This will disable colored diagnostics for clangs older than LLVM 3.3,
but that is several years old by now.)

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():