-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
73 lines (65 loc) · 2.69 KB
/
action.yml
File metadata and controls
73 lines (65 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: 'Setup C/C++'
description: 'Sets up a C/C++ build environment'
inputs:
compiler-id:
description: 'Desired CMake compiler ID to use'
required: false
compiler-version:
description: 'Desired compiler version to use'
required: false
default: 'latest'
compiler-arch:
description: 'Desired compiler architecture'
required: false
default: 'amd64'
outputs:
compiler-id:
description: 'Detected CMake compiler ID'
value: ${{ steps.determine-compiler.outputs.compiler-id }}
compiler-version:
description: 'Detected compiler version'
value: ${{ steps.determine-compiler.outputs.compiler-version }}
runs:
using: composite
steps:
- run: echo "##[add-matcher]${{ github.action_path }}/gcc-matcher.json"
shell: bash
- name: Setup Visual Studio Developer Command Prompt
if: ${{ runner.os == 'Windows' && inputs.compiler-id == 'MSVC' }}
shell: pwsh
run: |
echo "##[add-matcher]${{ github.action_path }}/msvc-matcher.json"
$hostArch = switch ("${Env:PROCESSOR_ARCHITECTURE}") {
"AMD64" { "amd64" }
"ARM64" { Write-Error -Message "ARM64 is not a valid host architecture" -ErrorAction Stop }
default { "x86" }
}
$targetArch = switch ("${{ inputs.compiler-arch }}") {
"amd64" { "amd64" }
"arm64" { "arm64" }
"x86" { "x86" }
default { Write-Error -Message "Unsupported target architecture $_" -ErrorAction Stop }
}
$vsWhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installationPath = & $vsWhere -prerelease -latest -property installationPath
if ($installationPath -and (test-path "$installationPath\Common7\Tools\vsdevcmd.bat")) {
& "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -no_logo -host_arch=$hostArch -arch=$targetArch && set" | foreach-object {
$name, $value = $_ -split '=', 2
$currentValue = if (Test-Path -Path "env:\$name") { (Get-Item -Path "env:\$name").Value } else { $null }
if ($value -ne $currentValue) {
if ($name -eq 'PATH') {
echo "$value" >> "${Env:GITHUB_PATH}"
} else {
echo "$name=$value" >> "${Env:GITHUB_ENV}"
}
}
}
}
- name: Determine installed compiler and version
id: determine-compiler
shell: bash
run: |
awk -f- <(cmake --system-information) >> "$GITHUB_OUTPUT" << "EOF"
$1 == "CMAKE_CXX_COMPILER_ID" { gsub(/"/, "", $2); print "compiler-id=" $2 }
$1 == "CMAKE_CXX_COMPILER_VERSION" { gsub(/"/, "", $2); print "compiler-version=" $2 }
EOF