Skip to content

Conversation

gabrielschulhof
Copy link
Contributor

@gabrielschulhof gabrielschulhof commented May 16, 2017

Instead of making the path from which napi.h is included conditional
upon the Node.js version, make the path of node_api.h thusly
conditional. This way, no additional modification needs to be made to a
dependent's binding.gyp in order to add the EXTERNAL_NAPI preprocessor
directive when the C++ wrappers are not used.

By this mechanism the C++ wrapper napi.h will also refer to the correct
version of node_api.h.

Fixes #40
Fixes #41

}
```

2. Reference this package's include directory and gyp file in `binding.gyp`:
```gyp
'include_dirs': ["<!(node -p \"require('node-addon-api').include\")"],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the @ do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It indicates that the output of the command is to be used to fill out an array. In this case, it uses the double quotes I add in index.js to correctly split the output into array elements, stripping the quotes, so the paths are not misinterpreted.

README.md Outdated
@@ -16,13 +16,13 @@ To use N-API in a native module:
1. Add a dependency on this package to `package.json`:
```json
"dependencies": {
"node-addon-api": "github:nodejs/node-addon-api",
"node-addon-api": "github:nodejs/node-api",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting this repo would actually get renamed to node-addon-api. @mhdawson what do you think?

Instead of making the path from which napi.h is included conditional
upon the Node.js version, make the path of node_api.h thusly
conditional. This way, no additional modification needs to be made to a
dependent's binding.gyp in order to add the EXTERNAL_NAPI preprocessor
directive when the C++ wrappers are not used.

By this mechanism the C++ wrapper napi.h will also refer to the correct
version of node_api.h.

Fixes #41
@gabrielschulhof
Copy link
Contributor Author

@jasongin the PR no longer changes the README.md example showing how to depend on the repo.

@jasongin jasongin merged commit f797d14 into nodejs:master May 23, 2017
@jasongin
Copy link
Member

@gabrielschulhof I published node-addon-api@0.3.0 to NPM, which includes this change. So, your library can depend on it by name@version now instead of a repo URI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants