aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-01-04 13:20:30 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-01-04 13:21:43 +0300
commitc22ffb6ba196ce17f8b2b3ed72f3e0139c524668 (patch)
tree1df619d604821e7a54d5f3c110d6da300d9b1667
parenttweak output a little (diff)
downloadsetup-clang-c22ffb6ba196ce17f8b2b3ed72f3e0139c524668.tar.gz
setup-clang-c22ffb6ba196ce17f8b2b3ed72f3e0139c524668.zip
replace Fix-CygwinLink with a shorter bash script
-rw-r--r--action.yml62
1 files changed, 19 insertions, 43 deletions
diff --git a/action.yml b/action.yml
index ab9fa1a..75b658e 100644
--- a/action.yml
+++ b/action.yml
@@ -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: