-
-
Notifications
You must be signed in to change notification settings - Fork 245
Expand file tree
/
Copy pathplatform-map.js
More file actions
84 lines (76 loc) · 1.82 KB
/
Copy pathplatform-map.js
File metadata and controls
84 lines (76 loc) · 1.82 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
74
75
76
77
78
79
80
81
82
83
84
"use strict";
const { platform, arch } = process;
const PLATFORM_MAP = {
"linux-x64-gnu": {
packageName: "cpd-linux-x64-gnu",
os: "linux",
cpu: "x64",
libc: "glibc",
rustTarget: "x86_64-unknown-linux-gnu",
runner: "ubuntu-latest",
},
"linux-arm64-gnu": {
packageName: "cpd-linux-arm64-gnu",
os: "linux",
cpu: "arm64",
libc: "glibc",
rustTarget: "aarch64-unknown-linux-gnu",
runner: "ubuntu-latest",
},
"linux-x64-musl": {
packageName: "cpd-linux-x64-musl",
os: "linux",
cpu: "x64",
libc: "musl",
rustTarget: "x86_64-unknown-linux-musl",
runner: "ubuntu-latest",
},
"darwin-arm64": {
packageName: "cpd-darwin-arm64",
os: "darwin",
cpu: "arm64",
rustTarget: "aarch64-apple-darwin",
runner: "macos-latest",
},
"darwin-x64": {
packageName: "cpd-darwin-x64",
os: "darwin",
cpu: "x64",
rustTarget: "x86_64-apple-darwin",
runner: "macos-13",
},
"windows-x64-msvc": {
packageName: "cpd-windows-x64-msvc",
os: "win32",
cpu: "x64",
rustTarget: "x86_64-pc-windows-msvc",
runner: "windows-latest",
},
};
function detectLinuxLibc() {
if (platform !== "linux") {
return undefined;
}
const report =
process.report && typeof process.report.getReport === "function"
? process.report.getReport()
: undefined;
if (report && report.header && report.header.glibcVersionRuntime) {
return "glibc";
}
return "musl";
}
function getPlatformKey() {
const libc = detectLinuxLibc();
for (const [key, target] of Object.entries(PLATFORM_MAP)) {
if (target.os !== platform || target.cpu !== arch) {
continue;
}
if (target.os === "linux" && target.libc !== libc) {
continue;
}
return key;
}
return undefined;
}
module.exports = { PLATFORM_MAP, getPlatformKey };