-
Notifications
You must be signed in to change notification settings - Fork 3
/
build_binary.js
31 lines (22 loc) · 970 Bytes
/
build_binary.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
// @ts-nocheck
const fs = require('fs')
const { spawn, execSync } = require('child_process')
const { tdlib } = require('./package.json')
console.log('Downloading tdlib...')
execSync('git clone https://github.com/tdlib/td.git && cd td && git checkout ' + tdlib.commit + ' && cd ../', {stdio: 'ignore'})
console.log('Launching compiler, please wait...')
let cmd = 'cmake-js'
let cmdOptions = ['compile', '-C']
if (tdlib.debug) cmdOptions.push('-D')
let cmakeJs = spawn(cmd, cmdOptions)
cmakeJs.stdout.on('data', (data) => console.log(data.toString()))
cmakeJs.stderr.on('data', (data) => console.error(data.toString()))
cmakeJs.on('exit', function (code) {
if (code === 0) {
console.log('Moving artifact into correct location...')
fs.renameSync(`./build/${tdlib.debug ? 'Debug' : 'Release'}/tdlib.node`, './tdlib.node')
}
console.log('Cleaning up...')
execSync('rm -fR build && rm -fR td', {stdio: 'ignore'})
process.exit(0)
})