aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/action.yml
diff options
context:
space:
mode:
Diffstat (limited to 'action.yml')
-rw-r--r--action.yml41
1 files changed, 39 insertions, 2 deletions
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.