You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jim mentioned that the N-API team (and by that I mean Jim :)) added the concept a Napi-version to node-pre-gyp and prebuild. @jschlight will take a look at whether something similar makes sense for node-gyp.
(doesn't have to be awk -- the main thing is <(node_root_dir)/include/node/node_version.h) which is the header files being compiled against (node_root_dir is set by node-gyp)).
Yeah NAPI_VERSION is what I’m after. That’d do the trick, although it wouldn’t work on windows because there’s no awk there. For my project I’ve landed on an awful workaround of just making a bunch of indirect source files that conditionally include the right source files. It’d be nice to sort this out via gyp though.
Definitely not opposed to having node-gyp define a napi_version variable for use in binding.gyp files, but bear in mind it would take a while to filter through to dependents, e.g. npm (and, for example, the default version of npm in, say, Node.js 8, and by extension its version of node-gyp is unlikely to get updated).
node-pre-gyp and prebuild permit the user to request multiple builds using node-gyp. For both tools we defined a new node-gyp variable napi_build_version, accessible in the binding.gyp file, that communicates the N-API version the tool is requesting to build.
I think the work we did there does not apply to this situation.
node-gyp isn't the right place to embed that logic. If node exposes a napi_build_version through its common.gypi, node-gyp will automagically make it available to add-ons. I suggest moving this to nodejs/node.
Activity
mhdawson commentedon May 13, 2019
We discussed in the N-API team meeting today.
Jim mentioned that the N-API team (and by that I mean Jim :)) added the concept a Napi-version to
node-pre-gypandprebuild. @jschlight will take a look at whether something similar makes sense for node-gyp.richardlau commentedon May 13, 2019
Is the desired variable
NAPI_VERSIONfromnode_version.h? If so something like this:(doesn't have to be
awk-- the main thing is<(node_root_dir)/include/node/node_version.h)which is the header files being compiled against (node_root_diris set bynode-gyp)).josephg commentedon May 13, 2019
Yeah
NAPI_VERSIONis what I’m after. That’d do the trick, although it wouldn’t work on windows because there’s no awk there. For my project I’ve landed on an awful workaround of just making a bunch of indirect source files that conditionally include the right source files. It’d be nice to sort this out via gyp though.richardlau commentedon May 13, 2019
Maybe something like the following for cross-platform (looks messy because of the needed escaping):
Definitely not opposed to having
node-gypdefine anapi_versionvariable for use inbinding.gypfiles, but bear in mind it would take a while to filter through to dependents, e.g.npm(and, for example, the default version ofnpmin, say, Node.js 8, and by extension its version ofnode-gypis unlikely to get updated).jschlight commentedon May 14, 2019
node-pre-gyp and prebuild permit the user to request multiple builds using
node-gyp. For both tools we defined a newnode-gypvariablenapi_build_version, accessible in thebinding.gypfile, that communicates the N-API version the tool is requesting to build.I think the work we did there does not apply to this situation.
bnoordhuis commentedon May 16, 2019
node-gyp isn't the right place to embed that logic. If node exposes a
napi_build_versionthrough its common.gypi, node-gyp will automagically make it available to add-ons. I suggest moving this to nodejs/node.bnoordhuis commentedon Jun 20, 2019
There's an open pull request over at nodejs/node that is this close to landing so I'll go ahead and close out this issue.
build: expose napi_build_version variable
build: expose napi_build_version variable
build: expose napi_build_version variable
build: expose napi_build_version variable