[scripts] Get clang version from soong/scripts/get_clang_version.py
... instead of manually parsing soong/cc/config/global.go Also hard-code clang_base in gdbclient.py to 'prebuilts/clang/host' as it's unlikely to change in global.go. Test: acov-llvm.py flush Test: verify gdbclient.read_toolchain_config() in the interpreter Change-Id: I28ed4416749edcd5d623598eb65eeb7891b657ae
This commit is contained in:
@@ -60,14 +60,10 @@ def android_build_top():
|
||||
|
||||
|
||||
def _get_clang_revision():
|
||||
regex = r'ClangDefaultVersion\s+= "(?P<rev>clang-r\d+[a-z]?)"'
|
||||
global_go = android_build_top() / 'build/soong/cc/config/global.go'
|
||||
with open(global_go) as infile:
|
||||
match = re.search(regex, infile.read())
|
||||
|
||||
if match is None:
|
||||
raise RuntimeError(f'Parsing clang info from {global_go} failed')
|
||||
return match.group('rev')
|
||||
version_output = subprocess.check_output(
|
||||
android_build_top() / 'build/soong/scripts/get_clang_version.py',
|
||||
text=True)
|
||||
return version_output.strip()
|
||||
|
||||
|
||||
CLANG_TOP = android_build_top() / 'prebuilts/clang/host/linux-x86/' \
|
||||
|
||||
@@ -35,23 +35,11 @@ g_temp_dirs = []
|
||||
|
||||
|
||||
def read_toolchain_config(root):
|
||||
"""Finds out current toolchain path and version."""
|
||||
def get_value(str):
|
||||
return str[str.index('"') + 1:str.rindex('"')]
|
||||
|
||||
config_path = os.path.join(root, 'build', 'soong', 'cc', 'config',
|
||||
'global.go')
|
||||
with open(config_path) as f:
|
||||
contents = f.readlines()
|
||||
clang_base = ""
|
||||
clang_version = ""
|
||||
for line in contents:
|
||||
line = line.strip()
|
||||
if line.startswith('ClangDefaultBase'):
|
||||
clang_base = get_value(line)
|
||||
elif line.startswith('ClangDefaultVersion'):
|
||||
clang_version = get_value(line)
|
||||
return (clang_base, clang_version)
|
||||
"""Finds out current toolchain version."""
|
||||
version_output = subprocess.check_output(
|
||||
f'{root}/build/soong/scripts/get_clang_version.py',
|
||||
text=True)
|
||||
return version_output.strip()
|
||||
|
||||
|
||||
def get_lldb_path(toolchain_path):
|
||||
@@ -348,7 +336,8 @@ def do_main():
|
||||
is64bit = arch.endswith("64")
|
||||
|
||||
# Make sure we have the linker
|
||||
clang_base, clang_version = read_toolchain_config(root)
|
||||
clang_base = 'prebuilts/clang/host'
|
||||
clang_version = read_toolchain_config(root)
|
||||
toolchain_path = os.path.join(root, clang_base, platform_name,
|
||||
clang_version)
|
||||
llvm_readobj_path = os.path.join(toolchain_path, "bin", "llvm-readobj")
|
||||
|
||||
Reference in New Issue
Block a user