-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathprepare.js
45 lines (34 loc) · 1.5 KB
/
prepare.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
// prepare luajit cjson protobuf
// (test -d 3rdlibs || mkdir 3rdlibs) && cd 3rdlibs && wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz && tar -xf LuaJIT-2.0.5.tar.gz
const url = 'http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz';
const cjsonurl = 'https://github.com/openresty/lua-cjson/archive/master.zip';
const cjsonname = 'lua-cjson';
const luajitname = 'LuaJIT';
const os = require('os');
const fs = require('fs');
const spawn = require('child_process').spawn;
if (os.platform() === 'win32') {
// shell.exec('sudo make install');
// console.warn(' windows maybe trigger error. because windows not have wget,tar and unzip command!');
}
if (os.platform() === 'darwin') {
console.warn('os x can not use luajit,use default maclualib');
return 0;
}
let child;
if (os.platform() === 'win32') {
// child = spawn('cd 3rdlibs\\LuaJIT\\src && msvcbuild.bat',{shell:true});
console.log("win32 use pre build library. You could compile dll by yourself,put lua51.dll,lua51.lib into win64luajit and run npm i")
return 0
} else {
// linux
child = spawn('cd 3rdlibs/LuaJIT && make && make install', {shell: true});
}
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
child.on('close', function (code) {
console.log('compile LuaJIT result code:', code);
});
//shell.cd(cjsonname);
//shell.exec('make LUA_INCLUDE_DIR="../'+luajitname+'/src" LUA_BIN_DIR="../'+ luajitname+'/src" LUA_CMODULE_DIR="../' + luajitname+'/src" LUA_MODULE_DIR="../'+luajitname+'/src"');
return 0;