aboutsummaryrefslogtreecommitdiff
path: root/deps/cares/build/gcc_version.py
blob: da019e866114b0a3df4d35796ab318e02db81a7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

import os
import re
import subprocess
import sys


def DoMain(*args):
  cc = os.environ.get('CC', 'gcc')
  stdin, stderr = os.pipe()
  subprocess.call([cc, '-v'], stderr=stderr)
  output = os.read(stdin, 4096)
  match = re.search("\ngcc version (\d+\.\d+\.\d+)", output)
  if match:
    print(match.group(1))


if __name__ == '__main__':
  DoMain(*sys.argv)