Skip to content

Commit

Permalink
better search for cl.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
st-pasha committed Nov 16, 2023
1 parent b950b2b commit f6a589a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: |
echo "DT_BUILD_ID=$((git rev-list --count origin/main) - 1)" >> $env:DT_BUILD_ID
if ($env:GITHUB_EVENT_NAME -eq 'pull_request') {
if ($env:GITHUB_PULL_REQUEST_HEAD_REPO_BRANCH -match '^rel-') {
if ($env:GITHUB_HEAD_REF -match '^rel-') {
echo "DT_RELEASE=True" >> $env:DT_RELEASE
} else {
echo "DT_BUILD_SUFFIX=PR$($env:GITHUB_EVENT_NUMBER).$env:DT_BUILD_ID" >> $env:DT_BUILD_SUFFIX
Expand All @@ -52,7 +52,7 @@ jobs:
echo "GITHUB_EVENT_NAME = $env:GITHUB_EVENT_NAME"
echo "GITHUB_EVENT_NUMBER = $env:GITHUB_EVENT_NUMBER"
echo "GITHUB_REF = $env:GITHUB_REF"
echo "GITHUB_PULL_REQUEST_HEAD_REPO_BRANCH = $env:GITHUB_PULL_REQUEST_HEAD_REPO_BRANCH"
echo "GITHUB_HEAD_REF = $env:GITHUB_HEAD_REF"
echo "GITHUB_CONTEXT = $env:GITHUB_CONTEXT"
echo "DT_HARNESS = $env:DT_HARNESS"
echo "DT_BUILD_ID = $env:DT_BUILD_ID"
Expand Down
41 changes: 19 additions & 22 deletions ci/xbuild/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,29 +182,26 @@ def _detect_compiler_executable(self):
"variable."
)

def print_path(path: pathlib.Path, indent: str):
for p in path.iterdir():
if p.is_dir():
self.log.info(p.name + '/', indent=indent)
print_path(p, indent + " ")
elif p.suffix.endswith('exe'):
self.log.info(p.name, indent=indent)

self.log.info(f"MSVC_path = {msvc_path}:")
print_path(pathlib.Path(msvc_path), indent = " ")
def find_bin_path(dir: pathlib.Path) -> pathlib.Path | None:
bin_path = dir / "bin" / "Hostx64" / "x64"
if bin_path.is_dir():
return bin_path
for subdir in dir.iterdir():
if subdir.is_dir():
found = find_bin_path(subdir)
if found:
return found

candidates = []
compiler_versions = next(os.walk(msvc_path))[1]
for compiler_version in reversed(compiler_versions):
path = os.path.join(msvc_path, compiler_version)
bin_path = os.path.join(path, "bin\\Hostx64\\x64")
if os.path.exists(os.path.join(bin_path, "cl.exe")):
candidates += [{
"compiler": os.path.join(bin_path, "cl.exe"),
"linker": os.path.join(bin_path, "link.exe"),
"path" : path
}]
candidates += [{"compiler": "cl.exe", "linker": "link.exe"}]
bin_path = find_bin_path(pathlib.Path(msvc_path))
if bin_path:
candidates += [{
"compiler": str(bin_path / "cl.exe"),
"linker": str(bin_path / "link.exe"),
"path" : str(bin_path.parent.parent.parent)
}]
else:
candidates += [{"compiler": "cl.exe", "linker": "link.exe"}]
elif sys.platform == "darwin":
candidates = [
{"compiler": "/usr/local/opt/llvm/bin/clang"},
Expand All @@ -226,7 +223,7 @@ def print_path(path: pathlib.Path, indent: str):
self.log.report_compiler_executable(candidate["compiler"])
return

self.log.info(f"Candidates: {candidates!r}")
self.log.info(f"Candidates tried: {candidates!r}")
raise RuntimeError("Suitable C++ compiler cannot be determined. "
"Please specify a compiler executable in the "
"`CXX` environment variable.")
Expand Down

0 comments on commit f6a589a

Please sign in to comment.