-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildcheck.js
81 lines (69 loc) · 1.63 KB
/
buildcheck.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
'use strict';
const BuildEnvironment = require('buildcheck');
const be = new BuildEnvironment();
const gyp = {
defines: [],
libraries: [],
};
[
'inttypes.h',
'malloc.h',
'memory.h',
'stdint.h',
'stdlib.h',
'string.h',
'strings.h',
'sys/types.h',
'sys/stat.h',
'unistd.h',
].forEach((headerName) => {
be.checkHeader('c', headerName);
});
// On Windows localtime_s is a macro, so we need to use `checkDeclared()`
[
['localtime_s', { headers: ['time.h'] }],
].forEach((fnName) => {
if (Array.isArray(fnName))
be.checkDeclared('c', ...fnName);
else
be.checkDeclared('c', fnName);
});
[
['fdatasync', { searchLibs: ['rt'] }],
'gmtime_r',
'isnan',
'localtime_r',
'malloc_usable_size',
'posix_fallocate',
'pread',
'pread64',
'pwrite',
'pwrite64',
'strchrnul',
'usleep',
'utime',
].forEach((fnName) => {
if (Array.isArray(fnName))
be.checkFunction('c', ...fnName);
else
be.checkFunction('c', fnName);
});
[
'strerror_r',
].forEach((feat) => {
be.checkFeature(feat);
});
// Custom defines --------------------------------------------------------------
gyp.defines.push(
'SQLITE_ENABLE_FTS3',
'SQLITE_ENABLE_JSON1',
);
if (be.checkFunction('c', 'log', { searchLibs: ['m'] }))
gyp.defines.push('SQLITE_ENABLE_FTS4', 'SQLITE_ENABLE_FTS5');
if (be.checkFunction('c', 'ceil', { searchLibs: ['m'] }))
gyp.defines.push('SQLITE_ENABLE_MATH_FUNCTIONS');
// -----------------------------------------------------------------------------
// Add the things we detected
gyp.defines.push(...be.defines(null, true));
gyp.libraries.push(...be.libs());
console.log(JSON.stringify(gyp, null, 2));