1 from __future__ import absolute_import
2 from __future__ import print_function
9 GMODULES_SUPPORT_MAP = {}
10 GMODULES_HELP_REGEX = re.compile(r"\s-gmodules\s")
13 def is_compiler_clang_with_gmodules(compiler_path):
14 # Before computing the result, check if we already have it cached.
15 if compiler_path in GMODULES_SUPPORT_MAP:
16 return GMODULES_SUPPORT_MAP[compiler_path]
18 def _gmodules_supported_internal():
19 compiler = os.path.basename(compiler_path)
20 if "clang" not in compiler:
23 # Check the compiler help for the -gmodules option.
24 clang_help = os.popen("%s --help" % compiler_path).read()
25 return GMODULES_HELP_REGEX.search(
26 clang_help, re.DOTALL) is not None
28 GMODULES_SUPPORT_MAP[compiler_path] = _gmodules_supported_internal()
29 return GMODULES_SUPPORT_MAP[compiler_path]