File tree Expand file tree Collapse file tree 5 files changed +42
-1
lines changed Expand file tree Collapse file tree 5 files changed +42
-1
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
@@ -1131,6 +1132,10 @@ def configure_node(o):
11311132 else :
11321133 o ['variables' ]['node_target_type' ] = 'executable'
11331134
1135+ def configure_napi (output ):
1136+ version = getnapibuildversion .get_napi_version ()
1137+ output ['variables' ]['napi_build_version' ] = version
1138+
11341139def configure_library (lib , output ):
11351140 shared_lib = 'shared_' + lib
11361141 output ['variables' ]['node_' + shared_lib ] = b (getattr (options , shared_lib ))
@@ -1603,6 +1608,7 @@ def make_bin_override():
16031608flavor = GetFlavor (flavor_params )
16041609
16051610configure_node (output )
1611+ configure_napi (output )
16061612configure_library ('zlib' , output )
16071613configure_library ('http_parser' , output )
16081614configure_library ('libuv' , output )
Original file line number Diff line number Diff line change @@ -661,6 +661,7 @@ An example of the possible output looks like:
661661 variables:
662662 {
663663 host_arch: ' x64' ,
664+ napi_build_version: 4 ,
664665 node_install_npm: ' true' ,
665666 node_prefix: ' ' ,
666667 node_shared_cares: ' false' ,
Original file line number Diff line number Diff line change 99// Use INT_MAX, this should only be consumed by the pre-processor anyway.
1010#define NAPI_VERSION 2147483647
1111#else
12- // The baseline version for N-API
12+ // The baseline version for N-API.
13+ // The NAPI_VERSION controls which version will be used by default when
14+ // compilling a native addon. If the addon developer specifically wants to use
15+ // functions available in a new version of N-API that is not yet ported in all
16+ // LTS versions, they can set NAPI_VERSION knowing that they have specifically
17+ // depended on that version.
1318#define NAPI_VERSION 6
1419#endif
1520#endif
Original file line number Diff line number Diff line change @@ -43,3 +43,6 @@ for (let i = 0; i < expected_keys.length; i++) {
4343 const descriptor = Object . getOwnPropertyDescriptor ( process . versions , key ) ;
4444 assert . strictEqual ( descriptor . writable , false ) ;
4545}
46+
47+ assert . strictEqual ( process . config . variables . napi_build_version ,
48+ 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