-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.js
53 lines (48 loc) · 1.42 KB
/
build.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
const nexe = require('nexe')
const fs = require('fs')
const path = require('path')
const pjson = require('./package.json')
const supportedPlatforms = [
['win32', 'windows', 'x64'],
['linux', 'linux', 'x64']
]
if (process.env.DOCKER) {
build('linux', 'linux', 'x64', '12.16.2')
} else {
for (const [platform, platformName, arch] of supportedPlatforms) {
build(platform, platformName, arch, '12.14.1')
}
}
function build (platform, platformName, arch, nodeVersion) {
const buildPath = `./compile/index_${platform}-${arch}.js`
fs.writeFileSync(
buildPath,
String(fs.readFileSync('./compile/index.js'))
.replace(
'./build/Release/farmhash.node',
`require("../farmhash_${platform}_72.node")`
)
.replace(
/return __webpack_require__.*\(`\.\/cws_\${process\.platform}_\${process\.versions\.modules}`\)/,
// eslint-disable-next-line no-template-curly-in-string
'return require(`../cws_${process.platform}_${process.versions.modules}`)'
)
)
nexe.compile({
input: buildPath,
output: path.join('compile', `net64plus-server_${pjson.version}_${platform}-${arch}`),
target: `${platformName}-${arch}-${nodeVersion}`,
native: {
cws: {
additionalFiles: [
`./compile/cws_${platform}_72.node`
]
},
farmhash: {
additionalFiles: [
`./compile/farmhash_${platform}_72.node`
]
}
}
})
}