check_cc.py (757B)
1 #!/usr/bin/env python3 2 3 import os 4 import subprocess 5 import sys 6 7 def main(): 8 if sys.platform == 'win32' or len(sys.argv) < 2: 9 print(0) 10 else: 11 cc = os.environ.get('CC', 'cc') 12 try: 13 if sys.argv[1] == "cc": 14 cc_output = subprocess.check_output( 15 [cc, '--version'], universal_newlines=True) 16 cc_is_arg = "cc" in cc_output and not ("gcc" in cc_output) 17 else: 18 cc_is_arg = sys.argv[1] in subprocess.check_output( 19 [cc, '--version'], universal_newlines=True) 20 except OSError: 21 # We probably just don't have CC/cc. 22 cc_is_arg = False 23 print(int(cc_is_arg)) 24 25 if __name__ == '__main__': 26 main()