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
|
if: matrix.cygwin
|
||||||
|
|
||||||
- name: Set up Clang
|
- name: Set up Clang
|
||||||
id: setup
|
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
platform: '${{ matrix.platform }}'
|
platform: '${{ matrix.platform }}'
|
||||||
|
@ -65,16 +64,14 @@ jobs:
|
||||||
$flags += '-m32'
|
$flags += '-m32'
|
||||||
}
|
}
|
||||||
$flags += @(
|
$flags += @(
|
||||||
'-x', 'c++',
|
|
||||||
'-std=c++14',
|
'-std=c++14',
|
||||||
'-o', 'foo.exe',
|
'-o', 'foo.exe',
|
||||||
'foo.cpp',
|
'foo.cpp'
|
||||||
'-lstdc++'
|
|
||||||
)
|
)
|
||||||
if ('${{ runner.os }}' -eq 'Linux') {
|
if ('${{ runner.os }}' -eq 'Linux') {
|
||||||
$flags += '-lpthread'
|
$flags += '-lpthread'
|
||||||
}
|
}
|
||||||
& '${{ steps.setup.outputs.clangxx }}' $flags
|
clang++ $flags
|
||||||
|
|
||||||
- name: Run foo.exe
|
- name: Run foo.exe
|
||||||
run: |
|
run: |
|
||||||
|
|
54
action.yml
54
action.yml
|
@ -11,19 +11,10 @@ inputs:
|
||||||
required: false
|
required: false
|
||||||
default: 0
|
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:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- id: setup
|
- run: |
|
||||||
run: |
|
|
||||||
New-Variable os -Value '${{ runner.os }}' -Option Constant
|
New-Variable os -Value '${{ runner.os }}' -Option Constant
|
||||||
|
|
||||||
New-Variable linux_host -Value ($os -eq 'Linux') -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) {
|
if ($linux_host) {
|
||||||
sudo apt update
|
sudo apt update
|
||||||
if ($x64) {
|
if ($x64) {
|
||||||
|
@ -48,9 +51,6 @@ runs:
|
||||||
} else {
|
} else {
|
||||||
sudo apt install -y clang g++-multilib
|
sudo apt install -y clang g++-multilib
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "::set-output name=clang::clang"
|
|
||||||
echo "::set-output name=clangxx::clang++"
|
|
||||||
} elseif ($cygwin_host) {
|
} elseif ($cygwin_host) {
|
||||||
if (!$x64) {
|
if (!$x64) {
|
||||||
echo @'
|
echo @'
|
||||||
|
@ -63,25 +63,29 @@ runs:
|
||||||
$choco = Locate-Choco
|
$choco = Locate-Choco
|
||||||
|
|
||||||
# IDK why, but without libiconv-devel, even a "Hello, world!"
|
# IDK why, but without libiconv-devel, even a "Hello, world!"
|
||||||
# C++ app cannot be compiled as of December 2020.
|
# C++ app cannot be compiled as of December 2020. Also, libstdc++
|
||||||
# Also, libstdc++ is required, and for simplicity's sake, gcc-g++
|
# is required; it's simpler to install gcc-g++ for all the
|
||||||
# is installed.
|
# dependencies.
|
||||||
& $choco install -y --no-progress --source=cygwin clang libiconv-devel gcc-g++
|
& $choco install -y --no-progress --source=cygwin clang libiconv-devel gcc-g++
|
||||||
|
|
||||||
# clang/clang++ are symlinks on Cygwin, pointing to clang-VERSION.exe.
|
# clang/clang++ are Cygwin symlinks, pointing to clang-X.exe. It's
|
||||||
$clang = cygpath.exe -wa (readlink.exe --canonicalize-existing /usr/bin/clang)
|
# convenient to make proper executables instead so that they can be
|
||||||
$clangxx = cygpath.exe -wa (readlink.exe --canonicalize-existing /usr/bin/clang++)
|
# called from Windows' command prompt.
|
||||||
|
find.exe /usr/bin -iname 'clang*' -type l | %{
|
||||||
echo "::set-output name=clang::$clang"
|
$link_path = $_
|
||||||
echo "::set-output name=clangxx::$clangxx"
|
$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) {
|
} elseif ($windows_host) {
|
||||||
$choco = Locate-Choco
|
$choco = Locate-Choco
|
||||||
|
|
||||||
& $choco install -y --no-progress llvm
|
& $choco install -y --no-progress llvm
|
||||||
echo (Join-Path $env:ProgramFiles LLVM bin) >> $env:GITHUB_PATH
|
echo (Join-Path $env:ProgramFiles LLVM bin) >> $env:GITHUB_PATH
|
||||||
|
|
||||||
echo "::set-output name=clang::clang"
|
|
||||||
echo "::set-output name=clangxx::clang++"
|
|
||||||
} else {
|
} else {
|
||||||
throw "Sorry, installing Clang is unsupported on $os"
|
throw "Sorry, installing Clang is unsupported on $os"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue