diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-01-04 13:20:30 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-01-04 13:21:43 +0300 |
commit | c22ffb6ba196ce17f8b2b3ed72f3e0139c524668 (patch) | |
tree | 1df619d604821e7a54d5f3c110d6da300d9b1667 | |
parent | tweak output a little (diff) | |
download | setup-clang-c22ffb6ba196ce17f8b2b3ed72f3e0139c524668.tar.gz setup-clang-c22ffb6ba196ce17f8b2b3ed72f3e0139c524668.zip |
replace Fix-CygwinLink with a shorter bash script
Diffstat (limited to '')
-rw-r--r-- | action.yml | 62 |
1 files changed, 19 insertions, 43 deletions
@@ -86,44 +86,6 @@ runs: } } - function Convert-CygwinPath { - # Like cygpath -wa, but don't resolve symlinks. - param( - [Parameter(Mandatory=$true)] - [string] $Path - ) - - $realpath = realpath.exe --no-symlinks -- $Path - $dirname = dirname.exe -- $realpath - $dirname = cygpath.exe -wa $dirname - Join-Path $dirname (Split-Path $realpath -Leaf) - } - - function Fix-CygwinLink { - # Replace a Cygwin symlink with a hardlink. - param( - [Parameter(Mandatory=$true)] - [string] $Path - ) - - $link_path = $Path - $link_winpath = Convert-CygwinPath $link_path - $link_ext = [System.IO.Path]::GetExtension($link_path) - - $dest_path = readlink.exe --canonicalize-existing -- $link_path - $dest_winpath = Convert-CygwinPath $dest_path - $dest_ext = [System.IO.Path]::GetExtension($dest_path) - - echo "Removing symlink: $link_winpath" - Remove-Item $link_winpath -Force - - if ($dest_ext.ToLower() -ne $link_ext.ToLower()) { - $link_winpath += $dest_ext - } - echo "Creating hardlink '$link_winpath', pointing to '$dest_winpath'" - New-Item -ItemType HardLink -Path $link_winpath -Value $dest_winpath | Out-Null - } - if ($linux_host) { if ($x64) { $pkgs = 'clang','g++','llvm' @@ -150,11 +112,6 @@ runs: # dependencies. Install-Package clang gcc-g++ libiconv-devel llvm - # 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 -type l -a '-(' -iname 'clang*' -o -iname 'llvm*' '-)' | %{ Fix-CygwinLink $_ } - Link-Exe -Exe clang -LinkName cc Link-Exe -Exe clang++ -LinkName c++ } elseif ($windows_host) { @@ -168,6 +125,25 @@ runs: } else { throw "Sorry, installing Clang is unsupported on $os" } + + if ($cygwin_host) { + # 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. + echo @' + while IFS= read -d '' -r link_path; do + dest_path="$( readlink --canonicalize-existing -- "$link_path" )" + dest_ext=".${dest_path##*.}" + [ "$dest_ext" == ".$dest_path" ] && dest_ext= + link_ext=".${link_path##*.}" + [ "$link_ext" == ".$link_path" ] && link_ext= + echo "Removing symlink $link_path" && rm -f -- "$link_path" + [ "$link_ext" != "$dest_ext" ] && echo "${PATHEXT//\;/ + }" | grep -q --ignore-case --line-regexp -F -- "$dest_ext" && link_path="$link_path$dest_ext" + echo "Creating hardlink $link_path -> $dest_path" && ln -- "$dest_path" "$link_path" + done < <( find /usr/bin -type l -a '-(' -iname 'clang*' -o -iname 'llvm*' '-)' -print0 ) + '@ | & bash.exe --login -o errexit -o nounset -o pipefail -o igncr + } shell: pwsh branding: |