Merge changes from topic "soong-clang-version-fix"

* changes:
  [scripts] Get clang version from soong/scripts/get_clang_version.py
  [scripts] Adjust FindClangDir
This commit is contained in:
Treehugger Robot
2021-08-11 06:57:27 +00:00
committed by Gerrit Code Review
3 changed files with 12 additions and 27 deletions

View File

@@ -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/' \

View File

@@ -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")

View File

@@ -38,7 +38,7 @@ def FindClangDir():
# We want the script to fail if get_clang_version.py exists but is unable
# to find the clang version.
version_output = subprocess.check_output(get_clang_version, text=True)
return ANDROID_BUILD_TOP + "/prebuilts/clang/host/linux-x86/clang-" + version_output.strip()
return ANDROID_BUILD_TOP + "/prebuilts/clang/host/linux-x86/" + version_output.strip()
else:
return None