-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathResolve-SodiumRuntimeIdentifier.ps1
More file actions
65 lines (60 loc) · 2.19 KB
/
Copy pathResolve-SodiumRuntimeIdentifier.ps1
File metadata and controls
65 lines (60 loc) · 2.19 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
function Resolve-SodiumRuntimeIdentifier {
<#
.SYNOPSIS
Resolves the native Sodium runtime identifier.
.DESCRIPTION
Maps the active operating system and process architecture to the runtime identifier used by the bundled native library.
#>
[OutputType([string])]
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[System.Runtime.InteropServices.Architecture] $ProcessArchitecture,
[Parameter()]
[switch] $Linux,
[Parameter()]
[switch] $MacOS,
[Parameter()]
[switch] $Windows
)
process {
switch ($true) {
$Linux {
switch ($ProcessArchitecture) {
'Arm64' { return 'linux-arm64' }
'X64' { return 'linux-x64' }
default {
$message = "Unsupported Linux process architecture: $ProcessArchitecture. " +
'Please refer to the documentation for supported architectures.'
throw $message
}
}
}
$MacOS {
switch ($ProcessArchitecture) {
'Arm64' { return 'osx-arm64' }
'X64' { return 'osx-x64' }
default {
$message = "Unsupported macOS process architecture: $ProcessArchitecture. " +
'Please refer to the documentation for supported architectures.'
throw $message
}
}
}
$Windows {
switch ($ProcessArchitecture) {
'X64' { return 'win-x64' }
'X86' { return 'win-x86' }
default {
$message = "Unsupported Windows process architecture: $ProcessArchitecture. " +
'Please refer to the documentation for supported architectures.'
throw $message
}
}
}
default {
throw 'Unsupported platform. Please refer to the documentation for more information.'
}
}
}
}