aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-01-02 07:55:53 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-01-02 11:02:21 +0300
commit2113853bafe637a55a531498f63158dacf11320a (patch)
tree3dd209101cf8916097e57f58299668c9c81b5c5f
parentworkflows/test.yml: remove redundant flags (diff)
downloadsetup-gcc-2113853bafe637a55a531498f63158dacf11320a.tar.gz
setup-gcc-2113853bafe637a55a531498f63158dacf11320a.zip
set up cc/c++ executables
-rw-r--r--.github/workflows/test.yml10
-rw-r--r--action.yml41
2 files changed, 49 insertions, 2 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index ffffe70..2dcc535 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -85,3 +85,13 @@ jobs:
Unexpected output:
$actual
"@)
+
+ # Is this really the most stable piece of `gcc --version` output?
+ - name: Check cc/c++
+ run: |
+ $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")
+ $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")
diff --git a/action.yml b/action.yml
index b05f777..8b2a038 100644
--- a/action.yml
+++ b/action.yml
@@ -14,8 +14,7 @@ inputs:
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
@@ -33,6 +32,38 @@ runs:
}
}
+ function Make-Link {
+ param(
+ [Parameter(Mandatory=$true)]
+ [string] $ExeName,
+ [Parameter(Mandatory=$true)]
+ [string] $LinkName
+ )
+
+ $exe_path = (Get-Command $ExeName).Path
+ $exe_dir = Split-Path $exe_path
+ $exe_name = Split-Path $exe_path -Leaf
+ if (!$exe_name.StartsWith($ExeName)) {
+ throw "'$exe_name' must start with '$ExeName'"
+ }
+ $ext = $exe_name.Substring($ExeName.Length)
+
+ $link_dir = if ($script:linux_host) { '/usr/local/bin' } else { $exe_dir }
+ $link_name = $LinkName + $ext
+ $link_path = Join-Path $link_dir $link_name
+
+ echo "Creating link '$link_path', pointing to '$exe_path'"
+ if ($script:linux_host) {
+ sudo rm -f -- $link_path
+ sudo ln -s -- $exe_path $link_path
+ } else {
+ if (Test-Path $link_path) {
+ Remove-Item $link_path -Force
+ }
+ New-Item -ItemType HardLink -Path $link_path -Value $exe_path | Out-Null
+ }
+ }
+
if ($linux_host) {
sudo apt update
if ($x64) {
@@ -40,6 +71,9 @@ runs:
} else {
sudo apt install -y g++-multilib
}
+
+ Make-Link -Exe gcc -LinkName cc
+ Make-Link -Exe g++ -LinkName c++
} elseif ($cygwin_host) {
if (!$x64) {
echo @'
@@ -51,6 +85,9 @@ runs:
}
$choco = Locate-Choco
& $choco install -y --no-progress --source=cygwin gcc-g++
+
+ Make-Link -Exe gcc -LinkName cc
+ Make-Link -Exe g++ -LinkName c++
} elseif ($windows_host) {
# TODO: use setup-mingw when calling composite actions within
# composite actions is implemented.