aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-01-07 13:19:35 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-01-07 13:33:00 +0300
commitbccca58731cba4be574a3106820dad9b540da858 (patch)
treec6a273b537c7d6ff50a948cdb87fbd6424c3addf
parentsetting up cc is optional now (diff)
downloadsetup-gcc-bccca58731cba4be574a3106820dad9b540da858.tar.gz
setup-gcc-bccca58731cba4be574a3106820dad9b540da858.zip
Cygwin: option to convert symlinks to hardlinks
Diffstat (limited to '')
-rw-r--r--.github/workflows/test.yml28
-rw-r--r--README.md18
-rw-r--r--action.yml29
3 files changed, 66 insertions, 9 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 509f0b4..b30d245 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -15,6 +15,7 @@ jobs:
matrix:
platform: [x86, x64]
cygwin: [0, 1]
+ hardlinks: [0, 1]
os: [ubuntu-18.04, windows-2019]
include:
@@ -27,10 +28,12 @@ jobs:
# This action is not suitable for Windows hosts, use setup-mingw for
# that.
- {os: windows-2019, cygwin: 0}
+ # Only test hardlinks on Cygwin.
+ - {cygwin: 0, hardlinks: 1}
runs-on: '${{ matrix.os }}'
- name: '${{ matrix.name }} / ${{ matrix.platform }}'
+ name: '${{ matrix.name }} / ${{ matrix.platform }} / Hardlinks: ${{ matrix.hardlinks }}'
defaults:
run:
@@ -56,6 +59,7 @@ jobs:
platform: '${{ matrix.platform }}'
cygwin: '${{ matrix.cygwin }}'
cc: 1
+ hardlinks: '${{ matrix.hardlinks }}'
- name: Build foo.exe
run: |
@@ -68,6 +72,15 @@ jobs:
$flags += '-lpthread'
}
g++ $flags
+ if: '!matrix.cygwin || matrix.hardlinks'
+
+ - name: Build foo.exe on Cygwin
+ run: |
+ $cwd = cygpath.exe -ua (Get-Location)
+ $arch = if ('${{ matrix.platform }}' -eq 'x64') { '-m64' } else { '-m32' }
+ $cmd = printf.exe -- 'cd %q && g++ %q -std=c++14 -o foo foo.cpp' $cwd $arch
+ bash.exe --login -o errexit -c $cmd
+ if: matrix.cygwin && !matrix.hardlinks
- name: Run foo.exe
run: |
@@ -88,9 +101,22 @@ jobs:
# Is this really the most stable piece of `gcc --version` output?
- name: Check cc/c++
run: |
+ echo (Get-Command cc).Path
$cc = & cc --version
echo $cc
$($cc | Select-String -Pattern "This is free software; see the source for copying conditions." -SimpleMatch -Quiet) -or $(throw "Unexpected `cc --version` output")
+ echo (Get-Command c++).Path
$cxx = & c++ --version
echo $cxx
$($cxx | Select-String -Pattern "This is free software; see the source for copying conditions." -SimpleMatch -Quiet) -or $(throw "Unexpected `c++ --version` output")
+ if: '!matrix.cygwin || matrix.hardlinks'
+
+ - name: Check cc/c++ on Cygwin
+ run: |
+ $cc = bash.exe --login -o errexit -c 'cc --version'
+ echo $cc
+ $($cc | Select-String -Pattern "This is free software; see the source for copying conditions." -SimpleMatch -Quiet) -or $(throw "Unexpected `cc --version` output")
+ $cxx = bash.exe --login -o errexit -c 'c++ --version'
+ echo $cxx
+ $($cxx | Select-String -Pattern "This is free software; see the source for copying conditions." -SimpleMatch -Quiet) -or $(throw "Unexpected `c++ --version` output")
+ if: matrix.cygwin && !matrix.hardlinks
diff --git a/README.md b/README.md
index 882b4be..8cb7796 100644
--- a/README.md
+++ b/README.md
@@ -30,14 +30,16 @@ Disable this by setting the `cc` parameter to `0`.
API
---
-| Input | Value | Default | Description
-| -------- | ------- | ------- | -----------
-| platform | x64 | Yes | Install the x86_64 toolchain.
-| | *Other* | No | Install the i686 toolchain.
-| cygwin | 1 | No | Install Cygwin packages.
-| | *Other* | Yes | Install native binaries.
-| cc | 1 | Yes | Set up `cc`/`c++` executables.
-| | *Other* | No | Don't set up `cc`/`c++`.
+| Input | Value | Default | Description
+| --------- | ------- | ------- | -----------
+| platform | x64 | Yes | Install the x86_64 toolchain.
+| | *Other* | No | Install the i686 toolchain.
+| cygwin | 1 | No | Install Cygwin packages.
+| | *Other* | Yes | Install native binaries.
+| cc | 1 | Yes | Set up `cc`/`c++` executables.
+| | *Other* | No | Don't set up `cc`/`c++`.
+| hardlinks | *Other* | Yes | Cygwin: don't convert any symlinks.
+| | 1 | No | Cygwin: convert symlinks in /usr/bin to hardlinks.
License
-------
diff --git a/action.yml b/action.yml
index ec7170c..acc886e 100644
--- a/action.yml
+++ b/action.yml
@@ -14,6 +14,10 @@ inputs:
description: Set up cc/c++ executables
required: false
default: 1
+ hardlinks:
+ description: On Cygwin, replace executable symlinks with hardlinks
+ required: false
+ default: 0
runs:
using: composite
@@ -120,6 +124,31 @@ runs:
}
shell: pwsh
+ - run: |
+ New-Variable cygwin_host -Value ('${{ inputs.cygwin }}' -eq '1') -Option Constant
+ New-Variable hardlinks -Value ('${{ inputs.hardlinks }}' -eq '1') -Option Constant
+
+ if ($cygwin_host -and $hardlinks) {
+ 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/local/bin /usr/bin \
+ -type l '-(' \
+ -path /usr/local/bin/cc -o \
+ -path /usr/local/bin/c++ \
+ '-)' -print0 )
+ '@ | & bash.exe --login -o errexit -o nounset -o pipefail -o igncr
+ }
+ shell: pwsh
+
branding:
icon: star
color: green