]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/support/gmodules.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / support / gmodules.py
1 from __future__ import absolute_import
2 from __future__ import print_function
3
4 # System modules
5 import os
6 import re
7
8
9 GMODULES_SUPPORT_MAP = {}
10 GMODULES_HELP_REGEX = re.compile(r"\s-gmodules\s")
11
12
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]
17
18     def _gmodules_supported_internal():
19         compiler = os.path.basename(compiler_path)
20         if "clang" not in compiler:
21             return False
22         else:
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
27
28     GMODULES_SUPPORT_MAP[compiler_path] = _gmodules_supported_internal()
29     return GMODULES_SUPPORT_MAP[compiler_path]