194eb010fSTodd Fiala# System modules 294eb010fSTodd Fialaimport os 394eb010fSTodd Fialaimport re 494eb010fSTodd Fiala 594eb010fSTodd Fiala 694eb010fSTodd FialaGMODULES_SUPPORT_MAP = {} 794eb010fSTodd FialaGMODULES_HELP_REGEX = re.compile(r"\s-gmodules\s") 894eb010fSTodd Fiala 994eb010fSTodd Fiala 1094eb010fSTodd Fialadef is_compiler_clang_with_gmodules(compiler_path): 1194eb010fSTodd Fiala # Before computing the result, check if we already have it cached. 1294eb010fSTodd Fiala if compiler_path in GMODULES_SUPPORT_MAP: 1394eb010fSTodd Fiala return GMODULES_SUPPORT_MAP[compiler_path] 1494eb010fSTodd Fiala 1594eb010fSTodd Fiala def _gmodules_supported_internal(): 1694eb010fSTodd Fiala compiler = os.path.basename(compiler_path) 1794eb010fSTodd Fiala if "clang" not in compiler: 1894eb010fSTodd Fiala return False 1994eb010fSTodd Fiala else: 2094eb010fSTodd Fiala # Check the compiler help for the -gmodules option. 2194eb010fSTodd Fiala clang_help = os.popen("%s --help" % compiler_path).read() 22*2238dcc3SJonas Devlieghere return GMODULES_HELP_REGEX.search(clang_help, re.DOTALL) is not None 2394eb010fSTodd Fiala 2494eb010fSTodd Fiala GMODULES_SUPPORT_MAP[compiler_path] = _gmodules_supported_internal() 2594eb010fSTodd Fiala return GMODULES_SUPPORT_MAP[compiler_path] 26