octalmage / robotjs

Node.js Desktop Automation.
http://robotjs.io
MIT License
12.34k stars 955 forks source link

Multiple compile warnings and an error in 0.6.0 with node 16.14.2 - error in mouse.c #736

Open Sinc63 opened 1 year ago

Sinc63 commented 1 year ago

Expected Behavior

Code should compile. :-)

Current Behavior

warning Error running install script for optional dependency: "/var/rpmbuild/BUILD/infinity_one/client/node_modules/robotjs: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild
Arguments:
Directory: /var/rpmbuild/BUILD/infinity_one/client/node_modules/robotjs
Output:
prebuild-install WARN install No prebuilt binaries found (target=16.14.2 runtime=node arch=x64 libc= platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp@8.4.1
gyp info using node@16.14.2 | linux | x64
gyp info find Python using Python version 3.6.8 found at \"/usr/bin/python3\"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/var/src/.asdf/installs/nodejs/16.14.2/lib/node_modules/npm/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   '/var/rpmbuild/BUILD/infinity_one/client/node_modules/robotjs/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/var/src/.asdf/installs/nodejs/16.14.2/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.cache/node-gyp/16.14.2/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/16.14.2',
gyp info spawn args   '-Dnode_gyp_dir=/var/src/.asdf/installs/nodejs/16.14.2/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/16.14.2/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/var/rpmbuild/BUILD/infinity_one/client/node_modules/robotjs',
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: Entering directory '/var/rpmbuild/BUILD/infinity_one/client/node_modules/robotjs/build'
  CXX(target) Release/obj.target/robotjs/src/robotjs.o
cc1plus: warning: command line option ‘-Wbad-function-cast’ is valid for C/ObjC but not for C++
In file included from ../src/robotjs.cc:1:
/root/.cache/node-gyp/16.14.2/include/node/node.h:842:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
       (node::addon_register_func) (regfunc),                          \\\n                                           ^
/root/.cache/node-gyp/16.14.2/include/node/node.h:876:3: note: in expansion of macro ‘NODE_MODULE_X’
   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
   ^~~~~~~~~~~~~
../src/robotjs.cc:907:1: note: in expansion of macro ‘NODE_MODULE’
 NODE_MODULE(robotjs, InitAll)
 ^~~~~~~~~~~
../src/robotjs.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE keyToggle(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/robotjs.cc:592:17: warning: ‘down’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    toggleKeyCode(key, down, flags);
    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from ../../nan/nan_new.h:189,
                 from ../../nan/nan.h:294,
                 from ../src/robotjs.cc:2:
../../nan/nan_implementation_12_inl.h: In function ‘void InitAll(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’:
../../nan/nan_implementation_12_inl.h:119:1: warning: inlining failed in call to ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’: --param large-function-growth limit reached [-Winline]
 Factory<v8::FunctionTemplate>::New( FunctionCallback callback
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../nan/nan.h:294,
                 from ../src/robotjs.cc:2:
../../nan/nan_new.h:239:32: note: called from here
     return imp::Factory<T>::New(callback, data);
            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
In file included from ../../nan/nan_new.h:189,
                 from ../../nan/nan.h:294,
                 from ../src/robotjs.cc:2:
../../nan/nan_implementation_12_inl.h:119:1: warning: inlining failed in call to ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’: --param large-function-growth limit reached [-Winline]
 Factory<v8::FunctionTemplate>::New( FunctionCallback callback
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../nan/nan.h:294,
                 from ../src/robotjs.cc:2:
../../nan/nan_new.h:239:32: note: called from here
     return imp::Factory<T>::New(callback, data);
            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
  CC(target) Release/obj.target/robotjs/src/deadbeef_rand.o
  CC(target) Release/obj.target/robotjs/src/mouse.o
../src/mouse.c:12:11: fatal error: X11/extensions/XTest.h: No such file or directory
  #include <X11/extensions/XTest.h>
           ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [robotjs.target.mk:135: Release/obj.target/robotjs/src/mouse.o] Error 1
make: Leaving directory '/var/rpmbuild/BUILD/infinity_one/client/node_modules/robotjs/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/var/src/.asdf/installs/nodejs/16.14.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:526:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 4.18.0-425.13.1.0.1.el8_7.x86_64
gyp ERR! command \"/var/src/.asdf/installs/nodejs/16.14.2/bin/node\" \"/var/src/.asdf/installs/nodejs/16.14.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"rebuild\"
gyp ERR! cwd /var/rpmbuild/BUILD/infinity_one/client/node_modules/robotjs
gyp ERR! node -v v16.14.2
gyp ERR! node-gyp -v v8.4.1
gyp ERR! not ok"
info This module is OPTIONAL, you can safely ignore this error

Possible Solution

Steps to Reproduce (for bugs)

  1. Build

Context

Trying to build a load of our system. Apparently we ignore this because it's an optional dependency, but that doesn't mean I shouldn't tell you about it. Might help someone else out.

Your Environment

s1hofmann commented 1 year ago

Your machine is missing XTest headers

fatal error: X11/extensions/XTest.h: No such file or directory

Sinc63 commented 1 year ago

Your machine is missing XTest headers

fatal error: X11/extensions/XTest.h: No such file or directory

Thanks. If this project depends on that header, shouldn't the library and/or package be declared as a dependency of this package, so that installing this code ensures installation of all its dependencies? and maybe have the make file set up so that if the dependency is missing it fails with a more definitive message?

Also, I'm running this in RedHat Linux, so if I understand the "X" reference correctly, nothing here is running in X (probably why I don't have the package), so should the code that needs this header have some conditional compilation around it so that it doesn't use the X headers if it isn't compiling in an X environment, or for an X target?

s1hofmann commented 1 year ago

To be fair, it's listed as a dependency in the readme.

But IMHO, using the library shouldn't require you to compile anything. In my own framework everything comes pre-compiled.

On the other hand, this repo is inactive, so it is what it is.

Also, I'm running this in RedHat Linux, so if I understand the "X" reference correctly, nothing here is running in X (probably why I don't have the package), so should the code that needs this header have some conditional compilation around it so that it doesn't use the X headers if it isn't compiling in an X environment, or for an X target?

Well, if it did that most of its Linux part wouldn't work. I'm currently investigating a generic way to make input simulation work generically on both X11 and Wayland, but that's only in its planning phase at the moment.

ftyszyx commented 2 weeks ago

Robotjs (https://github.com/octalmage/robotjs)is build use V8 API.So it must be rebuilt for different Node versions. This is a big trouble when installing on a platform that has no build environment.. So I rewrapped Robotjs with Node API and prebuilt it. Now you can install robotjs_addon with just one command npm install robotjs_addon And it is compatible with different Node versions. It's open source. You can check it out if you are interested.https://github.com/ftyszyx/robotjs Warm: some api is removed,because there is no need for me, you can help to improve.