nodejs / node-addon-api

Module for using Node-API from C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enabling C++ exceptions on Windows is hell

mmomtchev opened this issue · comments

(this is the suite of nodejs/node-gyp#2903)

node-addon-api seems to include an undocumented but very useful file found node_modules\node-addon-api\except.gypi.

Alas, besides being undocumented, this file is very hard to use, since when a module is installed in production, its path will be different and gyp does not support variable expansion in includes directives.

After discussion in the node-addon-api team meeting today @legendecas is going to take a look at the issue in a bit more depth.

Tried with node-gyp -I option and automatic config.gypi detection, not working with no luck. However, I found that we can sort of solve the problem with a dummy gyp dependency. As documented at https://gyp.gsrc.io/docs/InputFormatReference.md#processing-order, a dependency's setting is processed after merging the root target_defaults, and variable expansion is allowed in dependency specifiers.

This allows the following pattern to enable c++ exception support:

'dependencies': [
  "<!(node -p \"require('node-addon-api').gyp\"):node-addon-api-except"
]