Cygwin: proper executables instead of symlinks
This commit is contained in:
parent
685da103bf
commit
60dbd57c3a
2 changed files with 31 additions and 30 deletions
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
|
@ -52,7 +52,6 @@ jobs:
|
|||
if: matrix.cygwin
|
||||
|
||||
- name: Set up Clang
|
||||
id: setup
|
||||
uses: ./
|
||||
with:
|
||||
platform: '${{ matrix.platform }}'
|
||||
|
@ -65,16 +64,14 @@ jobs:
|
|||
$flags += '-m32'
|
||||
}
|
||||
$flags += @(
|
||||
'-x', 'c++',
|
||||
'-std=c++14',
|
||||
'-o', 'foo.exe',
|
||||
'foo.cpp',
|
||||
'-lstdc++'
|
||||
'foo.cpp'
|
||||
)
|
||||
if ('${{ runner.os }}' -eq 'Linux') {
|
||||
$flags += '-lpthread'
|
||||
}
|
||||
& '${{ steps.setup.outputs.clangxx }}' $flags
|
||||
clang++ $flags
|
||||
|
||||
- name: Run foo.exe
|
||||
run: |
|
||||
|
|
54
action.yml
54
action.yml
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue