Skip to content

Commit

Permalink
docs: generate files script looks for versioned compiler executables
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Jul 10, 2024
1 parent 2d35d94 commit 75f1814
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,6 @@ jobs:
compiler: clang
version: 18

- name: Set environment variables
run: |
set -x
clangpp_path="$(which clang++-18)"
clang_path="$(which clang-18)"
echo "CXX_COMPILER=$clangpp_path" >> $GITHUB_ENV
echo "CXX=$clang_path" >> $GITHUB_ENV
echo "C_COMPILER=$clang_path" >> $GITHUB_ENV
echo "CC=$clang_path" >> $GITHUB_ENV
git config --global --add safe.directory "$(pwd)"
- name: Build Antora Docs
run: |
cd doc
Expand Down
33 changes: 30 additions & 3 deletions doc/generate-files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,37 @@ function findExecutable(executableName) {
}
try {
const whichCommand = (process.platform === 'win32') ? 'where' : 'which';
const cmd = `${whichCommand} ${executableName}`
return execSync(cmd, {encoding: 'utf-8'}).trim()
const cmd = `${whichCommand} ${executableName}`;
let result = execSync(cmd, { encoding: 'utf-8' }).trim();
if (result) {
return result;
}
} catch (error) {
return undefined
// continue to version search
}
try {
const whichCommand = (process.platform === 'win32') ? 'where' : 'which -a';
const versionedCmd = `${whichCommand} ${executableName}*`;
const versionedResults = execSync(versionedCmd, { encoding: 'utf-8' }).trim().split('\n').map(r => r.trim());

const versionRegex = new RegExp(`${executableName}-(\\d+)`);
let highestVersion = 0;
let bestMatch = undefined;

for (const result of versionedResults) {
const match = path.basename(result).match(versionRegex);
if (match) {
const version = parseInt(match[1], 10);
if (version > highestVersion) {
highestVersion = version;
bestMatch = result;
}
}
}

return bestMatch;
} catch (error) {
return undefined;
}
}

Expand Down

0 comments on commit 75f1814

Please sign in to comment.