build: expose napi_build_version variable · nodejs/node@cd71aad · GitHub
Skip to content

Commit cd71aad

Browse files
NickNasotargos
authored andcommitted
build: expose napi_build_version variable
Expose `napi_build_version` to allow `node-gyp` to make it available for building native addons. Fixes: nodejs/node-gyp#1745 Refs: nodejs/abi-stable-node#371 PR-URL: #27835 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 8a64b70 commit cd71aad

6 files changed

Lines changed: 44 additions & 2 deletions

File tree

configure.py

Lines changed: 6 additions & 0 deletions

doc/api/process.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ An example of the possible output looks like:
662662
variables:
663663
{
664664
host_arch: 'x64',
665+
napi_build_version: 4,
665666
node_install_npm: 'true',
666667
node_prefix: '',
667668
node_shared_cares: 'false',

src/js_native_api.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
#ifdef NAPI_EXPERIMENTAL
1313
#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL
1414
#else
15-
// The baseline version for N-API
15+
// The baseline version for N-API.
16+
// The NAPI_VERSION controls which version will be used by default when
17+
// compilling a native addon. If the addon developer specifically wants to use
18+
// functions available in a new version of N-API that is not yet ported in all
19+
// LTS versions, they can set NAPI_VERSION knowing that they have specifically
20+
// depended on that version.
1621
#define NAPI_VERSION 4
1722
#endif
1823
#endif

src/node_version.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191
*/
9292
#define NODE_MODULE_VERSION 72
9393

94-
// the NAPI_VERSION provided by this version of the runtime
94+
// The NAPI_VERSION provided by this version of the runtime. This is the version
95+
// which the Node binary being built supports.
9596
#define NAPI_VERSION 4
9697

9798
#endif // SRC_NODE_VERSION_H_

test/parallel/test-process-versions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ for (let i = 0; i < expected_keys.length; i++) {
4545
const descriptor = Object.getOwnPropertyDescriptor(process.versions, key);
4646
assert.strictEqual(descriptor.writable, false);
4747
}
48+
49+
assert.strictEqual(process.config.variables.napi_build_version,
50+
process.versions.napi);

tools/getnapibuildversion.py

Lines changed: 26 additions & 0 deletions

0 commit comments

Comments
 (0)