aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-01-02 11:23:01 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-01-02 11:59:08 +0300
commitc669dcf1e756407b8b0bf94133de5ad244b40085 (patch)
treef6057cdd256a0dd24283db79876ddb0d11842d51
parentset up cc/c++ executables (diff)
downloadsetup-gcc-c669dcf1e756407b8b0bf94133de5ad244b40085.tar.gz
setup-gcc-c669dcf1e756407b8b0bf94133de5ad244b40085.zip
refactoring
Diffstat (limited to '')
-rw-r--r--action.yml33
1 files changed, 23 insertions, 10 deletions
diff --git a/action.yml b/action.yml
index 8b2a038..9c57887 100644
--- a/action.yml
+++ b/action.yml
@@ -32,6 +32,26 @@ runs:
}
}
+ function Install-Package {
+ param(
+ [Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)]
+ [string[]] $Packages
+ )
+
+ if ($script:linux_host) {
+ sudo apt-get update -yq
+ sudo apt-get install -yq --no-install-recommends $Packages
+ } elseif ($script:cygwin_host) {
+ $choco = Locate-Choco
+ & $choco install -y --no-progress --source=cygwin $Packages
+ } elseif ($script:windows_host) {
+ $choco = Locate-Choco
+ & $choco install -y --no-progress $Packages
+ } else {
+ throw "Sorry, installing packages is unsupported on $script:os"
+ }
+ }
+
function Make-Link {
param(
[Parameter(Mandatory=$true)]
@@ -65,13 +85,8 @@ runs:
}
if ($linux_host) {
- sudo apt update
- if ($x64) {
- sudo apt install -y g++
- } else {
- sudo apt install -y g++-multilib
- }
-
+ $pkg = if ($x64) { 'g++' } else { 'g++-multilib' }
+ Install-Package $pkg
Make-Link -Exe gcc -LinkName cc
Make-Link -Exe g++ -LinkName c++
} elseif ($cygwin_host) {
@@ -83,9 +98,7 @@ runs:
If you _are_ using 32-bit Cygwin, you can ignore this message.
'@
}
- $choco = Locate-Choco
- & $choco install -y --no-progress --source=cygwin gcc-g++
-
+ Install-Package gcc-g++
Make-Link -Exe gcc -LinkName cc
Make-Link -Exe g++ -LinkName c++
} elseif ($windows_host) {