durs / node-activex

Node.JS Implementaion of ActiveXObject

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support cross-platform builds

mklinke opened this issue · comments

Background

Our developers and CI/CD pipeline use different platforms (Windows, Linux, Mac) for working in a monorepo based on nx. Due to this, we have a single package.json with all dependencies.

Problem

After adding winax as a dependency, npm ci fails on platforms other than Windows, because it cannot build the native binaries using node-gyp:

> winax@1.20.0 install /build/node_modules/winax
> node-gyp rebuild
make: Entering directory '/build/node_modules/winax/build'
  CXX(target) Release/obj.target/node_activex/src/main.o
In file included from ../src/main.cpp:7:0:
../src/stdafx.h:3:10: fatal error: SDKDDKVer.h: No such file or directory
 #include <SDKDDKVer.h>
          ^~~~~~~~~~~~~
compilation terminated.
make: *** [Release/obj.target/node_activex/src/main.o] Error 1
node_activex.target.mk:111: recipe for target 'Release/obj.target/node_activex/src/main.o' failed
make: Leaving directory '/build/node_modules/winax/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 4.14.203-156.332.amzn2.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /build/node_modules/winax
gyp ERR! node -v v12.20.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! winax@1.20.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the winax@1.20.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-02-10T09_31_03_262Z-debug.log
The command '/bin/sh -c npm ci --no-optional --no-audit' returned a non-zero code: 1

Proposal

It would be great if the winax package could include prebuilt binaries for Windows.

For example, the ffi-napi project includes those binaries and we can at least install the packages on other platforms and even do a build that can be used on Windows. FWIW, they are using prebuildify to build the Windows binaries in an Appveyor build.

commented

Is there any workaround for this issue?
I'm also using winax in monorepo based on rushstack and it would be great to at least have a possibility to install winax on other environments

Even though the Windows API is needed, it would be very helpful if the package could still be installed independently of the current OS, for example to support monorepo builds where a single package.json is used and not all dependencies are needed all the time.

FWIW, we have created a custom build to remove the OS restriction and do a check during runtime instead.

Same here. Any progress? We want to build Electron only for Windows but have to build the app on Linux :(