diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-01-01 12:14:10 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-01-02 06:52:11 +0300 |
commit | 60dbd57c3aff6b5c19ace5f88d9430f414394579 (patch) | |
tree | 52f76279b9603eb64895db724d7632e550654ef3 /action.yml | |
parent | Clang doesn't append .exe automatically (diff) | |
download | setup-clang-60dbd57c3aff6b5c19ace5f88d9430f414394579.tar.gz setup-clang-60dbd57c3aff6b5c19ace5f88d9430f414394579.zip |
Cygwin: proper executables instead of symlinks
Diffstat (limited to '')
-rw-r--r-- | action.yml | 54 |
1 files changed, 29 insertions, 25 deletions
@@ -11,19 +11,10 @@ inputs: required: false default: 0 -outputs: - clang: - description: clang executable name or path - value: '${{ steps.setup.outputs.clang }}' - clangxx: - description: clang++ executable name or path - value: '${{ steps.setup.outputs.clangxx }}' - runs: using: composite steps: - - id: setup - run: | + - run: | New-Variable os -Value '${{ runner.os }}' -Option Constant New-Variable linux_host -Value ($os -eq 'Linux') -Option Constant @@ -41,6 +32,18 @@ runs: } } + function Convert-CygwinPath { + # Like cygpath -wa, but don't resolve symlinks. + param( + [Parameter(Mandatory=$true)] + [string] $Path + ) + $Path = realpath.exe --no-symlinks -- $Path + $dirname = dirname.exe -- $Path + $dirname = cygpath.exe -wa $dirname + Join-Path $dirname (Split-Path $Path -Leaf) + } + if ($linux_host) { sudo apt update if ($x64) { @@ -48,9 +51,6 @@ runs: } else { sudo apt install -y clang g++-multilib } - - echo "::set-output name=clang::clang" - echo "::set-output name=clangxx::clang++" } elseif ($cygwin_host) { if (!$x64) { echo @' @@ -63,25 +63,29 @@ runs: $choco = Locate-Choco # IDK why, but without libiconv-devel, even a "Hello, world!" - # C++ app cannot be compiled as of December 2020. - # Also, libstdc++ is required, and for simplicity's sake, gcc-g++ - # is installed. + # C++ app cannot be compiled as of December 2020. Also, libstdc++ + # is required; it's simpler to install gcc-g++ for all the + # dependencies. & $choco install -y --no-progress --source=cygwin clang libiconv-devel gcc-g++ - # clang/clang++ are symlinks on Cygwin, pointing to clang-VERSION.exe. - $clang = cygpath.exe -wa (readlink.exe --canonicalize-existing /usr/bin/clang) - $clangxx = cygpath.exe -wa (readlink.exe --canonicalize-existing /usr/bin/clang++) - - echo "::set-output name=clang::$clang" - echo "::set-output name=clangxx::$clangxx" + # clang/clang++ are Cygwin symlinks, pointing to clang-X.exe. It's + # convenient to make proper executables instead so that they can be + # called from Windows' command prompt. + find.exe /usr/bin -iname 'clang*' -type l | %{ + $link_path = $_ + $dest_path = readlink.exe --canonicalize-existing -- $link_path + $link_winpath = Convert-CygwinPath $link_path + $dest_winpath = Convert-CygwinPath $dest_path + echo "Removing symlink: $link_winpath" + Remove-Item $link_winpath -Force + echo "Creating hardlink '$link_winpath.exe', pointing to '$dest_winpath'" + New-Item -ItemType HardLink -Path "$link_winpath.exe" -Value $dest_winpath | Out-Null + } } elseif ($windows_host) { $choco = Locate-Choco & $choco install -y --no-progress llvm echo (Join-Path $env:ProgramFiles LLVM bin) >> $env:GITHUB_PATH - - echo "::set-output name=clang::clang" - echo "::set-output name=clangxx::clang++" } else { throw "Sorry, installing Clang is unsupported on $os" } |