File tree Expand file tree Collapse file tree 6 files changed +44
-2
lines changed Expand file tree Collapse file tree 6 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 3434# imports in tools/
3535sys .path .insert (0 , 'tools' )
3636import getmoduleversion
37+ import getnapibuildversion
3738from gyp_node import run_gyp
3839
3940# imports in deps/v8/tools/node
@@ -1147,6 +1148,10 @@ def configure_node(o):
11471148 else :
11481149 o ['variables' ]['node_target_type' ] = 'executable'
11491150
1151+ def configure_napi (output ):
1152+ version = getnapibuildversion .get_napi_version ()
1153+ output ['variables' ]['napi_build_version' ] = version
1154+
11501155def configure_library (lib , output ):
11511156 shared_lib = 'shared_' + lib
11521157 output ['variables' ]['node_' + shared_lib ] = b (getattr (options , shared_lib ))
@@ -1626,6 +1631,7 @@ def make_bin_override():
16261631flavor = GetFlavor (flavor_params )
16271632
16281633configure_node (output )
1634+ configure_napi (output )
16291635configure_library ('zlib' , output )
16301636configure_library ('http_parser' , output )
16311637configure_library ('libuv' , output )
Original file line number Diff line number Diff 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' ,
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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_
Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff line change 1+ from __future__ import print_function
2+ import os
3+ import re
4+
5+
6+ def get_napi_version ():
7+ napi_version_h = os .path .join (
8+ os .path .dirname (__file__ ),
9+ '..' ,
10+ 'src' ,
11+ 'node_version.h' )
12+
13+ f = open (napi_version_h )
14+
15+ regex = '^#define NAPI_VERSION'
16+
17+ for line in f :
18+ if re .match (regex , line ):
19+ napi_version = line .split ()[2 ]
20+ return napi_version
21+
22+ raise Exception ('Could not find pattern matching %s' % regex )
23+
24+
25+ if __name__ == '__main__' :
26+ print (get_napi_version ())
You can’t perform that action at this time.
0 commit comments