Jake Egan d9db266499
[PowerPC][test] Catch any exception when retrieving git revision (#92004)
This makes the `vc-rev-enabled` feature unsupported if we fail to
retrieve the git revision for any reason, such as if git is not
installed.
2024-05-14 10:32:30 -04:00

24 lines
722 B
INI

if not "PowerPC" in config.root.targets:
config.unsupported = True
import subprocess
config.suffixes.add(".py")
def get_revision(repo_path):
cmd = ['git', '-C', repo_path, 'rev-parse', 'HEAD']
try:
return subprocess.run(cmd, stdout=subprocess.PIPE, check=True).stdout.decode()
except Exception as e:
print("An error occurred retrieving the git revision:", e)
return None
if config.have_vc_rev:
if config.force_vc_rev:
git_revision = config.force_vc_rev
else:
git_revision = get_revision(config.llvm_src_root)
if git_revision:
config.substitutions.append(("git-revision", git_revision))
config.available_features.add("vc-rev-enabled")