diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-01-02 12:39:35 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-01-02 12:39:35 +0300 |
commit | a8f5b76c71b03515376d3beb349cd8811a0c6fa5 (patch) | |
tree | 8d922f639b1cd12568d24f763138d76397e62afe | |
parent | refactoring (diff) | |
download | setup-gcc-a8f5b76c71b03515376d3beb349cd8811a0c6fa5.tar.gz setup-gcc-a8f5b76c71b03515376d3beb349cd8811a0c6fa5.zip |
refactoring
-rw-r--r-- | action.yml | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -52,7 +52,7 @@ runs: } } - function Make-Link { + function Link-Exe { param( [Parameter(Mandatory=$true)] [string] $ExeName, @@ -60,16 +60,18 @@ runs: [string] $LinkName ) + # Full executable path, including the extension: $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) + $exe_ext = [System.IO.Path]::GetExtension($exe_name) $link_dir = if ($script:linux_host) { '/usr/local/bin' } else { $exe_dir } - $link_name = $LinkName + $ext + $link_name = $LinkName + # On Windows, append .exe if required: + if (!$script:linux_host -and [System.IO.Path]::GetExtension($link_name) -ne $exe_ext) { + $link_name += $exe_ext + } $link_path = Join-Path $link_dir $link_name echo "Creating link '$link_path', pointing to '$exe_path'" @@ -87,8 +89,8 @@ runs: if ($linux_host) { $pkg = if ($x64) { 'g++' } else { 'g++-multilib' } Install-Package $pkg - Make-Link -Exe gcc -LinkName cc - Make-Link -Exe g++ -LinkName c++ + Link-Exe -Exe gcc -LinkName cc + Link-Exe -Exe g++ -LinkName c++ } elseif ($cygwin_host) { if (!$x64) { echo @' @@ -99,8 +101,8 @@ runs: '@ } Install-Package gcc-g++ - Make-Link -Exe gcc -LinkName cc - Make-Link -Exe g++ -LinkName c++ + Link-Exe -Exe gcc -LinkName cc + Link-Exe -Exe g++ -LinkName c++ } elseif ($windows_host) { # TODO: use setup-mingw when calling composite actions within # composite actions is implemented. |