Giter Club home page Giter Club logo

Comments (12)

gabrielschulhof avatar gabrielschulhof commented on July 27, 2024

Also, all the other node-addon-api exports can be added unconditionally to either the "include_dirs" or "dependencies" of a dependent target, because the conditionality is encapsulated in index.js.

from node-addon-api.

gabrielschulhof avatar gabrielschulhof commented on July 27, 2024

I guess it doesn't really cost that much to keep .isNodeApiBuiltin so we export something that can be used as a condition statement for unforeseen use cases, but we should definitely have the .defines in addition.

from node-addon-api.

jasongin avatar jasongin commented on July 27, 2024

The .isNodeApiBuiltin export was meant to be exposed as a runtime flag in case anybody wanted to write code to check that. But it's not used anywhere today, and there should be no need to use it at build time.

Did you follow the instructions in the README? You shouldn't need to define EXTERNAL_NAPI anywhere in your module's node.gyp. That is taken care of by these two lines to be added to your node.gyp:

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

Then when you #include "napi.h" that should get src/napi.h that has #define EXTERNAL_NAPI at the top.

from node-addon-api.

gabrielschulhof avatar gabrielschulhof commented on July 27, 2024

I don't use the C++ API.

from node-addon-api.

gabrielschulhof avatar gabrielschulhof commented on July 27, 2024

https://github.com/gabrielschulhof/iotivity-node/blob/node-addon-api/binding.gyp#L221-L232

from node-addon-api.

gabrielschulhof avatar gabrielschulhof commented on July 27, 2024

OK, I guess I can include napi.h directly, because I'm doing C++ anyway.

from node-addon-api.

gabrielschulhof avatar gabrielschulhof commented on July 27, 2024

I can't use napi.h because that requires exception handling to be enabled, which, for the plain C API I don't need.

from node-addon-api.

jasongin avatar jasongin commented on July 27, 2024

Hmm... using only the C APIs via this package wasn't a scenario I considered.

from node-addon-api.

gabrielschulhof avatar gabrielschulhof commented on July 27, 2024

Well, adding .defines and a mention in the README.md should cover plain C.

from node-addon-api.

jasongin avatar jasongin commented on July 27, 2024

Yes that will work. I had wanted to minimize the amount of stuff you have to add to your .gyp file. But one more line won't hurt.

from node-addon-api.

gabrielschulhof avatar gabrielschulhof commented on July 27, 2024

Although perhaps you could do the path juggling as you do now, but instead of including napi.h after defining EXTERNAL_NAPI, you include node_api.h.

from node-addon-api.

gabrielschulhof avatar gabrielschulhof commented on July 27, 2024

... and then, when napi.h includes node_api.h, it will receive it from the appropriate directory.

from node-addon-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.