Skip to content

Commit 461962a

Browse files
committed
update cxxStandard determination for C++20
1 parent efeb29a commit 461962a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

utils/defaultCxxStandard.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
const targetSpecified = process.argv[2] !== 'none';
22

3-
let isNode18OrElectron20AndUp = false;
3+
let cxxStandard = '14';
4+
45
if (targetSpecified) {
56
// Assume electron if target is specified.
67
// If building node 18 / 19 via target, will need to specify C++ standard manually
78
const majorVersion = process.argv[2].split('.')[0];
8-
isNode18OrElectron20AndUp = majorVersion >= 20;
9+
if (Number.parseInt(majorVersion) >= 32) {
10+
cxxStandard = '20';
11+
} else if (Number.parseInt(majorVersion) >= 21) {
12+
cxxStandard = '17';
13+
}
914
} else {
15+
const abiVersion = Number.parseInt(process.versions.modules) ?? 0;
1016
// Node 18 === 108
11-
isNode18OrElectron20AndUp = Number.parseInt(process.versions.modules) >= 108;
17+
if (abiVersion >= 131) {
18+
cxxStandard = '20';
19+
} else if (abiVersion >= 108) {
20+
cxxStandard = '17';
21+
}
1222
}
1323

14-
const defaultCxxStandard = isNode18OrElectron20AndUp
15-
? '17'
16-
: '14';
17-
18-
process.stdout.write(defaultCxxStandard);
24+
process.stdout.write(cxxStandard);

0 commit comments

Comments
 (0)