diff --git a/.github/actions/build-foo-cygwin/action.yml b/.github/actions/build-foo-cygwin/action.yml index 5f110c5..08fb820 100644 --- a/.github/actions/build-foo-cygwin/action.yml +++ b/.github/actions/build-foo-cygwin/action.yml @@ -1,5 +1,9 @@ name: Build foo.exe description: Build foo.exe (on Cygwin) +inputs: + platform: + description: Target platform + required: true runs: using: composite steps: @@ -10,6 +14,7 @@ runs: echo "$src_dir" src_dir="$( cygpath -ua "$src_dir" )" cd -- "$src_dir" - clang++ --version - clang++ -std=c++14 -o foo.exe foo.cpp + arch= + [ '${{ matrix.platform }}' == 'x86' ] && arch=-m32 + clang++ $arch -std=c++14 -o foo.exe foo.cpp shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}' diff --git a/.github/actions/build-foo/action.yml b/.github/actions/build-foo/action.yml index 36fc650..c86fecb 100644 --- a/.github/actions/build-foo/action.yml +++ b/.github/actions/build-foo/action.yml @@ -1,10 +1,9 @@ name: Build foo.exe description: Build foo.exe inputs: - binary: - description: Compiler binary file name + version: + description: Version to use required: false - default: clang++ platform: description: Target platform required: true @@ -24,5 +23,5 @@ runs: $flags += '-lpthread' } - & '${{ inputs.binary }}' $flags + & "clang++$version" $flags shell: pwsh diff --git a/.github/actions/check-cc-cygwin/action.yml b/.github/actions/check-cc-cygwin/action.yml index 432d1b8..f536649 100644 --- a/.github/actions/check-cc-cygwin/action.yml +++ b/.github/actions/check-cc-cygwin/action.yml @@ -1,5 +1,5 @@ -name: Check symlinks -description: Check symlinks (on Cygwin) +name: Check cc/c++ +description: Check cc/c++ (on Cygwin) runs: using: composite steps: diff --git a/.github/actions/check-cc/action.yml b/.github/actions/check-cc/action.yml index aef6d9c..1e5b988 100644 --- a/.github/actions/check-cc/action.yml +++ b/.github/actions/check-cc/action.yml @@ -1,5 +1,5 @@ -name: Check symlinks -description: Check symlinks +name: Check cc/c++ +description: Check cc/c++ inputs: version: description: Specific version to check @@ -28,7 +28,5 @@ runs: } Check-Exe cc - Check-Exe clang Check-Exe c++ - Check-Exe clang++ shell: pwsh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ef8b17..ea75fb4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,14 +13,14 @@ jobs: strategy: matrix: platform: [x86, x64] - os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022] + os: [ubuntu-18.04, ubuntu-20.04, ubuntu-latest, windows-2016, windows-2019, windows-latest] runs-on: '${{ matrix.os }}' name: 'Test: ${{ matrix.os }} / ${{ matrix.platform }}' steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v2 - name: Clean up PATH - uses: egor-tensin/cleanup-path@v3 + uses: egor-tensin/cleanup-path@v1 if: runner.os == 'Windows' - name: Set up Clang uses: ./ @@ -31,38 +31,24 @@ jobs: uses: ./.github/actions/build-foo - name: Run foo.exe uses: ./.github/actions/run-foo - - name: Check symlinks + - name: Check cc/c++ uses: ./.github/actions/check-cc versions: strategy: matrix: - os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04] - version: ['3.9', '4.0', 4, '5.0', 5, '6.0', 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] + os: [ubuntu-18.04, ubuntu-20.04] + version: ['3.9', '4.0', '5.0', '6.0', 7, 8, 9, 10, 11, 12] exclude: - {os: ubuntu-20.04, version: '3.9'} - {os: ubuntu-20.04, version: '4.0'} - - {os: ubuntu-20.04, version: 4} - {os: ubuntu-20.04, version: '5.0'} - - {os: ubuntu-20.04, version: 5} - - {os: ubuntu-22.04, version: '3.9'} - - {os: ubuntu-22.04, version: '4.0'} - - {os: ubuntu-22.04, version: 4} - - {os: ubuntu-22.04, version: '5.0'} - - {os: ubuntu-22.04, version: 5} - - {os: ubuntu-22.04, version: '6.0'} - - {os: ubuntu-22.04, version: 6} - - {os: ubuntu-22.04, version: 7} - - {os: ubuntu-22.04, version: 8} - - {os: ubuntu-22.04, version: 9} - - {os: ubuntu-22.04, version: 10} runs-on: '${{ matrix.os }}' name: 'Version: ${{ matrix.os }} / ${{ matrix.version }}' steps: - name: Checkout - uses: actions/checkout@v3 - - id: setup - name: Set up Clang + uses: actions/checkout@v2 + - name: Set up Clang uses: ./ with: version: '${{ matrix.version }}' @@ -71,10 +57,10 @@ jobs: - name: Build foo.exe uses: ./.github/actions/build-foo with: - binary: '${{ steps.setup.outputs.clangxx }}' + version: '${{ matrix.version }}' - name: Run foo.exe uses: ./.github/actions/run-foo - - name: Check symlinks + - name: Check cc/c++ uses: ./.github/actions/check-cc with: version: '${{ matrix.version }}' @@ -82,22 +68,23 @@ jobs: cygwin: strategy: matrix: + platform: [x86, x64] hardlinks: [0, 1] runs-on: windows-latest - name: 'Cygwin: hardlinks${{ matrix.hardlinks }}' - # As of January 2023, clang simply doesn't work on Cygwin. - # It's also marked "Unmaintained" in the installer. - continue-on-error: true + name: 'Cygwin: ${{ matrix.platform }} / hardlinks${{ matrix.hardlinks }}' steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v2 - name: Clean up PATH - uses: egor-tensin/cleanup-path@v3 + uses: egor-tensin/cleanup-path@v1 - name: Install Cygwin - uses: egor-tensin/setup-cygwin@v4 + uses: egor-tensin/setup-cygwin@v3 + with: + platform: '${{ matrix.platform }}' - name: Set up Clang uses: ./ with: + platform: '${{ matrix.platform }}' cygwin: 1 cc: 1 hardlinks: '${{ matrix.hardlinks }}' @@ -109,9 +96,9 @@ jobs: if: '!matrix.hardlinks' - name: Run foo.exe uses: ./.github/actions/run-foo - - name: Check symlinks + - name: Check cc/c++ uses: ./.github/actions/check-cc if: matrix.hardlinks - - name: Check symlinks + - name: Check cc/c++ on Cygwin uses: ./.github/actions/check-cc-cygwin if: '!matrix.hardlinks' diff --git a/README.md b/README.md index 9f7440b..62c7aaf 100644 --- a/README.md +++ b/README.md @@ -39,16 +39,11 @@ API | | *any* | | Install the i686 toolchain. | cygwin | *any* | ✓ | Install native binaries. | | 1 | | Install Cygwin packages. -| cc | 1 | ✓ | Set up `cc`/`clang`/`c++`/`clang++` executables. -| | *any* | | Don't set up the executables. +| cc | 1 | ✓ | Set up `cc`/`c++` executables. +| | *any* | | Don't set up `cc`/`c++`. | hardlinks | *any* | ✓ | Cygwin: don't convert any symlinks. | | 1 | | Cygwin: convert symlinks in /usr/bin to hardlinks. -| Output | Example | Description -| ------- | --------- | ----------- -| clang | clang-4.0 | `clang` binary name -| clangxx | clang++-7 | `clang++` binary name - Supported versions ------------------ @@ -61,26 +56,24 @@ The `version` parameter value is not checked for being an available version for the current distribution. The supported versions for a particular distribution are those found in that distro's repositories & those in the LLVM repository. -For example, you can find the list of available versions as of January 2023 -below. +For example, the supported versions for Bionic & Focal as of July 2021 are +listed below. -| `version` | Bionic | Focal | Jammy -| --------- | ------ | ----- | ----- -| 3.9 | ✓ | | -| 4.0 | ✓ | | -| 5.0 | ✓ | | -| 6.0 | ✓ | ✓ | -| 7 | ✓ | ✓ | -| 8 | ✓ | ✓ | -| 9 | ✓ | ✓ | -| 10 | ✓ | ✓ | -| 11 | ✓ | ✓ | ✓ -| 12 | ✓ | ✓ | ✓ -| 13 | ✓ | ✓ | ✓ -| 14 | ✓ | ✓ | ✓ -| 15 | ✓ | ✓ | ✓ +| `version` | Bionic | Focal +| --------- | ------ | ----- +| 3.9 | ✓ | +| 4.0 | ✓ | +| 5.0 | ✓ | +| 6.0 | ✓ | ✓ +| 7 | ✓ | ✓ +| 8 | ✓ | ✓ +| 9 | ✓ | ✓ +| 10 | ✓ | ✓ +| 11 | ✓ | ✓ +| 12 | ✓ | ✓ -This table should be updated periodically; it's a work-in-progress. +This table is not definitive; I expect more future versions to be made +available, especially for Focal. On Windows and Cygwin, the `version` parameter is ignored. diff --git a/action.yml b/action.yml index 511433d..f1b9a1b 100644 --- a/action.yml +++ b/action.yml @@ -15,7 +15,7 @@ inputs: required: false default: 0 cc: - description: Set up cc/clang/c++/clang++ executables + description: Set up cc/c++ executables required: false default: 1 hardlinks: @@ -75,6 +75,15 @@ runs: } } + function Get-DistroVersion { + if (!(Get-Command lsb_release -ErrorAction SilentlyContinue)) { + throw "Couldn't find lsb_release; LLVM only provides repositories for Debian/Ubuntu" + } + $distro = lsb_release -is + $version = lsb_release -sr + "$distro-$version" + } + function Format-UpstreamVersion { param( [Parameter(Mandatory=$true)] @@ -83,9 +92,8 @@ runs: switch -Exact ($Version) { # Since version 7, they dropped the .0 suffix. The earliest - # version supported is 3.9 on Bionic; versions 4, 5 and 6 are - # mapped to LLVM-friendly 4.0, 5.0 and 6.0. - '4' { '4.0' } + # version supported is 5.0 on Bionic; versions 5 and 6 are + # mapped to LLVM-friendly 5.0 and 6.0. '5' { '5.0' } '6' { '6.0' } default { $Version } @@ -98,12 +106,25 @@ runs: [string] $Version ) - if (!(Get-Command lsb_release -ErrorAction SilentlyContinue)) { - throw "Couldn't find lsb_release; LLVM only provides repositories for Debian/Ubuntu" - } - $codename = lsb_release -sc + $distro = Get-DistroVersion - "deb http://apt.llvm.org/$codename/ llvm-toolchain-$codename-$Version main" + switch -Wildcard -CaseSensitive ($distro) { + 'Debian-9*' { "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-$Version main" } + 'Debian-10*' { "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-$Version main" } + 'Debian-11*' { "deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-$Version main" } + 'Debian-unstable' { "deb http://apt.llvm.org/unstable/ llvm-toolchain-$Version main" } + 'Debian-testing' { "deb http://apt.llvm.org/unstable/ llvm-toolchain-$Version main" } + 'Ubuntu-16.04' { "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-$Version main" } + 'Ubuntu-18.04' { "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-$Version main" } + 'Ubuntu-18.10' { "deb http://apt.llvm.org/cosmic/ llvm-toolchain-cosmic-$Version main" } + 'Ubuntu-19.04' { "deb http://apt.llvm.org/disco/ llvm-toolchain-disco-$Version main" } + 'Ubuntu-19.10' { "deb http://apt.llvm.org/eoan/ llvm-toolchain-eoan-$Version main" } + 'Ubuntu-20.04' { "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-$Version main" } + 'Ubuntu-20.10' { "deb http://apt.llvm.org/groovy/ llvm-toolchain-groovy-$Version main" } + 'Ubuntu-21.04' { "deb http://apt.llvm.org/hirsute/ llvm-toolchain-hirsute-$Version main" } + + default { throw "Unsupported distribution: $distro" } + } } function Add-UpstreamRepo { @@ -138,9 +159,8 @@ runs: if (!$x64) { $pkg_gxx = 'g++-multilib' } - $packages = $pkg_clang,$pkg_llvm,$pkg_gxx - Install-Package $packages + Install-Package $pkg_clang $pkg_llvm $pkg_gxx } elseif ($cygwin_host) { if (!$x64) { echo @' @@ -165,8 +185,8 @@ runs: throw "Sorry, installing Clang is unsupported on $os" } - echo "clang=$clang" >> $env:GITHUB_OUTPUT - echo "clangxx=$clangxx" >> $env:GITHUB_OUTPUT + echo "::set-output name=clang::$clang" + echo "::set-output name=clangxx::$clangxx" shell: pwsh - run: | @@ -178,9 +198,6 @@ runs: New-Variable cc -Value ('${{ inputs.cc }}' -eq '1') -Option Constant - New-Variable clang -Value '${{ steps.install.outputs.clang }}' -Option Constant - New-Variable clangxx -Value '${{ steps.install.outputs.clangxx }}' -Option Constant - function Link-Exe { param( [Parameter(Mandatory=$true)] @@ -204,14 +221,8 @@ runs: } if ($cc) { - Link-Exe $clang cc - if ($clang -ne 'clang') { - Link-Exe $clang 'clang' - } - Link-Exe $clangxx c++ - if ($clangxx -ne 'clang++') { - Link-Exe $clangxx 'clang++' - } + Link-Exe '${{ steps.install.outputs.clang }}' cc + Link-Exe '${{ steps.install.outputs.clangxx }}' c++ } shell: pwsh