iohook
iohook copied to clipboard
master branch checked out in stand-alone dir builds -- fails building in electron apps ./node_modules/iohook
environment: os: macOs 11.6.1
$ node_modules/electron/dist/Electron.app/Contents/MacOS/Electron --version
v13.2.3
$ node_modules/electron/dist/Electron.app/Contents/MacOS/Electron --abi
89
I can clone iohook to a stand alone directory and successfully build with this command:
$ git clone [email protected]:wilix-team/iohook.git
$ cd iohook
$ npm install
$ node build.js --runtime electron --version 13.2.3 --abi 89 --upload=false
gyp ends with an ok and this file is generated:
$ ls -l build/Release/iohook.node
-rwxr-xr-x 1 stephen staff 70616 Oct 31 02:14 build/Release/iohook.node
So I tried an equivalent series of commands to do this in my electron applications node_modules
directory:
$ npm install github:wilix-team/iohook#229774494 --save
$ cd node_modules/iohook
$ npm install
$ node build.js --runtime electron --version 13.2.3 --abi 89 --upload=false
Which fails with this error:
make: *** No rule to make target `Release/obj.target/uiohook/libuiohook/src/logger.o', needed by `Release/uiohook.dylib'. Stop.
Here's the console log:
Building iohook for electron v13.2.3>>>>
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 3.9.7 found at "/usr/local/opt/[email protected]/bin/python3.9"
gyp info spawn /usr/local/opt/[email protected]/bin/python3.9
gyp info spawn args [
gyp info spawn args '/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/stephen/Library/Caches/node-gyp/13.2.3/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/stephen/Library/Caches/node-gyp/13.2.3',
gyp info spawn args '-Dnode_gyp_dir=/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/stephen/Library/Caches/node-gyp/13.2.3/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info find Python using Python version 3.9.7 found at "/usr/local/opt/[email protected]/bin/python3.9"
gyp info spawn /usr/local/opt/[email protected]/bin/python3.9
gyp info spawn args [
gyp info spawn args '/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/stephen/Library/Caches/node-gyp/13.2.3/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/stephen/Library/Caches/node-gyp/13.2.3',
gyp info spawn args '-Dnode_gyp_dir=/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/stephen/Library/Caches/node-gyp/13.2.3/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: *** No rule to make target `Release/obj.target/uiohook/libuiohook/src/logger.o', needed by `Release/uiohook.dylib'. Stop.
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command "/Users/stephen/.nvm/versions/node/v14.18.1/bin/node" "/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/node_modules/.bin/node-gyp" "configure" "rebuild" "--target=13.2.3" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--v8_enable_pointer_compression=1" "--build_v8_with_gn=false" "--enable_lto=false"
gyp ERR! cwd /Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook
gyp ERR! node -v v14.18.1
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok
Error: Failed to build...
at ChildProcess.<anonymous> (/Users/stephen/dev/00-clients/rlmg/cfa-own-electron/node_modules/iohook/build.js:188:23)
at ChildProcess.emit (events.js:400:28)
at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
I already have iohook in the package.json dependencies for the electron app so when I manually create the destination path and copy iohook.node
successfully built in the git clone in a separate directory iohook and the application work without error.
I'd like to be able to do this in electron-forge more automatically and build distributable artifacts for Windows and macOS.
This manual process worked:
$ mkdir -p './out/CfA OWN Electron-darwin-x64/CfA OWN Electron.app/Contents/Resources/app/.webpack/main/builds/electron-v89-darwin-x64/build/Release'
$ ls -asl './out/CfA OWN Electron-darwin-x64/CfA OWN Electron.app/Contents/Resources/app/.webpack/main/builds/electron-v89-darwin-x64/build/Release'
total 0
0 drwxr-xr-x 2 stephen staff 64 Oct 31 02:40 .
0 drwxr-xr-x 3 stephen staff 96 Oct 31 02:40 ..
$ ls -l ../iohook/build/Release/iohook.node
-rwxr-xr-x 1 stephen staff 70616 Oct 31 02:14 ../iohook/build/Release/iohook.node
$ cp ../iohook/build/Release/iohook.node './out/CfA OWN Electron-darwin-x64/CfA OWN Electron.app/Contents/Resources/app/.webpack/main/builds/electron-v89-darwin-x64/build/Release'
$ ls -l './out/CfA OWN Electron-darwin-x64/CfA OWN Electron.app/Contents/Resources/app/.webpack/main/builds/electron-v89-darwin-x64/build/Release'
144 -rwxr-xr-x 1 stephen staff 70616 Oct 31 02:41 iohook.node
When you do npm install iohook
only the essential "prod" part of the library is installed inside node_modules/iohook
. When you clone the iohook repo you get the complete library source with everything needed to manually build. You could for convenience move the entire dev repo into node_modules/iohook
and build from there, but then you'd have a lot of unnecessary junk packaged with your electron app unless you add exceptions to your Forge config to exclude them. The easiest thing to do in this situation IMHO is to have your separate iohook clone folder where you do your manual build, then copy your build files *.node and *.dylib into e.g. [your electron app source]/node_modules/iohook/builds/electron-v89-darwin-x64/buildRelease/
and then Forge will automatically include those in your packaged app.