UNPKG

3.16 kBMarkdownView Raw
1# Manual Build
2
3::: tip INFO
4This is not required for regular users. You should follow this page only if you want to build the source files yourself.
5:::
6
7Firstly, run this script
8```js
9const path = require('path');
10const runtime = process.versions['electron'] ? 'electron' : 'node';
11const essential = runtime + '-v' + process.versions.modules + '-' + process.platform + '-' + process.arch;
12const modulePath = path.join(__dirname, 'builds', essential, 'build', 'Release', 'iohook.node');
13console.info('The path is:', modulePath);
14```
15and get the full path, to where the package looks for the binary. (It's enough to run `node index.js` and look for result of the `console.info` in line `15`).
16Then, run `npm run build` and copy created binary `iohook.node` file from `build/Release/iohook.node` to the `console.info`'ed path.
17Running `node examples/example.js` should show you a working result of your build.
18For build requirements for your OS look below.
19
20## Ubuntu 16
21- `sudo apt install libx11-dev libxtst-dev libxt-dev libx11-xcb-dev libxkbcommon-dev libxkbcommon-x11-dev libpng-dev`
22- `npm run build`
23
24## macOS
25- `brew install cmake automake libtool pkg-config`
26- `npm run build`
27
28## Windows
29- Install: msys2 with autotools, pkg-config, libtool, gcc, clang, glib, C++ Build Tools, cmake
30- `npm run build`
31
32## Building for specific versions of node
33
34After running `npm run build`, if you want to build iohook for a specific
35node/electron version, you can use `build.js` which features the following
36command line options:
37
38* `--runtime` specifies whether to build for Electron or plain node
39* `--version` specifies what version of Electron/node to build for
40* `--abi` specifies what [ABI version](https://nodejs.org/en/docs/guides/abi-stability/) of Electron/node to build against
41
42For example, to build for Electron v4.0.4, you would run:
43
44```
45node build.js --runtime electron --version 4.0.4 --abi 69
46```
47
48To see more examples of what values to use, view iohook's [package.json file](https://github.com/wilix-team/iohook/blob/master/package.json), under `supportedTargets`. The three values in each block are runtime, version and abi respectively.
49
50`--runtime`, `--version` and `--abi` must all be supplied to build for a specific node version. If they are not supplied, `build.js` will build for the versions specified under `supportedTargets` in your `package.json` (again, see iohook's [package.json file](https://github.com/wilix-team/iohook/blob/master/package.json) for details).
51
52* `--no-upload` tells the script not to attempt to upload the built files to GitHub afterwards
53
54Typically `build.js` is used as part of iohook's CI in order to upload newly-built binaries to NPM. This is thus the default behavior of the script. To prevent this, supply the `--no-upload` flag:
55
56```
57node build.js --no-upload
58```
59
60# Testing
61
62iohook uses Jest for automated testing. To execute tests, run `npm run test` in your console.
63
64::: warning
65It is important you don't press any buttons on your keyboard, don't use your mouse nor the scroll wheel. Tests depend on native events fired by the real keyboard and mouse. Interrupting them will cause tests to fail.
66:::