diff options
Diffstat (limited to '')
-rw-r--r-- | .github/workflows/test.yml | 1 | ||||
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | action.yml | 81 |
3 files changed, 47 insertions, 40 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59e4d1f..509f0b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,6 +55,7 @@ jobs: with: platform: '${{ matrix.platform }}' cygwin: '${{ matrix.cygwin }}' + cc: 1 - name: Build foo.exe run: | @@ -21,6 +21,9 @@ Use it in your workflow like this: Use `x86` if you want to build 32-bit binaries. * Set the `cygwin` parameter to `1` to set up GCC inside an existing Cygwin installation (you can set up Cygwin itself using my action [setup-cygwin]). +* `cc` and `c++` executables are set up, pointing to the `gcc` and `g++` +executables. +Disable this by setting the `cc` parameter to `0`. [setup-cygwin]: https://github.com/egor-tensin/setup-cygwin @@ -33,6 +36,8 @@ API | | *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++`. License ------- @@ -10,6 +10,10 @@ inputs: description: Install inside Cygwin required: false default: 0 + cc: + description: Set up cc/c++ executables + required: false + default: 1 runs: using: composite @@ -52,46 +56,9 @@ runs: } } - function Link-Exe { - param( - [Parameter(Mandatory=$true)] - [string] $ExeName, - [Parameter(Mandatory=$true)] - [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 - $exe_ext = [System.IO.Path]::GetExtension($exe_name) - - $link_dir = if ($script:linux_host) { '/usr/local/bin' } else { $exe_dir } - $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'" - 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) { $pkg = if ($x64) { 'g++' } else { 'g++-multilib' } Install-Package $pkg - - Link-Exe -Exe gcc -LinkName cc - Link-Exe -Exe g++ -LinkName c++ } elseif ($cygwin_host) { if (!$x64) { echo @' @@ -103,9 +70,6 @@ runs: } Install-Package gcc-g++ - - 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. @@ -119,6 +83,43 @@ runs: } shell: pwsh + - run: | + New-Variable os -Value '${{ runner.os }}' -Option Constant + + New-Variable linux_host -Value ($os -eq 'Linux') -Option Constant + New-Variable cygwin_host -Value ('${{ inputs.cygwin }}' -eq '1') -Option Constant + New-Variable windows_host -Value ($os -eq 'Windows' -and !$cygwin_host) -Option Constant + + New-Variable cc -Value ('${{ inputs.cc }}' -eq '1') -Option Constant + + function Link-Exe { + param( + [Parameter(Mandatory=$true)] + [string] $Exe, + [Parameter(Mandatory=$true)] + [string] $LinkName + ) + + $exe_path = (Get-Command $Exe).Path + $link_dir = if ($script:windows_host) { Split-Path $exe_path } else { '/usr/local/bin' } + $link_name = if ($script:windows_host) { "$LinkName.exe" } else { $LinkName } + $link_path = if ($script:cygwin_host) { "$link_dir/$link_name" } else { Join-Path $link_dir $link_name } + echo "Creating link $link_path -> $exe_path" + if ($script:linux_host) { + sudo ln -f -s $exe_path $link_path + } elseif ($script:cygwin_host) { + ln.exe -f -s $exe_path $link_path + } elseif ($script:windows_host) { + New-Item -ItemType HardLink -Path $link_path -Value $exe_path -Force | Out-Null + } + } + + if ($cc) { + Link-Exe gcc cc + Link-Exe g++ c++ + } + shell: pwsh + branding: icon: star color: green |