-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathprebuiltBinding.js
87 lines (79 loc) · 4.79 KB
/
prebuiltBinding.js
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
85
86
87
const os = require('node:os')
const fs = require('fs')
const util = require('util')
const exec = util.promisify(require('child_process').exec)
const rename = util.promisify(fs.rename)
const rm = util.promisify(fs.rm)
;(async function () {
const platform = await os.platform()
const arch = await os.arch()
if (platform === 'darwin') {
console.log('Darwin binaries')
await rm('lib/binding/node-v131-win32-x64', { recursive: true, force: true })
await rm('lib/binding/node-v127-win32-x64', { recursive: true, force: true })
await rm('lib/binding/node-v115-win32-x64', { recursive: true, force: true })
await rm('lib/binding/node-v108-win32-x64', { recursive: true, force: true })
if (arch === 'x64') {
await rm('lib/binding/node-v131-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v127-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v115-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v108-darwin-arm64', { recursive: true, force: true })
} else {
await rm('lib/binding/node-v131-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/node-v127-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/node-v115-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/node-v108-darwin-x64', { recursive: true, force: true })
}
await rm('lib/binding/glibc@2.35', { recursive: true, force: true })
await rm('lib/binding/glibc@2.31', { recursive: true, force: true })
} else if (platform === 'win32') {
console.log('Windows binaries')
await rm('lib/binding/node-v131-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v127-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v115-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v108-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v131-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/node-v127-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/node-v115-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/node-v108-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/glibc@2.35', { recursive: true, force: true })
await rm('lib/binding/glibc@2.31', { recursive: true, force: true })
} else {
console.log('Linux binaries')
await rm('lib/binding/node-v131-win32-x64', { recursive: true, force: true })
await rm('lib/binding/node-v127-win32-x64', { recursive: true, force: true })
await rm('lib/binding/node-v115-win32-x64', { recursive: true, force: true })
await rm('lib/binding/node-v108-win32-x64', { recursive: true, force: true })
await rm('lib/binding/node-v131-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v127-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v115-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v108-darwin-arm64', { recursive: true, force: true })
await rm('lib/binding/node-v131-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/node-v127-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/node-v115-darwin-x64', { recursive: true, force: true })
await rm('lib/binding/node-v108-darwin-x64', { recursive: true, force: true })
const output = await exec("ldd --version | awk 'NR==1{print $NF}'")
const version = Number(output.stdout)
let glibc
if (version < 2.35) {
glibc = '2.31'
} else {
glibc = '2.35'
}
console.log('GLIBC version: ' + glibc)
console.log('ARCH: ' + arch)
if (arch === 'x64') {
await rename('lib/binding/glibc@' + glibc + '/node-v131-linux-x64', 'lib/binding/node-v131-linux-x64')
await rename('lib/binding/glibc@' + glibc + '/node-v127-linux-x64', 'lib/binding/node-v127-linux-x64')
await rename('lib/binding/glibc@' + glibc + '/node-v115-linux-x64', 'lib/binding/node-v115-linux-x64')
await rename('lib/binding/glibc@' + glibc + '/node-v108-linux-x64', 'lib/binding/node-v108-linux-x64')
} else {
await rename('lib/binding/glibc@' + glibc + '/node-v131-linux-arm64', 'lib/binding/node-v131-linux-arm64')
await rename('lib/binding/glibc@' + glibc + '/node-v127-linux-arm64', 'lib/binding/node-v127-linux-arm64')
await rename('lib/binding/glibc@' + glibc + '/node-v115-linux-arm64', 'lib/binding/node-v115-linux-arm64')
await rename('lib/binding/glibc@' + glibc + '/node-v108-linux-arm64', 'lib/binding/node-v108-linux-arm64')
}
await rm('lib/binding/glibc@2.31', { recursive: true, force: true })
await rm('lib/binding/glibc@2.35', { recursive: true, force: true })
}
})()