-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dependencies.js
executable file
·105 lines (96 loc) · 2.44 KB
/
Dependencies.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const os = require('os');
const fs = require('fs');
const { execSync } = require('child_process');
const deps = {
"Native": {
"Prefix": "",
"Prefix directory": "/usr/local",
"Build tools": {
"libtoolize": false,
"aclocal": false,
"autoheader": false,
"automake": false,
"autoconf": false,
"pkg-config": false
},
"Compilers": {
"g++": false,
},
"Libraries": {
"jsoncpp": false,
"uuid": false,
"ecs-cpp": false,
"the-seed": false,
"LIEF": false
},
"Files": {
}
},
"Win64": {
"Prefix": "x86_64-w64-mingw32-",
"Prefix directory": "/usr/x86_64-w64-mingw32",
"Build tools": {
"libtoolize": false,
"aclocal": false,
"autoheader": false,
"automake": false,
"autoconf": false,
"x86_64-w64-mingw32-pkg-config": false
},
"Compilers": {
"g++": false
},
"Libraries": {
"jsoncpp": false,
"ecs-cpp": false,
"the-seed": false
},
"Files": {
"include/mingw.thread.h": false,
"include/mingw.invoke.h": false,
"include/mingw.mutex.h": false
}
}
}
class Dependencies {
constructor() {
Object.keys(deps).forEach(target => {
let prefix = deps[target].Prefix;
let prefixDir = deps[target]["Prefix directory"];
Object.keys(deps[target]["Build tools"]).forEach(tool => {
let check_command = "which " + tool;
try {
let result = execSync(check_command).toString();
deps[target]["Build tools"][tool] = result;
} catch(err) {
}
});
let pkg_config_command = prefix + "pkg-config --exists ";
Object.keys(deps[target].Libraries).forEach(lib => {
let check_command = pkg_config_command + lib;
try {
execSync(check_command);
deps[target].Libraries[lib] = true;
} catch(err) {
}
});
Object.keys(deps[target]["Compilers"]).forEach(compiler => {
let check_command = "which " + prefix + compiler;
try {
let result = execSync(check_command).toString();
deps[target]["Compilers"][compiler] = result;
} catch(err) {
}
});
Object.keys(deps[target].Files).forEach(file => {
if(fs.existsSync(prefixDir + "/" + file)) {
deps[target].Files[file] = true;
}
});
});
}
Dependencies() {
return deps;
}
}
module.exports = Dependencies;