From 75f1814c22aaa83e7aff4286abbefa508d59360a Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Wed, 10 Jul 2024 18:09:42 -0300 Subject: [PATCH] docs: generate files script looks for versioned compiler executables --- .github/workflows/ci.yml | 11 ----------- doc/generate-files.mjs | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a73b4cf3c..c517f82c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/doc/generate-files.mjs b/doc/generate-files.mjs index a6665a989..7c0fd4877 100644 --- a/doc/generate-files.mjs +++ b/doc/generate-files.mjs @@ -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; } }